Skip to content

Commit 4f13da8

Browse files
authored
ci: add prelease comment trigger (#93)
1 parent 125c5b1 commit 4f13da8

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: release
2+
3+
permissions:
4+
contents: write
5+
6+
on:
7+
issue_comment:
8+
types:
9+
- created
10+
11+
jobs:
12+
release:
13+
if: ${{ github.event.issue.pull_request && github.event.comment.body == 'npm publish' }}
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Install pnpm
21+
uses: pnpm/action-setup@v3
22+
with:
23+
version: 9
24+
25+
- name: Install Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
cache: "pnpm"
30+
registry-url: "https://registry.npmjs.org"
31+
32+
- name: npm version
33+
run: npm version --no-git-tag-version 0.0.0-$(git rev-parse HEAD)
34+
env:
35+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
36+
37+
- name: Install dependencies
38+
run: pnpm install
39+
40+
# publish to npm tag as next
41+
- run: pnpm publish --no-git-checks --tag pre
42+
env:
43+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
44+
45+
- name: "Update comment"
46+
uses: actions/github-script@v7
47+
with:
48+
github-token: ${{ secrets.GITHUB_TOKEN }}
49+
script: |
50+
const { issue: { number: issue_number }, repo: { owner, repo }, payload } = context;
51+
const { name: packageName, version } = require(`${process.env.GITHUB_WORKSPACE}/package.json`);
52+
53+
await github.rest.issues.updateComment({
54+
owner,
55+
repo,
56+
comment_id: payload.comment.id,
57+
body: [
58+
`npm package published to pre tag.`,
59+
`\`\`\`bash\nnpm install ${packageName}@pre\n\`\`\``
60+
`\`\`\`bash\nnpm install ${packageName}@${version}\n\`\`\``
61+
].join('\n\n'),
62+
});

0 commit comments

Comments
 (0)