Skip to content

Commit ce4d539

Browse files
committed
fix(ci): remove nightly-version job, compute version inline to avoid cascade skips
1 parent 803c185 commit ce4d539

File tree

1 file changed

+23
-39
lines changed

1 file changed

+23
-39
lines changed

.github/workflows/ci.yml

Lines changed: 23 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -11,31 +11,6 @@ concurrency:
1111
cancel-in-progress: true
1212

1313
jobs:
14-
nightly-version:
15-
name: Compute Nightly Version
16-
# Only compute a nightly version on direct pushes to main — not on PRs or
17-
# release branches. Downstream jobs (build-binary, publish-nightly) check
18-
# whether this output is non-empty before acting on it; when this job is
19-
# skipped the output is an empty string, so they behave as normal CI runs.
20-
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
21-
runs-on: ubuntu-latest
22-
outputs:
23-
version: ${{ steps.version.outputs.version }}
24-
steps:
25-
- uses: actions/checkout@v4
26-
with:
27-
sparse-checkout: package.json
28-
- id: version
29-
name: Compute version
30-
run: |
31-
VERSION=$(node -e "
32-
const pkg = JSON.parse(require('fs').readFileSync('package.json', 'utf8'));
33-
const ts = Math.floor(Date.now() / 1000);
34-
// Replace trailing -dev.<n> suffix with -dev.<unix_seconds>
35-
console.log(pkg.version.replace(/-dev\.\d+$/, '-dev.' + ts));
36-
")
37-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
38-
3914
changes:
4015
name: Detect Changes
4116
runs-on: ubuntu-latest
@@ -158,10 +133,7 @@ jobs:
158133

159134
build-binary:
160135
name: Build Binary (${{ matrix.target }})
161-
needs: [lint, test-unit, nightly-version]
162-
# Allow this job to run even when nightly-version is skipped (PRs / non-main pushes).
163-
# Without this, GitHub skips dependents of skipped jobs by default.
164-
if: ${{ !failure() && !cancelled() }}
136+
needs: [lint, test-unit]
165137
runs-on: ${{ matrix.os }}
166138
strategy:
167139
fail-fast: false
@@ -207,18 +179,18 @@ jobs:
207179
echo "All install attempts failed"
208180
exit 1
209181
- name: Set nightly version
210-
# Inject the computed nightly version into package.json before the build
211-
# so it gets baked into the binary. Only runs on main-branch pushes where
212-
# nightly-version produced a non-empty output.
213-
if: needs.nightly-version.outputs.version != ''
182+
# Inject a nightly version into package.json before the build so it gets
183+
# baked into the binary. Only runs on direct pushes to main.
184+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
214185
shell: bash
215186
run: |
216187
node -e "
217188
const fs = require('fs');
218189
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
219-
pkg.version = process.argv[1];
190+
const ts = Math.floor(Date.now() / 1000);
191+
pkg.version = pkg.version.replace(/-dev\.\d+$/, '-dev.' + ts);
220192
fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
221-
" "${{ needs.nightly-version.outputs.version }}"
193+
"
222194
- name: Build
223195
env:
224196
SENTRY_CLIENT_ID: ${{ vars.SENTRY_CLIENT_ID }}
@@ -326,13 +298,25 @@ jobs:
326298
publish-nightly:
327299
name: Publish Nightly
328300
# Only publish after a successful main-branch build+test. Skipped on PRs
329-
# and release branches (nightly-version output will be empty).
330-
needs: [nightly-version, build-binary, test-e2e]
301+
# and release branches.
302+
needs: [build-binary, test-e2e]
331303
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
332304
runs-on: ubuntu-latest
333305
permissions:
334306
contents: write
335307
steps:
308+
- uses: actions/checkout@v4
309+
with:
310+
sparse-checkout: package.json
311+
- name: Compute nightly version
312+
id: version
313+
run: |
314+
VERSION=$(node -e "
315+
const pkg = JSON.parse(require('fs').readFileSync('package.json', 'utf8'));
316+
const ts = Math.floor(Date.now() / 1000);
317+
console.log(pkg.version.replace(/-dev\.\d+$/, '-dev.' + ts));
318+
")
319+
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
336320
- name: Download all binary artifacts
337321
uses: actions/download-artifact@v4
338322
with:
@@ -342,7 +326,7 @@ jobs:
342326
- name: Create version.json
343327
run: |
344328
cat > version.json <<EOF
345-
{"version":"${{ needs.nightly-version.outputs.version }}","sha":"${{ github.sha }}","date":"$(date -u +%Y-%m-%dT%H:%M:%SZ)"}
329+
{"version":"${{ steps.version.outputs.version }}","sha":"${{ github.sha }}","date":"$(date -u +%Y-%m-%dT%H:%M:%SZ)"}
346330
EOF
347331
- name: Create or update nightly release
348332
env:
@@ -361,7 +345,7 @@ jobs:
361345
--prerelease \
362346
--notes "Latest nightly build from the \`main\` branch.
363347
364-
**Version:** \`${{ needs.nightly-version.outputs.version }}\`
348+
**Version:** \`${{ steps.version.outputs.version }}\`
365349
**Commit:** ${{ github.sha }}"
366350
367351
# Upload/replace all .gz binaries and the version manifest

0 commit comments

Comments
 (0)