Ben Oram

Quick notes on tech, AWS, .NET & containers

on Using Minver to generate a version number in Github Actions #github-actions

MinVer is a tool that you can use to generate a version number that is based on your git repository history.

The tool does require .NET, but there is no requirement that you develop your app in .NET

Within your GitHub Action workflow, you can run MinVer to generate the version number and store it in an environment variable for later use.

GitHub checkout and set fetch depth appropriately

- uses: actions/checkout@v2
    fetch-depth: 0

Retrieve version and store in env

- name: Set APP_VERSION based on repo w/MinVer
   run: |
    dotnet tool install -g minver-cli -v q
    echo "Adding version to GITHUB_ENV: APP_VERSION=$APP_VERSION"

Example: Reference the variable in later steps

- name: Publish artifact to GitHub
  uses: softprops/action-gh-release@v1
    tag_name: ${{ env.APP_VERSION }}
    GITHUB_TOKEN: ${{ github.token }}


Thanks for reading! If you found my content useful, spread the word!