-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (93 loc) · 4.19 KB
/
Copy pathrelease.yml
File metadata and controls
104 lines (93 loc) · 4.19 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
name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write # create the GitHub release + upload archives
jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # goreleaser needs full history for the changelog
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
# A flake building `src = self` has no git tag to read, so flake.nix
# carries the version as a literal. Fail the release rather than ship a
# binary that reports the wrong version to nix users.
- name: flake.nix version matches the tag
run: |
tag="${GITHUB_REF_NAME#v}"
flake=$(sed -n 's/^ *version = "\(.*\)";$/\1/p' flake.nix)
if [ "$tag" != "$flake" ]; then
echo "::error::tag $tag does not match flake.nix version $flake"
exit 1
fi
- uses: goreleaser/goreleaser-action@v6
with:
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Needed only for the Homebrew cask push. Create a `homebrew-tap` repo
# and a PAT with `repo` scope on it, saved as this secret. Without it,
# add `--skip=homebrew` to args above to release binaries only.
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
# Publishes @sanketsudake/chrome-cdp via TRUSTED PUBLISHING (OIDC): npm
# verifies this workflow's GitHub identity instead of accepting a long-lived
# token. That needs a one-time setup on npmjs.com — package Settings ->
# Trusted Publisher, all fields case-sensitive and exact:
#
# Organization or user: sanketsudake
# Repository: chrome-cdp-cli
# Workflow filename: release.yml (filename only, no path)
# Allowed actions: npm publish
#
# Renaming this file, the repo, or the owner breaks publishing until the
# trusted publisher is updated to match.
#
# Why bother: npm is retiring 2FA-bypass granular access tokens for direct
# publishing (phase 2, ~January 2027), and OIDC removes the standing
# publish credential from the repo altogether.
npm:
needs: goreleaser
runs-on: ubuntu-latest
# Gated on a repository variable so a fork — which cannot satisfy this
# package's trusted publisher — skips the publish instead of failing the
# whole release. Set the NPM_PUBLISH repository variable to "true" to arm
# it.
if: vars.NPM_PUBLISH == 'true'
permissions:
contents: read
# Required for OIDC: this is what lets npm verify the workflow identity.
id-token: write
steps:
- uses: actions/checkout@v4
# Trusted publishing needs Node >= 22.14.0 AND npm >= 11.5.1. Node 24
# satisfies the runtime floor, but the bundled npm varies by patch
# release, so the CLI is pinned explicitly below rather than assumed:
# an npm too old to speak OIDC looks for a token instead, and with no
# token configured that surfaces as an authentication failure rather
# than anything that names the real cause.
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- name: Ensure an npm that supports trusted publishing
run: |
npm install -g npm@^11.5.1
echo "npm $(npm --version) / node $(node --version)"
# No NODE_AUTH_TOKEN: the NPM_TOKEN secret is deleted and OIDC is the
# only authentication path. That is the point of trusted publishing —
# the repo holds no standing publish credential — and it means a
# misconfigured trusted publisher fails the publish outright instead of
# quietly falling back to a token, which is the louder of the two
# failure modes and the one we want.
#
# --provenance is redundant under trusted publishing (attestations are
# generated automatically) and kept only because it states the intent
# at the call site; dropping it would not change what is published.
- run: cd npm && npm version "${GITHUB_REF_NAME#v}" --no-git-tag-version && npm test && npm publish --provenance --access public