Last active
April 6, 2023 08:30
-
-
Save wojtek1150/76b64ad6f41d0bda437ba0edb0d3f20f to your computer and use it in GitHub Desktop.
YML script for cut-off NPM based project to release branch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# YML script for cuffing of npm project to release branch | |
# There are 2 wersions, x.y.z-SNAPSHOT for development and x.y.z for releasing. | |
# Release branch will be created without snapshot postfix | |
before_script: | |
# fetch version to release from package.json snapshot version | |
- export RELEASE_VERSION=$(node -p "require('./package.json').version.replace('-SNAPSHOT','')") | |
# bump next version in pattern X.X+1.0 from RELEASE_VERSION | |
- export NEXT_VERSION=$(perl -pe 's/^(\d+)\.(\d+)\.(\d+)$/"$1.".($2+1).".0"/e' <<< $RELEASE_VERSION) | |
# calculate release branch name by cutting patch level | |
- export RELEASE_BRANCH_NAME=`echo ${RELEASE_VERSION} | sed 's/\([0-9]*\.[0-9]*\)\.[0-9]*/\1/gi'` | |
script: | |
# Optionally check if sentry package is outdated | |
- '[ -z "$(npm outdated @sentry/angular | tee /dev/stderr)" ] || exit 7' | |
- git checkout -b release-${RELEASE_BRANCH_NAME} | |
- git push origin release-${RELEASE_BRANCH_NAME} | |
- git checkout develop | |
# set NEXT_VERSION (snapshot) in package.json and lock file without creating tag | |
- npm version ${NEXT_VERSION}-SNAPSHOT -git-tag-version=false | |
# commit and push | |
- git commit -a -m "New snapshot version ${NEXT_VERSION}" | |
- git push --push-option=ci.skip origin HEAD:${CI_COMMIT_REF_NAME} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment