This GitHub Action makes it easy to pull versions from XML files. It can be used in your workflows for other uses such as version validation, version tag management, and more!!
TLDR - Additional Info
In a nutshell, VersionMiner pulls versions out of XML data files for use in workflows.
Just tell the action which repo, branch, and file contains the version, and it will search through the file for the version-keys and pull out the value of that key. This value is used as the value of the action's output,
which has the name version, so you can use it in the rest of your workflow.
TLDR - Use Cases
- Create tags automatically with the version, during the release process.
- Validate the version syntax to help enforce version syntax.
- Example: Semantic version vs. a date-based version.
- Manage release note file names by having the version embedded in the file name.
- Use the version in the title of a GitHub release.
- Release announcements.
- Example: Use the version in a release announcement on Twitter.
- Use status check workflows to verify versions before a pull request can be completed.
Note VersionMiner is built using C#/NET and runs in a docker container. If the job step for running this action is contained in a job that runs on Windows, you will need to move the step to a job that runs on Ubuntu. You can split up your jobs to fulfill the
runs-onrequirements of the GitHub action. This can be accomplished by moving the step into its job. You can then route the action step outputs to the job outputs and use them throughout the rest of your workflow.
For more information on step and job outputs, refer to the GitHub documentation links below:
name: Get Version Example
jobs:
get_version_job:
runs-on: ubuntu-latest # Cannot use windows
steps:
- uses: actions/3
- name: Get Version From C# Project File
id: get-version
uses: KinsonDigital/VersionMiner@v1.0.0-preview.2
with:
repo-owner: JohnDoe
repo-name: MyRepo
repo-token: ${{ secrets.GITHUB_TOKEN }}
branch-name: main
file-format: xml # Not case sensitive
file-path: "MyProject/MyProject.csproj"
version-keys: Version
- name: Print Version From File
id: print-output
run: echo "${{ steps.get-version.outputs.version }}"If the XML file had the contents below, the workflow above would print the value 1.2.3 to the GitHub console.
<!--Quick Example - C# Project File-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<Version>1.2.3</Version> <!--The version that would be discovered-->
<FileVersion>0.1.0</FileVersion>
</PropertyGroup>
</Project>The action output is a single string value with the name version. Click here to see an example of how to use the output of the action.
Searches for a version but does not fail the workflow if no version is found:
#Example 1 Workflow
- name: Get Version From C# Project File
uses: KinsonDigital/VersionMiner@v1.0.0-preview.2
with:
repo-owner: JohnDoe
repo-name: MyRepo
repo-token: ${{ secrets.GITHUB_TOKEN }}
branch-name: main
file-format: xml # Not case sensitive
file-path: "${{ github.workspace }}/MyProject/MyProject.csproj"
version-keys: Version
fail-when-version-not-found: false<!--Example 1 - C# Project File-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<Version></Version> <!--No value. Does not fail workflow.-->
</PropertyGroup>
</Project>#Example 2 Workflow
- name: Get Version From C# Project File
uses: KinsonDigital/VersionMiner@v1.0.0-preview.2
with:
repo-owner: JohnDoe
repo-name: MyRepo
repo-token: ${{ secrets.GITHUB_TOKEN }}
branch-name: main
file-format: xml # Not case sensitive
file-path: "MyProject/MyProject.csproj"
version-keys: "Version,FileVersion"<!--Example 2 - C# Project File-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<Version></Version> <!--No value. Search continues for the FileVersion key-->
<FileVersion>4.5.6</FileVersion> <!--Key with a value exists so this value is returned-->
</PropertyGroup>
</Project>#Example 3 Workflow
- name: Get Version From C# Project File
uses: KinsonDigital/VersionMiner@v1.0.0-preview.2
with:
repo-owner: JohnDoe
repo-name: MyRepo
repo-token: ${{ secrets.GITHUB_TOKEN }}
branch-name: main
file-format: xml # Not case sensitive
file-path: "MyProject/MyProject.csproj"
version-keys: VeRSion # Different casing as the XML key below.
case-sensitive-keys: false # Not required and has a default value of true.<!--Example 3 - C# Project File-->
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>11.0</LangVersion>
<version>1.2.3</version> <!--Casing does not match but key is still used.-->
</PropertyGroup>
</Project>Trims the value refs/heads/ from the beginning of the branch.
Note Click here to get more information about the default variable
github.refused in the example below:
#Example 4 Workflow
- name: Get Version From C# Project File
uses: KinsonDigital/VersionMiner@v1.0.0-preview.2
with:
repo-owner: JohnDoe
repo-name: MyRepo
repo-token: ${{ secrets.GITHUB_TOKEN }}
branch-name: ${{ github.ref }} # If the branch was 'my-branch', this value could be 'refs/heads/my-branch'
file-format: xml # Not case sensitive
file-path: "MyProject/MyProject.csproj"
version-keys: version
trim-start-from-branch: "refs/heads/"Interested in contributing? If so, click here to learn how to contribute your time or here if you are interested in contributing your funds via one-time or recurring donation.
Calvin Wilkinson (KinsonDigital GitHub Organization - Owner)
Kristen Wilkinson (KinsonDigital GitHub Organization - Project Management, Documentation, Tester)
This software is distributed under the very permissive MIT license and all dependencies are distributed under MIT-compatible licenses. This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community.
