Repository navigation
282 lines (272 loc) · 10.4 KB
/
Copy pathpreview.yml
File metadata and controls
282 lines (272 loc) · 10.4 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
272
273
274
275
276
277
278
279
280
281
282
name: V1 preview
on:
push:
branches: [master]
workflow_dispatch:
inputs:
expedite:
description: Publish this master snapshot without the quiet wait, retaining all validation
type: boolean
default: false
# Automatic runs debounce master and discard obsolete builds. Explicit expedited
# dispatches pin their master snapshot in a separate, non-cancelling group so
# ongoing development cannot starve publication. All validation still applies.
# No tag/release/workflow_run trigger, and only GITHUB_TOKEN may publish.
concurrency:
group: v1-preview-${{ github.event_name == 'workflow_dispatch' && inputs.expedite && 'pinned' || 'master' }}
cancel-in-progress: ${{ github.event_name == 'push' }}
permissions:
contents: read
actions: read
env:
JCODE_CI: "1"
JCODE_PREVIEW_PINNED: ${{ github.event_name == 'workflow_dispatch' && inputs.expedite && 'true' || 'false' }}
JCODE_RELEASE_BUILD: "1"
JCODE_CI_BUILD: "1"
JCODE_BUILD_SEMVER: v1.0.0-preview.${{ github.run_number }}
CARGO_BUILD_RUSTC_WRAPPER: ""
CARGO_TERM_COLOR: always
CARGO_INCREMENTAL: "0"
CARGO_PROFILE_RELEASE_OPT_LEVEL: "3"
JUSTRUST_TOOLCHAIN: system
JUSTRUST_SLOTS: "0"
JUSTRUST_NO_TELEMETRY: "1"
jobs:
quiet-and-ci:
if: github.repository == '1jehuang/jcode' && vars.JCODE_V1_PREVIEW_ENABLED != 'false' && github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
timeout-minutes: 205
steps:
- name: Require 15 quiet minutes on master
if: env.JCODE_PREVIEW_PINNED != 'true'
run: sleep 900
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
persist-credentials: false
- name: Reject superseded master commit
env:
GH_TOKEN: ${{ github.token }}
run: |
set --
if [ "$JCODE_PREVIEW_PINNED" = true ]; then set -- --pinned; fi
python3 scripts/preview_release.py check-head --sha "$GITHUB_SHA" --tag "$JCODE_BUILD_SEMVER" "$@"
- name: Require exact-commit source CI under preview policy
env:
GH_TOKEN: ${{ github.token }}
run: python3 scripts/check_release_ci.py "$GITHUB_SHA" --repo "$GITHUB_REPOSITORY" --timeout 10800 --preview
build:
needs: quiet-and-ci
runs-on: ${{ matrix.os }}
timeout-minutes: 100
strategy:
fail-fast: true
matrix:
include:
- os: ubuntu-22.04
target: x86_64-unknown-linux-gnu
artifact: jcode-linux-x86_64
compat: true
hosted: true
# Match the x86 tenant host for the source-pinned justrust bootstrap.
# ARM execution separately consumes this job's uploaded archive.
- os: ubuntu-24.04
target: aarch64-unknown-linux-gnu
artifact: jcode-linux-aarch64
hosted: true
- os: macos-latest
target: aarch64-apple-darwin
artifact: jcode-macos-aarch64
- os: macos-15-intel
target: x86_64-apple-darwin
artifact: jcode-macos-x86_64
- os: windows-latest
target: x86_64-pc-windows-msvc
artifact: jcode-windows-x86_64
msvc: amd64
- os: windows-11-arm
target: aarch64-pc-windows-msvc
artifact: jcode-windows-aarch64
msvc: amd64_arm64
cargo_args: --no-default-features --features pdf
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
fetch-depth: 0
submodules: recursive
persist-credentials: false
- uses: ilammy/msvc-dev-cmd@v1
if: runner.os == 'Windows'
with:
arch: ${{ matrix.msvc }}
- uses: dtolnay/rust-toolchain@stable
if: matrix.hosted != true
with:
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
if: matrix.hosted != true
with:
key: preview-${{ matrix.target }}
- uses: dtolnay/rust-toolchain@stable
if: matrix.hosted == true
with:
toolchain: 1.99.0
- name: Install pinned justrust
if: matrix.hosted != true
shell: bash
run: bash scripts/install_justrust_ci.sh
- name: Install source-pinned hosted justrust
if: matrix.hosted == true
shell: bash
run: bash scripts/install_justrust_hosted_ci.sh
- name: Build Linux preview on hosted justrust
if: matrix.hosted == true
shell: bash
env:
JCODE_API_KEY: ${{ secrets.JUSTRUST_API_KEY }}
run: bash scripts/build_preview_linux_hosted.sh "${{ matrix.target }}"
- name: Verify and package portable hosted Linux preview
if: matrix.compat == true
shell: bash
run: bash scripts/package_preview_linux_hosted.sh
- name: Build native preview
if: matrix.hosted != true && runner.os != 'Windows'
shell: bash
env:
TARGET: ${{ matrix.target }}
EXTRA_ARGS: ${{ matrix.cargo_args }}
# SDK-backed hosted macOS/MSVC builds still need provisioning.
JUSTRUST_DISABLE: "1"
run: |
set -euo pipefail
# Positional parameters also expand safely when empty on macOS Bash 3.2.
set --
if [ -n "$EXTRA_ARGS" ]; then
read -r -a extra_args <<< "$EXTRA_ARGS"
set -- "${extra_args[@]}"
fi
justrust build --local --locked --release --target "$TARGET" -p jcode --bin jcode "$@"
- name: Build Windows preview with MSVC environment
if: runner.os == 'Windows'
shell: pwsh
env:
TARGET: ${{ matrix.target }}
EXTRA_ARGS: ${{ matrix.cargo_args }}
JUSTRUST_DISABLE: "1"
run: |
$ErrorActionPreference = 'Stop'
# Git Bash prepends its Unix link.exe ahead of the MSVC linker.
# PowerShell preserves the developer-command-prompt PATH ordering.
$extraArgs = @()
if ($env:EXTRA_ARGS) {
$extraArgs = $env:EXTRA_ARGS -split '\s+'
}
& justrust build --local --locked --release --target $env:TARGET -p jcode --bin jcode @extraArgs
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
- name: Package native binary
if: matrix.compat != true
shell: bash
env:
TARGET: ${{ matrix.target }}
ARTIFACT: ${{ matrix.artifact }}
run: |
set -euo pipefail
mkdir -p dist
extension=""
if [ "$RUNNER_OS" = Windows ]; then extension=.exe; fi
cp "target/$TARGET/release/jcode$extension" "dist/$ARTIFACT$extension"
if [ "$RUNNER_OS" = macOS ]; then
codesign --force --sign - --identifier com.jcode.cli "dist/$ARTIFACT"
codesign -dv "dist/$ARTIFACT" 2>&1 | grep -qx 'Identifier=com.jcode.cli'
fi
# Never execute cross-built ARM on the x86 packaging caller.
if [ "$TARGET" != aarch64-unknown-linux-gnu ]; then
"dist/$ARTIFACT$extension" --no-update --no-selfdev --version | tee "$RUNNER_TEMP/preview-version.txt"
grep -F "$JCODE_BUILD_SEMVER" "$RUNNER_TEMP/preview-version.txt"
fi
tar czf "dist/$ARTIFACT.tar.gz" -C dist "$ARTIFACT$extension"
- name: Verify portable preview version
if: matrix.compat == true
shell: bash
run: |
dist/jcode-linux-x86_64 --no-update --no-selfdev --version | tee "$RUNNER_TEMP/preview-version.txt"
grep -F "$JCODE_BUILD_SEMVER" "$RUNNER_TEMP/preview-version.txt"
- name: Verify locked source
shell: bash
run: git diff --exit-code -- Cargo.lock
- uses: actions/upload-artifact@v4
with:
name: preview-${{ matrix.artifact }}
path: dist/${{ matrix.artifact }}.tar.gz
if-no-files-found: error
native-arm-runtime:
needs: build
runs-on: ubuntu-24.04-arm
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
persist-credentials: false
# Consume the same immutable upload as publish, never rebuild or repackage.
# No hosted credentials enter this job.
- uses: actions/download-artifact@v4
with:
name: preview-jcode-linux-aarch64
path: dist
- name: Verify uploaded ARM archive on native Ubuntu 24.04
shell: bash
run: python3 scripts/verify_preview_arm_runtime.py dist/jcode-linux-aarch64.tar.gz
publish:
needs: [quiet-and-ci, build, native-arm-runtime]
if: github.repository == '1jehuang/jcode' && vars.JCODE_V1_PREVIEW_ENABLED != 'false'
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
actions: read
contents: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.sha }}
persist-credentials: false
- uses: actions/download-artifact@v4
with:
pattern: preview-jcode-*
merge-multiple: true
path: dist
- name: Publish validated current head or explicitly pinned master snapshot
env:
GH_TOKEN: ${{ github.token }}
run: |
set --
if [ "$JCODE_PREVIEW_PINNED" = true ]; then set -- --pinned; fi
python3 scripts/preview_release.py publish --sha "$GITHUB_SHA" --tag "$JCODE_BUILD_SEMVER" --assets dist "$@"
publish-sdk:
needs: publish
runs-on: ubuntu-latest
permissions:
contents: read
actions: write
steps:
# npm's trusted publisher is bound to the standalone SDK workflow identity.
# A reusable call carries this caller's identity and is rejected by npm.
# GITHUB_TOKEN also suppresses release events, so dispatch explicitly.
- name: Dispatch trusted SDK preview publication
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run publish-typescript-sdk.yml --repo "$GITHUB_REPOSITORY" --ref master -f "jcode_release_tag=$JCODE_BUILD_SEMVER"
announce:
needs: publish
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
steps:
# GITHUB_TOKEN suppresses release events. Reuse the announcement workflow's
# per-tag concurrency and marker-based duplicate prevention explicitly.
- name: Dispatch opt-in preview announcement
env:
GH_TOKEN: ${{ github.token }}
run: gh workflow run discord-release.yml --repo "$GITHUB_REPOSITORY" --ref master -f "tag=$JCODE_BUILD_SEMVER"