-
Notifications
You must be signed in to change notification settings - Fork 1
182 lines (161 loc) · 5.74 KB
/
Copy pathrelease.yml
File metadata and controls
182 lines (161 loc) · 5.74 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
name: Release
# Release flow (see docs/guide/): release-please maintains a release PR on
# main; merging it creates the tag + GitHub Release, then this same workflow
# builds the SEA binaries for every platform, attaches them to the release,
# and publishes the npm packages (wrapper + per-platform binaries).
#
# Everything is chained inside ONE workflow on purpose: tags created with the
# default GITHUB_TOKEN do not trigger other workflows, so a separate
# `on: push: tags` build would never fire.
#
# workflow_dispatch covers the bootstrap and recovery paths: given an
# EXISTING release tag (e.g. the hand-made v0.1.0 launch release), it
# rebuilds the binaries and re-publishes the assets for that tag.
on:
push:
branches: [main]
workflow_dispatch:
inputs:
tag:
description: 'Existing release tag to build and publish (e.g. v0.1.0)'
required: true
type: string
concurrency:
group: release-${{ github.event_name == 'workflow_dispatch' && inputs.tag || github.ref }}
cancel-in-progress: false
permissions: {}
jobs:
release-please:
name: Release PR / tag
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
outputs:
release_created: ${{ steps.rp.outputs.release_created }}
tag_name: ${{ steps.rp.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@v5
id: rp
build:
name: Build ${{ matrix.artifact }}
needs: [release-please]
# `!cancelled()` lets this run when release-please is skipped
# (workflow_dispatch); the second clause gates the push path on an
# actual release having been cut.
if: >-
${{ !cancelled() && (
github.event_name == 'workflow_dispatch' ||
needs.release-please.outputs.release_created == 'true'
) }}
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-latest
artifact: coderadius_linux_amd64
- runner: ubuntu-24.04-arm
artifact: coderadius_linux_arm64
- runner: macos-15-intel
artifact: coderadius_darwin_amd64
- runner: macos-latest
artifact: coderadius_darwin_arm64
runs-on: ${{ matrix.runner }}
permissions:
contents: read
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || needs.release-please.outputs.tag_name }}
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: actions/setup-node@v6
with:
node-version: 22
- name: Install dependencies
run: bun install
- name: Build SEA release tarball
run: make release
- name: Generate checksums
run: |
cd release
for f in *.tar.gz; do
(sha256sum "$f" 2>/dev/null || shasum -a 256 "$f") > "$f.sha256"
done
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.artifact }}
path: |
release/*.tar.gz
release/*.sha256
if-no-files-found: error
publish-github:
name: Attach release assets
needs: [release-please, build]
if: ${{ !cancelled() && needs.build.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || needs.release-please.outputs.tag_name }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || needs.release-please.outputs.tag_name }}
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Upload assets to the release
run: gh release upload "$TAG" dist/* scripts/install.sh --clobber
publish-npm:
name: Publish npm packages
needs: [release-please, build]
if: ${{ !cancelled() && needs.build.result == 'success' }}
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write # npm --provenance
env:
TAG: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || needs.release-please.outputs.tag_name }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.tag || needs.release-please.outputs.tag_name }}
- uses: oven-sh/setup-bun@v2
with:
bun-version: latest
- uses: actions/setup-node@v6
with:
node-version: 22
registry-url: https://registry.npmjs.org
- uses: actions/download-artifact@v8
with:
path: dist
merge-multiple: true
- name: Generate npm packages from SEA tarballs
run: bun run scripts/build-npm-packages.ts --version "${TAG#v}" --tarballs dist --out npm-dist
# Platform packages first, wrapper last: the wrapper's
# optionalDependencies must be resolvable the moment it goes live.
# Already-published versions are skipped so a recovery re-run after a
# partial publish completes the remaining packages instead of failing.
- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
publish() {
local name
name=$(bun -e "console.log(require('./$1/package.json').name)")
if npm view "${name}@${TAG#v}" version >/dev/null 2>&1; then
echo "skip ${name}@${TAG#v}: already published"
else
(cd "$1" && npm publish --provenance --access public)
fi
}
for pkg in npm-dist/platforms/*; do
publish "$pkg"
done
publish npm-dist/coderadius