Repository navigation
ci: publish a binary prerelease for every verified main commit #360
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,59 @@ | ||||||
| name: Binary prerelease | ||||||
|
|
||||||
| # Every commit on main that passed Verify PR becomes a GitHub prerelease carrying the five single binaries, | ||||||
| # titled with the time it was created (2026-11-01T10:30:00Z), tag 20261101T103000Z-<short sha> (git tags | ||||||
| # cannot hold ":"; the sha keeps parallel runs apart). Prereleases are never "latest", so the in-app update | ||||||
| # notice and `v*` releases are unaffected. | ||||||
| on: | ||||||
| workflow_run: | ||||||
| workflows: [Verify PR] | ||||||
| types: [completed] | ||||||
| branches: [main] | ||||||
| workflow_dispatch: | ||||||
|
|
||||||
| # One group per commit: a shared group keeps only one pending run, so a burst of merges would drop commits. | ||||||
| concurrency: | ||||||
| group: ${{ github.workflow }}-${{ github.event.workflow_run.head_sha || github.sha }} | ||||||
| cancel-in-progress: false | ||||||
|
|
||||||
| permissions: | ||||||
| contents: write | ||||||
|
|
||||||
| jobs: | ||||||
| prerelease: | ||||||
| # A manual run publishes main only: from another branch it would ship that branch's unverified code. | ||||||
| if: (github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main') || (github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push') | ||||||
| runs-on: ubuntu-latest | ||||||
| env: | ||||||
| SHA: ${{ github.event.workflow_run.head_sha || github.sha }} | ||||||
| steps: | ||||||
| - uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 | ||||||
| with: | ||||||
| ref: ${{ env.SHA }} | ||||||
| # npm ci runs dependency install scripts: keep the write token out of .git/config (gh reads GH_TOKEN). | ||||||
| persist-credentials: false | ||||||
|
|
||||||
| - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 | ||||||
| with: | ||||||
| node-version-file: .nvmrc | ||||||
| cache: npm | ||||||
|
|
||||||
| - run: npm ci | ||||||
| - run: npm run build | ||||||
| - name: Build the release binaries | ||||||
| run: sh scripts/build-release-binaries.sh | ||||||
| - run: npm run smoke -- --binary release/ompweb-linux-x64/ompweb | ||||||
|
|
||||||
| - name: Publish the prerelease | ||||||
| env: | ||||||
| GH_TOKEN: ${{ github.token }} | ||||||
| run: | | ||||||
| now=$(date -u +%s) | ||||||
| title=$(date -u -d "@$now" +%Y-%m-%dT%H:%M:%SZ) | ||||||
| tag=$(date -u -d "@$now" +%Y%m%dT%H%M%SZ)-$(git rev-parse --short=10 "$SHA") | ||||||
| subject=$(git log -1 --format=%s "$SHA") | ||||||
| # A draft first, so a failed upload never leaves a published prerelease missing archives. | ||||||
| gh release create "$tag" release/ompweb-*.tar.gz release/ompweb-*.zip \ | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔥 The Roast: The publish step still globs 🩹 The Fix: Add a guard before publishing, e.g.
Suggested change
or verify each expected archive exists explicitly. 📏 Severity: suggestion
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same point as the earlier thread, so I'm not changing this. A build that produces no archive can't reach this step: |
||||||
| --repo "$GITHUB_REPOSITORY" --target "$SHA" --draft --prerelease --title "$title" \ | ||||||
| --notes "Binaries built from $GITHUB_REPOSITORY@$SHA ($subject). Not a release: no npm package, no update notice." | ||||||
| gh release edit "$tag" --repo "$GITHUB_REPOSITORY" --draft=false | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| #!/bin/sh | ||
| # The five binaries every release and prerelease ships (after `npm run build`), into release/: | ||
| # release/ompweb-<os>-<arch>.tar.gz, .zip for Windows. Bun cross-compiles all of them from one machine. | ||
| # The x64 targets name -baseline (no AVX2 needed): in Bun 1.4.4 that is the default x64 runtime too (the | ||
| # same bytes), and naming it keeps a later Bun from shipping a -modern one. They keep the plain | ||
| # ompweb-<os>-x64 names. | ||
| set -eu | ||
| for target in bun-linux-x64-baseline bun-linux-arm64 bun-darwin-x64-baseline bun-darwin-arm64 bun-windows-x64-baseline; do | ||
| npx bun scripts/build-binary.ts --target "$target" | ||
| done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 The Roast:
release/ompweb-*.tar.gz release/ompweb-*.zip— you're publishing a prerelease by glob. If the build step is ever reordered, the archives are missing, or someone renames a target, this handsghliteral asterisks and a release that either fails late or ships with filenames that look like shell incantations. It couples the publish step to an unverified naming convention with no guardrail.🩹 The Fix: Verify the archives exist before touching the release, so a renamed or missing target can't sneak in or get shipped:
sh
shas=(release/ompweb-.tar.gz release/ompweb-.zip)
for f in "${shas[@]}"; do [ -e "$f" ] || { echo "missing $f" >&2; exit 1; }; done
gh release create "$tag" "${shas[@]}" --repo "$GITHUB_REPOSITORY" --target "$SHA" --draft --prerelease --title "$title" --notes "..."
📏 Severity: nitpick
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not changing this.
scripts/build-release-binaries.shruns withset -eu, so a target that fails to build fails the job before this step. An unmatched glob reachesghas a literal path, andgh release createstops on a missing asset file, before a release or tag exists. Either way the job fails before anything is published.