@@ -22,12 +22,54 @@ jobs:
22
22
runs-on : ubuntu-latest
23
23
steps :
24
24
- uses : actions/checkout@v4
25
+ with :
26
+ fetch-depth : 0 # Fetch all history for PR message extraction
27
+
25
28
- uses : actions/setup-node@v4
26
29
with :
27
30
node-version : ' latest'
31
+
32
+ - name : Get PR Message
33
+ id : pr_message
34
+ run : |
35
+ PR_NUMBER=$(git log -1 --pretty=%B | grep -oP '#\K\d+' || echo "")
36
+ if [ ! -z "$PR_NUMBER" ]; then
37
+ PR_MESSAGE=$(gh pr view $PR_NUMBER --json body -q .body || echo "")
38
+ echo "message<<EOF" >> $GITHUB_OUTPUT
39
+ echo "$PR_MESSAGE" >> $GITHUB_OUTPUT
40
+ echo "EOF" >> $GITHUB_OUTPUT
41
+ else
42
+ echo "message=No PR message found" >> $GITHUB_OUTPUT
43
+ fi
44
+ env :
45
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
46
+
28
47
- run : npm ci
29
48
- run : npm install -g tsx
30
- - run : npm run build # Add build step here too
31
- - uses : JS-DevTools/npm-publish@v3
49
+ - run : npm run build
50
+
51
+ - name : Publish to NPM
52
+ id : publish
53
+ uses : JS-DevTools/npm-publish@v3
54
+ with :
55
+ token : ${{ secrets.NPM_TOKEN }}
56
+
57
+ - name : Get package version
58
+ if : steps.publish.outputs.type != 'none'
59
+ id : package_version
60
+ run : echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
61
+
62
+ - name : Create GitHub Release
63
+ if : steps.publish.outputs.type != 'none'
64
+ uses : actions/create-release@v1
65
+ env :
66
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
32
67
with :
33
- token : ${{ secrets.NPM_TOKEN }}
68
+ tag_name : v${{ steps.package_version.outputs.version }}
69
+ release_name : Release v${{ steps.package_version.outputs.version }}
70
+ body : |
71
+ ${{ steps.pr_message.outputs.message }}
72
+
73
+ Package published to npm: ${{ steps.publish.outputs.version }}
74
+ draft : false
75
+ prerelease : false
0 commit comments