@@ -4,16 +4,28 @@ set -euxo pipefail
44VERSION=$( jq -r .version package.json)
55MAJOR_VERSION=$( echo " $VERSION " | cut -d. -f1)
66
7- # create the version tag
8- git tag " v$VERSION "
7+ # create the version tag (allow it to fail if it already exists)
8+ git tag " v$VERSION " || echo " Tag v $VERSION already exists locally "
99
1010# push changes to github
1111git push
1212# push the current tag to github
13- git push origin " v$VERSION "
13+ git push origin " v$VERSION " || echo " Tag v$VERSION already exists on remote"
14+
1415# set the major version tag to this release
1516git tag " v$MAJOR_VERSION " -f
16- # push the major version tag to github
17- git push origin " v$MAJOR_VERSION " -f
18- # create a release on github
19- gh release create " v$VERSION " --generate-notes --verify-tag
17+ # push the major version tag to github (retry with pull if it fails)
18+ if ! git push origin " v$MAJOR_VERSION " -f; then
19+ echo " Failed to push v$MAJOR_VERSION tag, pulling and retrying..."
20+ git fetch origin " refs/tags/v$MAJOR_VERSION :refs/tags/v$MAJOR_VERSION " -f
21+ git tag " v$MAJOR_VERSION " -f
22+ git push origin " v$MAJOR_VERSION " -f
23+ fi
24+
25+ # check if release already exists before creating
26+ if gh release view " v$VERSION " > /dev/null 2>&1 ; then
27+ echo " Release v$VERSION already exists, skipping creation"
28+ else
29+ # create a release on github
30+ gh release create " v$VERSION " --generate-notes --verify-tag
31+ fi
0 commit comments