Repository navigation
80 lines (70 loc) · 2.54 KB
/
Copy pathrelease.yml
File metadata and controls
80 lines (70 loc) · 2.54 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
71
72
73
74
75
76
77
78
79
80
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Version bump type"
required: true
type: choice
options:
- patch
- minor
- major
jobs:
ci:
name: Test + build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
- run: bun install --frozen-lockfile
- run: bun run typecheck
- run: bun test
- run: bun run build
release:
name: Publish to npm
needs: ci
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write # Required for npm trusted publishing + provenance
steps:
- uses: actions/checkout@v5
- uses: oven-sh/setup-bun@v2
- uses: actions/setup-node@v5
with:
# npm trusted publishing needs npm 11.5.1+; node 24 ships a
# recent enough version.
node-version: "24"
registry-url: "https://registry.npmjs.org"
# --frozen-lockfile prevents bun from mutating bun.lock during the
# release job. A drifted lockfile would otherwise dirty the working
# tree and make `npm version` abort with "Git working directory not
# clean". The ci job above will catch the drift first with a clearer
# error.
- run: bun install --frozen-lockfile
- name: Configure git
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# `npm version <bump>` invokes our `version` script (which runs
# scripts/sync-version.ts to keep the README in lockstep), then
# creates a commit + tag.
- name: Bump version
run: 'npm version ${{ inputs.version }} -m "chore: release v%s"'
- name: Push changes
run: git push --follow-tags
# Trusted publishing: no NODE_AUTH_TOKEN. npm exchanges the GitHub
# OIDC token (granted via id-token: write above) for a scoped
# publish credential. Requires the package to already exist on
# npm and the trusted publisher to be configured for this repo +
# workflow file + environment name.
#
# `--provenance` attaches a signed attestation linking the tarball
# to this exact workflow run; appears as a badge on the npm page.
#
# `prepublishOnly` (in package.json) runs `bun run build` so the
# dist/ directory is freshly built from the bumped version.
- name: Publish to npm
run: npm publish --access public --provenance