-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (145 loc) · 4.94 KB
/
Copy pathrelease.yml
File metadata and controls
149 lines (145 loc) · 4.94 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
name: Release Yield
on:
workflow_dispatch:
inputs:
bump:
description: Changeset bump, or an explicit higher bump
type: choice
options: [auto, patch, minor, major]
default: auto
required: true
dry_run:
description: Resolve and verify without tagging or publishing
type: boolean
default: false
required: true
notes_source:
description: Source for the immutable GitHub release notes
type: choice
options: [changesets, git-history]
default: changesets
required: true
permissions:
contents: read
concurrency:
group: release-yield
cancel-in-progress: false
jobs:
plan:
if: github.repository == 'operatorstack/yield'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.plan.outputs.version }}
tag: ${{ steps.plan.outputs.tag }}
source_sha: ${{ steps.plan.outputs.source_sha }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: "24"
cache: npm
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7
with:
go-version-file: go.mod
cache: true
- name: Bind dispatch to protected main
shell: bash
run: |
set -euo pipefail
test "$GITHUB_REF" = refs/heads/main
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
test "$(git rev-parse origin/main)" = "$GITHUB_SHA"
- run: npm ci --ignore-scripts
- name: Verify release controller and source
run: |
npm run test:release
node scripts/check-release-control.mjs
go test ./...
go build ./...
- id: plan
name: Resolve immutable release intent
env:
REQUESTED_BUMP: ${{ inputs.bump }}
NOTES_SOURCE: ${{ inputs.notes_source }}
run: >-
node scripts/release-plan.mjs
--bump "$REQUESTED_BUMP"
--notes-source "$NOTES_SOURCE"
--output "$GITHUB_OUTPUT"
--notes "$RUNNER_TEMP/release-notes.md"
- name: Report dry run
if: inputs.dry_run
env:
TAG: ${{ steps.plan.outputs.tag }}
VERSION: ${{ steps.plan.outputs.version }}
run: |
echo "### Dry run: $TAG" >> "$GITHUB_STEP_SUMMARY"
echo "Version: $VERSION" >> "$GITHUB_STEP_SUMMARY"
cat "$RUNNER_TEMP/release-notes.md" >> "$GITHUB_STEP_SUMMARY"
release:
needs: plan
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
environment: release-control
permissions:
actions: write
contents: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ needs.plan.outputs.source_sha }}
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6
with:
node-version: "24"
cache: npm
- run: npm ci --ignore-scripts
- id: confirm
name: Recompute release intent after approval
env:
REQUESTED_BUMP: ${{ inputs.bump }}
NOTES_SOURCE: ${{ inputs.notes_source }}
run: >-
node scripts/release-plan.mjs
--bump "$REQUESTED_BUMP"
--notes-source "$NOTES_SOURCE"
--output "$GITHUB_OUTPUT"
--notes "$RUNNER_TEMP/release-notes.md"
- name: Refuse plan drift
env:
EXPECTED_TAG: ${{ needs.plan.outputs.tag }}
EXPECTED_VERSION: ${{ needs.plan.outputs.version }}
ACTUAL_TAG: ${{ steps.confirm.outputs.tag }}
ACTUAL_VERSION: ${{ steps.confirm.outputs.version }}
run: |
test "$ACTUAL_TAG" = "$EXPECTED_TAG"
test "$ACTUAL_VERSION" = "$EXPECTED_VERSION"
- name: Create immutable tag and draft release
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ steps.confirm.outputs.tag }}
shell: bash
run: |
set -euo pipefail
if git ls-remote --exit-code --tags origin "refs/tags/$TAG" >/dev/null 2>&1; then
echo "Tag $TAG already exists" >&2
exit 1
fi
gh api --method POST "repos/$GITHUB_REPOSITORY/git/refs" \
-f ref="refs/tags/$TAG" \
-f sha="$GITHUB_SHA"
gh release create "$TAG" \
--repo "$GITHUB_REPOSITORY" \
--title "$TAG" \
--notes-file "$RUNNER_TEMP/release-notes.md" \
--draft \
--verify-tag
- name: Dispatch the protected package publisher
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.confirm.outputs.version }}
run: gh workflow run npm-publish.yml --repo "$GITHUB_REPOSITORY" --ref main -f version="$VERSION"