-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (57 loc) · 1.9 KB
/
release.yml
File metadata and controls
70 lines (57 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
id-token: write # required for npm provenance
jobs:
release:
name: Build, test, and publish to npm
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- uses: actions/setup-node@v4
with:
node-version: 20
cache: pnpm
registry-url: "https://registry.npmjs.org/"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm build
- name: Lint
run: pnpm lint
- name: Test
run: pnpm test
- name: Resolve version
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Verify package.json matches tag
env:
EXPECTED: ${{ steps.version.outputs.version }}
run: |
set -euo pipefail
pkg=$(node -p "require('./package.json').version")
echo "tag=$EXPECTED package.json=$pkg"
if [ "$pkg" != "$EXPECTED" ]; then
echo "::error::package.json version ($pkg) does not match tag ($EXPECTED). Run 'pnpm release' instead of tagging manually."
exit 1
fi
- name: Publish to npm
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: npm publish --access public --provenance
- name: Create GitHub Release
# Pinned to commit SHA of v2.6.2 (third-party action with contents: write).
# Update by resolving the desired tag with:
# gh api repos/softprops/action-gh-release/git/refs/tags/<tag> --jq .object.sha
uses: softprops/action-gh-release@3bb12739c298aeb8a4eeaf626c5b8d85266b0e65 # v2.6.2
with:
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref_name, '-') }}