-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add prelease comment trigger (#93)
- Loading branch information
1 parent
125c5b1
commit 4f13da8
Showing
1 changed file
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
name: release | ||
|
||
permissions: | ||
contents: write | ||
|
||
on: | ||
issue_comment: | ||
types: | ||
- created | ||
|
||
jobs: | ||
release: | ||
if: ${{ github.event.issue.pull_request && github.event.comment.body == 'npm publish' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/action-setup@v3 | ||
with: | ||
version: 9 | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
cache: "pnpm" | ||
registry-url: "https://registry.npmjs.org" | ||
|
||
- name: npm version | ||
run: npm version --no-git-tag-version 0.0.0-$(git rev-parse HEAD) | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
# publish to npm tag as next | ||
- run: pnpm publish --no-git-checks --tag pre | ||
env: | ||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: "Update comment" | ||
uses: actions/github-script@v7 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const { issue: { number: issue_number }, repo: { owner, repo }, payload } = context; | ||
const { name: packageName, version } = require(`${process.env.GITHUB_WORKSPACE}/package.json`); | ||
await github.rest.issues.updateComment({ | ||
owner, | ||
repo, | ||
comment_id: payload.comment.id, | ||
body: [ | ||
`npm package published to pre tag.`, | ||
`\`\`\`bash\nnpm install ${packageName}@pre\n\`\`\`` | ||
`\`\`\`bash\nnpm install ${packageName}@${version}\n\`\`\`` | ||
].join('\n\n'), | ||
}); |