1 min readOct 25, 2021
Automate build number version change in C# netcore projects
Tired of manually updating your application build version number?
Let’s take a look at how you can use artify (https://pypi.org/project/artify/) to achieve this.
Installing artify, Python 3.6+ required
pip install artify -U
Command structure below:
Installing artify, Python 3.6+ required
python -m artify -c version -t major|minor|patch|prerelease|auto -a netcore|npm|gradle|other
GitLab code snippet
auto-version-update:
stage: updates
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == "develop"'
script:
- python3 -m artify -c version -t auto -a netcore --file=AwesomeApp/AwesomeApp.csproj --debug
- python3 -m artify -c syncrepo -m "Changing version:::Build number" # Ensure that PRIVATE_TOKEN is set in environment variables
tags:
- <runner_machine>
BitBucket code snippet
pipelines:
branches:
develop:
- step:
name: Auto-bump build number
script:
- python3 -m artify -c version -t auto -a netcore
- python3 -m artify -c syncrepo -m "Changing version:::Build number"
GitHub code snippet
jobs:
test:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Auto Bump build version number
run: |
- python -m artify -c version -t auto -a netcore
- python -m artify -c syncrepo -m "Changing version:::Build number" # Ensure that PRIVATE_TOKEN is set in environment variables