55 branches :
66 - master
77 - main
8+ - release
89 paths :
910 - ' package.json'
1011
@@ -24,11 +25,42 @@ jobs:
2425 echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
2526 echo "Extracted version: $VERSION"
2627
28+ - name : Generate release tag and metadata
29+ id : release_info
30+ run : |
31+ VERSION=${{ steps.version.outputs.VERSION }}
32+ COMMIT_HASH=$(git rev-parse --short HEAD)
33+ BRANCH=${{ github.ref_name }}
34+ BUILD_DATE=$(date +'%Y%m%d')
35+
36+ if [[ "$BRANCH" == "release" ]]; then
37+ TAG="v$VERSION"
38+ TITLE="v$VERSION"
39+ NOTES="Release v$VERSION"
40+ IS_PRERELEASE="false"
41+ IS_LATEST="true"
42+ else
43+ TAG="v$VERSION-pre.$BUILD_DATE.$COMMIT_HASH"
44+ TITLE="v$VERSION-pre ($COMMIT_HASH)"
45+ NOTES="Pre-release v$VERSION from branch: $BRANCH"$'\n'"Commit: $COMMIT_HASH"$'\n'"Build Date: $BUILD_DATE"
46+ IS_PRERELEASE="true"
47+ IS_LATEST="false"
48+ fi
49+
50+ echo "TAG=$TAG" >> $GITHUB_OUTPUT
51+ echo "TITLE=$TITLE" >> $GITHUB_OUTPUT
52+ echo "NOTES<<EOF" >> $GITHUB_OUTPUT
53+ echo "$NOTES" >> $GITHUB_OUTPUT
54+ echo "EOF" >> $GITHUB_OUTPUT
55+ echo "IS_PRERELEASE=$IS_PRERELEASE" >> $GITHUB_OUTPUT
56+ echo "IS_LATEST=$IS_LATEST" >> $GITHUB_OUTPUT
57+ echo "Generated tag: $TAG"
58+
2759 - name : Check if release already exists
2860 id : check_release
2961 run : |
30- VERSION =${{ steps.version .outputs.VERSION }}
31- if gh release view "v$VERSION " > /dev/null 2>&1; then
62+ TAG =${{ steps.release_info .outputs.TAG }}
63+ if gh release view "$TAG " > /dev/null 2>&1; then
3264 echo "EXISTS=true" >> $GITHUB_OUTPUT
3365 else
3466 echo "EXISTS=false" >> $GITHUB_OUTPUT
@@ -39,10 +71,23 @@ jobs:
3971 - name : Create Release
4072 if : steps.check_release.outputs.EXISTS == 'false'
4173 run : |
42- VERSION=${{ steps.version.outputs.VERSION }}
43- gh release create "v$VERSION" \
44- --title "v$VERSION" \
45- --notes "Release v$VERSION" \
46- --latest
74+ TAG=${{ steps.release_info.outputs.TAG }}
75+ TITLE=${{ steps.release_info.outputs.TITLE }}
76+ IS_PRERELEASE=${{ steps.release_info.outputs.IS_PRERELEASE }}
77+ IS_LATEST=${{ steps.release_info.outputs.IS_LATEST }}
78+
79+ CREATE_ARGS="--title '$TITLE'"
80+
81+ if [[ "$IS_PRERELEASE" == "true" ]]; then
82+ CREATE_ARGS="$CREATE_ARGS --prerelease"
83+ fi
84+
85+ if [[ "$IS_LATEST" == "true" ]]; then
86+ CREATE_ARGS="$CREATE_ARGS --latest"
87+ fi
88+
89+ gh release create "$TAG" \
90+ $CREATE_ARGS \
91+ --notes "${{ steps.release_info.outputs.NOTES }}"
4792 env :
4893 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments