Repository navigation
81 lines (74 loc) · 3.56 KB
/
Copy pathrelease.yml
File metadata and controls
81 lines (74 loc) · 3.56 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
name: Release
on:
workflow_run:
workflows: ["CI"]
types:
- completed
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
jobs:
release:
name: Release
runs-on: ubuntu-latest
# `branches: [main]` above filters on the triggering run's HEAD branch, so a
# fork PR from a branch named `main` passes it. Only a push to this repo's
# own main may release: a `pull_request` CI run (fork or not) never does.
if: >-
${{
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_repository.full_name == github.repository
}}
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# The exact commit the green CI run measured, never the branch tip: a
# `workflow_run` checkout otherwise takes the default branch's CURRENT
# tip, which a push landing after CI went green can have moved.
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
# PAT so the git remote is configured with PAT credentials; the bare
# GITHUB_TOKEN push checkout normally sets up is treated as a bot
# event and would not fire `pull_request` workflows on the resulting
# branch — defeating the point of a PAT release.
token: ${{ secrets.RELEASE_PAT }}
- name: Setup
uses: ./.github/actions/setup
- name: Create Release Pull Request or Publish to npm
id: changesets
# v2, not v1: v1 bundles `@changesets/read@^0.6.7`, which parses EVERY
# `.changeset/*.md` as a changeset and fails the whole release on a
# repository that keeps `.changeset/CLAUDE.md` beside its changesets.
# `@changesets/read@1.0.0` — v2's — ignores `README.md`, `AGENTS.md`,
# `CLAUDE.md` and `GEMINI.md`. v2 also renamed every input.
uses: changesets/action@ae32849d5ba541f9ae29e40e22a623bc13562f51 # v2.1.2
with:
# An INPUT now: v2 defaults `github-token` to `${{ github.token }}`,
# so passing the PAT only through the environment below would
# silently fall back to the bot token, and a release PR opened by it
# starts no workflow runs — the exact thing the PAT prevents.
github-token: ${{ secrets.RELEASE_PAT }}
# Use `pnpm run …` so we invoke the package.json scripts. Bare
# `pnpm version` collides with pnpm's built-in `version` command.
version-script: pnpm run version
publish-script: pnpm run release
commit-message: "chore: release packages"
pr-title: "chore: release packages"
env:
# PAT rather than GITHUB_TOKEN: events triggered by GITHUB_TOKEN do
# not start new workflow runs (anti-recursion safeguard), so the
# "Version Packages" PR would otherwise skip CI. Required repo secret:
# RELEASE_PAT (classic PAT with `repo`, or fine-grained with
# Contents + Pull requests read/write on this repo).
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}
# NPM_TOKEN intentionally absent — npm Trusted Publishing uses the
# OIDC token minted via `id-token: write`. Each package must have a
# Trusted Publisher configured on npmjs.com pointing at this repo +
# workflow file (.github/workflows/release.yml).