Skip to content
Snippets Groups Projects

Resolve "Automatically tag and publish on version change"

Merged Jacek Lebioda requested to merge 43-automatically-tag-and-publish-on-version-change into latest
1 file
+ 8
7
Compare changes
  • Side-by-side
  • Inline
+ 8
7
@@ -42,22 +42,23 @@ auto-tag:
variables:
VERSION_FILE: "lib/jekyll-theme-lcsb-default.rb"
TARGET_BRANCH: latest
only:
changes:
- "lib/jekyll-theme-lcsb-default.rb"
script:
# Make sure that it is on latest, otherwise exit
# Make sure that it is on latest, otherwise exit. THIS IS A WORKAROUND, AS HAVING BOTH ONLY AND RULES IS NOT POSSIBLE
- '[[ "${CI_COMMIT_BRANCH:-1}" == "$TARGET_BRANCH" ]] && echo "On correct branch ($CI_COMMIT_BRANCH)" || exit 0'
# Make sure that the version exists
- VERSION=$(cat $VERSION_FILE | grep -o "\d\.\d\.\d")
# Make sure that the version exists and is correct, and put it in envvar
- cat $VERSION_FILE | grep "VERSION" | tr -d A-z\"\= | tr -d ' '
- VERSION=`cat $VERSION_FILE | grep "VERSION" | tr -d A-z\"\= | tr -d ' '`
- '[[ -z $VERSION ]] && exit -1 || echo "OK, version appears to be correct -> $VERSION"'
# Create the tag
- git tag -a $VERSION
- git tag -a $VERSION -m $VERSION
# Publish the tag
- git push origin $VERSION
only:
changes:
- "lib/jekyll-theme-lcsb-default.rb"
# This will push the gem to ruby-gems when the repository has been tagged
release:
Loading