Skip to content

Commit b44271f

Browse files
committed
ci: update create-release-on-github workflow (#1102)
1 parent 9eeac92 commit b44271f

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

.github/workflows/create-release-on-github.yml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
- main
99
- rel/**
1010

11+
permissions:
12+
id-token: write # Required for OIDC
13+
contents: read
14+
1115
jobs:
1216
publish-to-npm:
1317
runs-on: ubuntu-latest
@@ -28,6 +32,7 @@ jobs:
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
@@ -44,9 +49,6 @@ jobs:
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

.github/workflows/create-release-pr.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ jobs:
269269
title: pr.title.trim()
270270
}));
271271
272-
// Categorize PRs
272+
// Categorize PRs (exclude internal changes like ci/chore)
273273
const features = prs.filter(pr => /^feat/i.test(pr.title));
274274
const fixes = prs.filter(pr => /^fix/i.test(pr.title));
275-
const improvements = prs.filter(pr => /^(perf|refactor|chore)/i.test(pr.title));
275+
const improvements = prs.filter(pr => /^(perf|refactor)/i.test(pr.title));
276276
277277
// Helper function to build section
278278
const buildSection = (title, prs) => {

0 commit comments

Comments
 (0)