Skip to content

Commit 92bf1c4

Browse files
author
Deepak Kumar
committed
Update publish workflow to support prerelease tagging and GitHub release creation with changelog link
1 parent ad83660 commit 92bf1c4

1 file changed

Lines changed: 26 additions & 10 deletions

File tree

.github/workflows/publish.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77

88
permissions:
99
id-token: write # Required for OIDC
10-
contents: read
10+
contents: write
1111

1212
jobs:
1313
publish:
@@ -26,12 +26,28 @@ jobs:
2626

2727
- name: Extract tag name
2828
id: tag
29-
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
30-
31-
- name: Publish with beta tag
32-
if: contains(steps.tag.outputs.TAG_NAME, 'beta')
33-
run: npm publish --tag beta
34-
35-
- name: Publish with latest tag
36-
if: "!contains(steps.tag.outputs.TAG_NAME, 'beta')"
37-
run: npm publish
29+
run: |
30+
TAG_NAME=${GITHUB_REF#refs/tags/}
31+
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
32+
if [[ $TAG_NAME =~ (alpha|beta|rc) ]]; then
33+
echo "IS_PRERELEASE=true" >> $GITHUB_OUTPUT
34+
# Extract the keyword (alpha, beta, or rc) to use as npm tag
35+
if [[ $TAG_NAME =~ alpha ]]; then echo "NPM_TAG=alpha" >> $GITHUB_OUTPUT; fi
36+
if [[ $TAG_NAME =~ beta ]]; then echo "NPM_TAG=beta" >> $GITHUB_OUTPUT; fi
37+
if [[ $TAG_NAME =~ rc ]]; then echo "NPM_TAG=rc" >> $GITHUB_OUTPUT; fi
38+
else
39+
echo "IS_PRERELEASE=false" >> $GITHUB_OUTPUT
40+
echo "NPM_TAG=latest" >> $GITHUB_OUTPUT
41+
fi
42+
43+
- name: Publish to NPM
44+
run: npm publish --tag ${{ steps.tag.outputs.NPM_TAG }}
45+
env:
46+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
47+
48+
- name: Create GitHub Release
49+
uses: softprops/action-gh-release@v2
50+
with:
51+
prerelease: ${{ steps.tag.outputs.IS_PRERELEASE == 'true' }}
52+
body: |
53+
Please refer to [Change-log.md](https://github.com/${{ github.repository }}/blob/main/Change-log.md) for release notes.

0 commit comments

Comments
 (0)