Skip to content

Commit a471480

Browse files
authored
feat: create a workflow for publishing new versions (#292)
1 parent 29731fe commit a471480

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: release
2+
run-name: "release '${{ github.event.inputs.version }}' version by @${{ github.actor }}"
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: 'Version'
9+
required: true
10+
default: 'patch'
11+
type: choice
12+
options:
13+
- 'major'
14+
- 'minor'
15+
- 'patch'
16+
17+
jobs:
18+
build:
19+
runs-on: ubuntu-latest
20+
permissions:
21+
id-token: write # Enable OIDC
22+
pull-requests: write
23+
contents: write
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- uses: chainguard-dev/actions/setup-gitsign@main
29+
30+
- uses: actions/setup-node@v4
31+
with:
32+
node-version: 20
33+
34+
- name: Cache node_modules
35+
id: cache-node_modules
36+
uses: actions/cache@v4
37+
with:
38+
path: node_modules
39+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
40+
restore-keys: |
41+
${{ runner.os }}-node_modules-
42+
${{ runner.os }}-
43+
44+
- name: Install dependencies
45+
if: steps.cache-node_modules.outputs.cache-hit != 'true'
46+
run: |
47+
npm ci
48+
49+
- name: Setup git
50+
run: |
51+
git config --global tag.gpgsign true
52+
53+
- name: Bump version
54+
run: |
55+
npm version ${{ github.event.inputs.version }} --sign-git-tag
56+
57+
- name: Push changes
58+
env:
59+
GH_TOKEN: ${{ github.token }}
60+
run: |
61+
VERSION=$(node -p "require('./package.json').version")
62+
git push --follow-tags
63+
gh release create $VERSION --generate-notes
64+
65+
- name: Publish to npm
66+
env:
67+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
68+
run: |
69+
npm publish

0 commit comments

Comments
 (0)