88 - main
99 - rel/**
1010
11+ permissions :
12+ id-token : write # Required for OIDC
13+ contents : read
14+
1115jobs :
1216 publish-to-npm :
1317 runs-on : ubuntu-latest
2832 uses : oven-sh/setup-bun@v2
2933 with :
3034 bun-version : latest
35+ registry-url : ' https://registry.npmjs.org'
3136
3237 - name : Install
3338 run : bun install --frozen-lockfile
4449 fi
4550 echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
4651
47- - name : Configure NPM authentication
48- run : echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
49-
5052 - name : Build & Publish
5153 run : |
5254 bun run build
@@ -59,17 +61,37 @@ jobs:
5961 else
6062 bun publish
6163 fi
62- env :
63- NPM_CONFIG_TOKEN : ${{ secrets.NPM_TOKEN }}
6464
6565 - name : Create release notes
6666 uses : actions/github-script@v8
6767 id : release_notes
6868 with :
6969 script : |
70- // Use the PR that triggered this workflow
71- const releasePr = context.payload.pull_request;
72- const releaseNotes = releasePr.body.split('<!--')[0].trim();
70+ let releaseNotes = '';
71+
72+ if (context.payload.pull_request) {
73+ // PR triggered: use PR body
74+ const releasePr = context.payload.pull_request;
75+ releaseNotes = releasePr.body.split('<!--')[0].trim();
76+ } else {
77+ // Workflow dispatch: find latest merged "chore: Release" PR
78+ const prs = await github.rest.pulls.list({
79+ owner: context.repo.owner,
80+ repo: context.repo.repo,
81+ state: 'closed',
82+ sort: 'updated',
83+ direction: 'desc',
84+ per_page: 50
85+ });
86+
87+ const releasePr = prs.data.find(pr =>
88+ pr.merged_at && pr.title.includes('chore: Release')
89+ );
90+
91+ if (releasePr) {
92+ releaseNotes = releasePr.body.split('<!--')[0].trim();
93+ }
94+ }
7395 core.setOutput('notes', releaseNotes);
7496
7597 - name : Create GitHub Release
0 commit comments