Update Versioning authored by Klaas Kliffen's avatar Klaas Kliffen
......@@ -25,6 +25,9 @@ git tag v1.0.2 # or any version you'd like
# additionally you can also add a message, similar to commit messages (note both `-a` and `-m` are necessary
git tag -a v1.0.2 -m "Patch release v1.0.2"
# Push including tags
git push --tags # alternatively, use git push --all)
```
### Python Package
......@@ -73,5 +76,46 @@ except metadata.PackageNotFoundError:
__version__ = "Unknown"
```
### Using release branches
Sometimes it is more convenient to use a branch (this enables you to have a stable reference for a version):
An example can be found in the [LINC](https://git.astron.nl/RD/LINC) repository where it additionally updates some files with a fixed version of a container image in the release step.
**IMPORTANT**: when making a tag/commit in CI, please add `[SKIP CI]` to prevent circular triggering of pipelines from pipelines.
```yaml
# .gitlab-ci.yml
# Deploy a release version
deploy_release:
stage: deploy
needs: ["versioning", "download_data"]
image: docker:20.10
services:
- docker:20.10-dind
before_script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
- echo $DH_REGISTRY_PASSWORD | docker login -u $DH_REGISTRY_USER --password-stdin
- apk update && apk add git
- git config user.email $GITLAB_USER_EMAIL
- git config user.name $GITLAB_USER_NAME
script:
- echo -n "$CI_COMMIT_BRANCH" | sed -e "s/^releases\//export RELEASE=/" > version && source version
- docker tag $INTEGRATION_IMAGE astronrd/linc:$RELEASE
- docker push astronrd/linc:$RELEASE
# Update docker image in cwl steps by tagged version
- sed -i "s/astronrd\/linc/astronrd\/linc:$RELEASE/g" steps/*.cwl
# Create and push Git tag
- git add steps/*.cwl
# Skip CI on this commit and tag
- git commit -m "[SKIP CI] Replace latest with tag $RELEASE"
- git tag -a $RELEASE -m "[SKIP CI] Version $RELEASE created by gitlab-ci build"
- git push --all
rules:
# Only run on release branches
- if: '$CI_COMMIT_BRANCH =~ /^releases//'
when: always
```
## License
The [Semantic Versioning specification](https://semver.org/) was originally authored by Tom Preston-Werner and is licensed under [Creative Commons -- CC BY 3.0](https://creativecommons.org/licenses/by/3.0/)
\ No newline at end of file