-
-
Notifications
You must be signed in to change notification settings - Fork 0
165 lines (147 loc) · 5.91 KB
/
Copy pathrelease.yml
File metadata and controls
165 lines (147 loc) · 5.91 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Release
# Two release modes through this single workflow file:
#
# 1. Regular release (push to main): runs changesets/action, which either
# opens a "chore: release" PR with version bumps from queued changesets,
# or publishes the bumped versions to npm if the release PR has been
# merged.
#
# 2. Snapshot release (workflow_dispatch): publishes a one-off version under
# the `snapshot` dist-tag, so changes can be previewed without entering
# changesets pre-release mode.
#
# Both modes go through this single workflow file because npm Trusted
# Publishers (OIDC) bind publish authorization to one specific workflow
# filename per package. Renaming this file will break publishing until each
# package's npm-side trusted-publisher record is updated to match.
#
# Configure a Trusted Publisher for each released package on npmjs.com:
# https://www.npmjs.com/package/<package>/access -> Trusted Publisher
# Repository: creatornader/atrib
# Workflow: release.yml
#
# `commitMode: github-api` on changesets/action makes the release commit go
# through the GitHub REST API so it's auto-signed by GitHub. No GPG/SSH key
# wrangling, no commit-signature-rule exceptions.
#
# Node 24+ is required: Node 22's bundled npm 10.x can sign provenance
# attestations but cannot use OIDC tokens to authenticate the publish itself,
# leading to a 404 after provenance signing succeeds. Node 24 ships npm 11.12+
# which fixes this.
#
# Provenance attestations (`NPM_CONFIG_PROVENANCE: "true"`) are set on both
# the release + snapshot jobs. Sigstore publishes a transparency-log entry
# per published version; the npmjs.com package page shows a "Provenance"
# section with sigstore.dev verification links.
#
# Security note: this workflow does NOT interpolate any user-controlled
# github.event.* fields into run: commands, per the GitHub Actions
# script-injection guidance.
#
# See https://docs.npmjs.com/trusted-publishers for the npm-side docs.
on:
push:
branches:
- main
workflow_dispatch:
concurrency: ${{ github.workflow }}-${{ github.ref }}
# Default to read-only at the workflow level; each job grants only the writes
# it needs (`contents: write`, `pull-requests: write`, `id-token: write`).
permissions:
contents: read
# Opt into Node.js 24 for transitive JS actions (see ci.yml for rationale).
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
release:
if: github.event_name == 'push'
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
id-token: write
steps:
# Mint a GitHub App installation token to use in place of the default
# GITHUB_TOKEN. Required because GitHub's anti-loop policy blocks
# workflows triggered by GITHUB_TOKEN pushes from firing other
# workflows (push / pull_request events). The changesets-bot's
# Version Packages PR is opened with GITHUB_TOKEN by default, which
# means the required test + security-scan checks never run on it
# until someone closes + reopens the PR to retrigger them. App
# installation tokens are a non-GITHUB_TOKEN identity, so their
# pushes DO trigger downstream workflows.
#
# App: atrib-release-bot (https://github.com/settings/apps)
# Permissions: contents:write, pull-requests:write
# Installed on: creatornader/atrib only
# Secrets:
# RELEASE_APP_ID - the App's Client ID (the "Iv23li..."
# string shown on the App settings page).
# The secret name is historical; this workflow
# passes it as `client-id`.
# RELEASE_APP_PRIVATE_KEY - the PEM contents (multiline)
- name: Mint GitHub App installation token
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v7
with:
token: ${{ steps.app-token.outputs.token }}
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: "24"
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create release PR or publish to npm
id: changesets
uses: changesets/action@a45c4d594aa4e2c509dc14a9f2b3b67ba3780d0d # v1.9.0
with:
publish: pnpm release
version: pnpm version-packages
commitMode: github-api
# Per D060: per-package GitHub Release per version bump alongside the
# npm publish. Tags + release notes auto-derived from each package's
# CHANGELOG.md entry by changesets/action.
createGithubReleases: true
env:
NPM_CONFIG_PROVENANCE: "true"
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
snapshot:
if: github.event_name == 'workflow_dispatch'
name: Release snapshot
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v7
with:
token: ${{ github.token }}
- name: Setup pnpm
uses: pnpm/action-setup@v6
- name: Setup Node
uses: actions/setup-node@v7
with:
node-version: "24"
cache: "pnpm"
registry-url: "https://registry.npmjs.org"
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm -r build
- name: Snapshot version
run: pnpm changeset version --snapshot snapshot
- name: Publish snapshot
run: pnpm changeset publish --tag snapshot --no-git-tag
env:
NPM_CONFIG_PROVENANCE: "true"