Skip to content

Commit 4275054

Browse files
authored
Merge pull request #1005 from pubkey/copilot/add-release-script
Add npm release workflow
2 parents 4e96883 + 4b2604f commit 4275054

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'New Version (e.g. 1.0.0, or leave empty for patch)'
8+
required: false
9+
type: string
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-24.04
14+
# @link https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs
15+
permissions:
16+
contents: write
17+
# @link https://docs.npmjs.com/generating-provenance-statements#about-npm-provenance
18+
id-token: write
19+
steps:
20+
- uses: actions/checkout@v4
21+
- uses: actions/setup-node@v4
22+
with:
23+
node-version-file: '.nvmrc'
24+
registry-url: 'https://registry.npmjs.org'
25+
26+
- run: npm install
27+
- name: Bump Version
28+
id: bump
29+
run: |
30+
if [ -z "${{ inputs.version }}" ]; then
31+
npm version patch --no-git-tag-version > /dev/null
32+
else
33+
npm version ${{ inputs.version }} --no-git-tag-version > /dev/null
34+
fi
35+
echo "version=v$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
36+
- run: npm run build
37+
- run: npm run lint
38+
- run: npm run test:node
39+
- run: npm publish
40+
env:
41+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42+
43+
- name: Push changes
44+
run: |
45+
git config --global user.name 'github-actions[bot]'
46+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
47+
git add package.json
48+
git commit -m "release: ${{ steps.bump.outputs.version }}"
49+
git push

0 commit comments

Comments
 (0)