Repository navigation
271 lines (260 loc) · 10.3 KB
/
Copy pathpublish.yml
File metadata and controls
271 lines (260 loc) · 10.3 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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: Publish
# One workflow publishes every channel, since npm trusted publishing names a single workflow file.
# - canary / dev: every push to that branch
# - latest: run by hand on `main`; publishes each package whose version is not on npm yet
# dev and latest also make GitHub Releases (scripts/github.mjs): `devel`, one prerelease with the
# standalone binary replaced on every dev push, or `<pkg>@v<version>` per package released on
# latest, the CLI's with the binary and marked latest. canary makes `nightly`, one prerelease
# with the desktop app replaced on every canary push.
on:
push:
branches: [canary, dev]
paths-ignore:
- sites/**
- CHANGELOG.md
- README.md
workflow_dispatch:
permissions:
contents: read
id-token: write
concurrency:
group: publish-${{ github.ref_name }}
cancel-in-progress: false
env:
CHANNEL: ${{ github.event_name == 'workflow_dispatch' && 'latest' || github.ref_name }}
jobs:
guard:
runs-on: ubuntu-latest
# The run's release id, computed once so every job publishes under the same version.
outputs:
id: ${{ steps.release.outputs.id }}
steps:
- if: github.event_name == 'workflow_dispatch' && github.ref_name != 'main'
run: echo "::error::latest is published from main only" && exit 1
- uses: actions/checkout@v6
- uses: voidzero-dev/setup-vp@v1.21.1
with:
node-version: 24
run-install: false
cache: false
- id: release
run: echo "id=$(node scripts/version.mjs "$CHANNEL")" >> "$GITHUB_OUTPUT"
tui:
needs: guard
name: tui (${{ matrix.package }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: true
matrix:
include:
- package: tui-darwin-arm64
runner: macos-14
target: aarch64-apple-darwin
# Linux binaries link musl statically, so one build runs on any distro.
- package: tui-linux-arm64
runner: ubuntu-24.04-arm
target: aarch64-unknown-linux-musl
- package: tui-linux-x64
runner: ubuntu-24.04
target: x86_64-unknown-linux-musl
defaults:
run:
working-directory: packages/tui
steps:
- uses: actions/checkout@v6
- if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
workspaces: packages/tui
key: ${{ matrix.target }}
- run: cargo build --release --locked --target ${{ matrix.target }}
- if: runner.os == 'Linux'
name: Require a static binary
run: file target/${{ matrix.target }}/release/codework-tui | grep -E "static(-pie)? linked|statically linked"
# One artifact per platform package, named after it (`tui-<os>-<arch>`).
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.package }}
path: packages/tui/target/${{ matrix.target }}/release/codework-tui
if-no-files-found: error
retention-days: 1
publish:
needs: [guard, tui]
runs-on: ubuntu-latest
env:
CODEWORK_RELEASE_ID: ${{ needs.guard.outputs.id }}
steps:
- uses: actions/checkout@v6
- uses: voidzero-dev/setup-vp@v1.21.1
with:
node-version: 24
registry-url: https://registry.npmjs.org
run-install: false
cache: false
- run: vp install --frozen-lockfile --filter '!@codeworksh/www'
# Canary is push-and-build for quick testing; dev and latest are checked first.
- if: env.CHANNEL != 'canary'
run: vp run verify
# One directory per platform package; each package's build stages its binary from here.
- uses: actions/download-artifact@v8
with:
pattern: tui-*
path: packages/tui/dist/bin
- run: vp run release "$CHANNEL"
binary:
needs: [guard, tui]
if: github.ref_name != 'canary'
name: binary (${{ matrix.binary }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: true
matrix:
# Each on its own platform: --build-sea runs that platform's Node, and macOS signs.
include:
- binary: cli-darwin-arm64
tui: tui-darwin-arm64
runner: macos-14
- binary: cli-linux-arm64
tui: tui-linux-arm64
runner: ubuntu-24.04-arm
- binary: cli-linux-x64
tui: tui-linux-x64
runner: ubuntu-24.04
env:
CODEWORK_RELEASE_ID: ${{ needs.guard.outputs.id }}
steps:
- uses: actions/checkout@v6
# node-liblzma builds against the system liblzma at install. The bundle rebuilds it with xz
# linked statically, which needs cmake; the runners ship it.
- if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y liblzma-dev
- uses: voidzero-dev/setup-vp@v1.21.1
with:
node-version: 24
run-install: false
cache: false
- run: vp install --frozen-lockfile --filter '!@codeworksh/www'
- uses: actions/download-artifact@v8
with:
name: ${{ matrix.tui }}
path: tui
- run: |
chmod +x tui/codework-tui
echo "CODEWORK_TUI_BIN=$GITHUB_WORKSPACE/tui/codework-tui" >> "$GITHUB_ENV"
echo "CODEWORK_VERSION=$(node scripts/version.mjs "$CHANNEL" packages/codework)" >> "$GITHUB_ENV"
# The static xz build downloads xz through GitHub's API, which limits anonymous requests.
- working-directory: packages/codework
env:
GITHUB_TOKEN: ${{ github.token }}
run: vp run bundle && vp run sea
# Without API keys only the offline case runs: the binary with no Node on PATH unpacks its
# assets and runs a plugin through its own effect.
- working-directory: packages/codework
run: vp test test/sea.test.ts
- run: tar -czf ${{ matrix.binary }}.tar.gz -C packages/codework/dist/sea codework
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.binary }}
path: ${{ matrix.binary }}.tar.gz
if-no-files-found: error
retention-days: 1
# After npm, so a release never names a version npm does not have.
release:
needs: [guard, publish, binary]
if: github.ref_name != 'canary'
runs-on: ubuntu-latest
permissions:
contents: write
env:
CODEWORK_RELEASE_ID: ${{ needs.guard.outputs.id }}
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v6
- uses: voidzero-dev/setup-vp@v1.21.1
with:
node-version: 24
run-install: false
cache: false
- uses: actions/download-artifact@v8
with:
pattern: cli-*
path: release
merge-multiple: true
# codework.sh/install verifies each download against SHA256SUMS.
- run: (cd release && sha256sum *.tar.gz > SHA256SUMS)
- run: node scripts/github.mjs "$CHANNEL" release
desktop:
needs: guard
if: github.ref_name == 'canary'
name: desktop (${{ matrix.target }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: true
matrix:
# Each on its own platform: electron-builder packages for the host, and macOS signs.
include:
- target: mac-arm64
runner: macos-14
args: --mac --arm64
- target: linux-arm64
runner: ubuntu-24.04-arm
args: --linux --arm64
- target: linux-x64
runner: ubuntu-24.04
args: --linux --x64
env:
CODEWORK_RELEASE_ID: ${{ needs.guard.outputs.id }}
steps:
- uses: actions/checkout@v6
# The pacman target packs with bsdtar.
- if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get install -y libarchive-tools
- uses: voidzero-dev/setup-vp@v1.21.1
with:
node-version: 24
run-install: false
cache: false
# The app packages the web app and the app server it builds, so those install too.
- run: vp install --frozen-lockfile --filter '@codeworksh/desktop...' --filter '@codeworksh/server...'
- working-directory: apps/desktop
run: vp run package "$CHANNEL" ${{ matrix.args }}
# Installers only; electron-builder's update blockmaps and unpacked app stay behind.
- uses: actions/upload-artifact@v7
with:
name: desktop-${{ matrix.target }}
path: |
apps/desktop/dist/codework-desktop-*.dmg
apps/desktop/dist/codework-desktop-*.zip
apps/desktop/dist/codework-desktop-*.AppImage
apps/desktop/dist/codework-desktop-*.deb
apps/desktop/dist/codework-desktop-*.pacman
if-no-files-found: error
retention-days: 1
# After npm, so `nightly` never names a commit whose packages did not ship.
nightly:
needs: [guard, publish, desktop]
if: github.ref_name == 'canary'
runs-on: ubuntu-latest
permissions:
contents: write
env:
CODEWORK_RELEASE_ID: ${{ needs.guard.outputs.id }}
GH_TOKEN: ${{ github.token }}
steps:
- uses: actions/checkout@v6
- uses: voidzero-dev/setup-vp@v1.21.1
with:
node-version: 24
run-install: false
cache: false
- uses: actions/download-artifact@v8
with:
pattern: desktop-*
path: release
merge-multiple: true
- run: (cd release && sha256sum codework-desktop-* > SHA256SUMS)
- run: node scripts/github.mjs canary release