-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[STRATCONN-3673] - Extract release to a separate job in publish workf…
…low (#1963) This PR makes couple of changes to fix: To avoid using GH PAT token with write access to Github repo, I have moved the release tag computation to thepostversion.sh script. This script will be executed via postversion hook - only for main branch. Extract the release steps to separate job that depends on the build-and-publish job to ensure we don't use GH_PAT token. GH_PAT token contains permissions only to pull data from ctl-plane-js-client.
- Loading branch information
1 parent
16f2353
commit cdab6e3
Showing
4 changed files
with
51 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# This script is executed after the version is bumped by lerna. It generates a release tag. | ||
# The release tag generated will be pushed to the repository by lerna version. | ||
set -e | ||
sha=$(git rev-parse HEAD); | ||
branch=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD); | ||
|
||
if [[ $branch != "main" ]]; | ||
then | ||
echo "Skipping release tag generation for non-main branch" | ||
exit 0 | ||
fi; | ||
|
||
# Generate and push release tag. Release tag format: release-YYYY-MM-DD[.N] e.g. release-2024-01-01 | ||
if ! n=$(git rev-list --count $sha~ --grep "Publish" --since="00:00"); then | ||
echo 'Failed to compute release tag. Exiting.' | ||
exit 1 | ||
else | ||
case "$n" in | ||
0) suffix="" ;; # first commit of the day gets no suffix | ||
*) suffix=".$n" ;; # subsequent commits get a suffix, starting with .1 | ||
esac | ||
|
||
tag=$(printf release-$(date '+%Y-%m-%d%%s') $suffix) | ||
echo "Tagging $sha with $tag" | ||
git tag -a $tag -m "Release $tag" | ||
fi |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
#!/bin/bash | ||
branch=$(git rev-parse --symbolic-full-name --abbrev-ref HEAD); | ||
|
||
if [[ $branch != "main" ]]; | ||
then | ||
echo "You must be on the main branch to release" | ||
exit | ||
fi; | ||
|
||
|
||
git pull --ff-only | ||
echo "Running lerna version minor..." | ||
lerna version minor --no-private -y | ||
lerna version minor --no-private -y |