Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion .github/workflows/ci-napi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,25 @@ jobs:
if: env.NIGHTLY != 'true'
run: node scripts/check-release-version.mjs

qualify:
name: Verify release branch qualification
needs: validate-release
if: ${{ !startsWith(inputs.channel, 'nightly-') }}
runs-on: ubuntu-latest
timeout-minutes: 12
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@v7
with:
ref: ${{ needs.validate-release.outputs.build_sha }}
- name: Require the successful candidate run
env:
GH_TOKEN: ${{ github.token }}
CANDIDATE_SHA: ${{ needs.validate-release.outputs.build_sha }}
run: node scripts/check-release-qualification.mjs

build:
needs: validate-release
cache-mode: write
Expand Down Expand Up @@ -281,7 +300,8 @@ jobs:
run: pnpm --filter="!@celox-sim/celox-napi" --filter="!@celox-sim/playground" -r test

publish:
needs: [validate-release, test]
needs: [validate-release, test, qualify]
if: ${{ !cancelled() && needs.validate-release.result == 'success' && needs.test.result == 'success' && (needs.qualify.result == 'success' || (startsWith(inputs.channel, 'nightly-') && needs.qualify.result == 'skipped')) }}
runs-on: ubuntu-latest
name: Publish
environment: npm
Expand Down Expand Up @@ -318,6 +338,7 @@ jobs:
- name: Download all artifacts
uses: actions/download-artifact@v8
with:
pattern: bindings-*
path: crates/celox-napi/artifacts

- name: Create npm dirs
Expand Down
177 changes: 129 additions & 48 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

20 changes: 19 additions & 1 deletion .github/workflows/publish-crates.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,24 @@ jobs:
- name: Check synchronized release versions
run: node scripts/check-release-version.mjs

qualify:
name: Verify release branch qualification
needs: validate
runs-on: ubuntu-latest
timeout-minutes: 12
permissions:
contents: read
actions: read
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
- name: Require the successful candidate run
env:
GH_TOKEN: ${{ github.token }}
CANDIDATE_SHA: ${{ github.sha }}
run: node scripts/check-release-qualification.mjs

package:
name: Package and test
needs: validate
Expand Down Expand Up @@ -111,7 +129,7 @@ jobs:

publish:
name: Publish to crates.io
needs: [validate, package]
needs: [validate, package, qualify]
runs-on: ubuntu-latest
environment: crates-io
permissions:
Expand Down
83 changes: 83 additions & 0 deletions .github/workflows/release-candidate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Release Candidate

on:
push:
branches: [release]
workflow_dispatch:
inputs:
validation_only:
description: Qualify a recovery SHA without creating a stable release
type: boolean
default: false

# A newer RC must not cancel qualification of a running candidate.
concurrency:
group: release-candidate
cancel-in-progress: false

permissions:
contents: read

jobs:
candidate:
name: Resolve release candidate
if: github.ref == 'refs/heads/release'
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.candidate.outputs.sha }}
tag: ${{ steps.candidate.outputs.tag }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.sha }}
fetch-depth: 0
- name: Validate candidate identity
id: candidate
run: |
git merge-base --is-ancestor HEAD origin/master
node scripts/check-release-version.mjs
tag="v$(tr -d '\r\n' < VERSION)"
[[ "$tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]
echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
echo "tag=$tag" >> "$GITHUB_OUTPUT"

qualify:
name: Qualify release candidate
needs: candidate
uses: ./.github/workflows/ci.yml
permissions:
contents: read
issues: write
with:
validation_ref: ${{ needs.candidate.outputs.sha }}
secrets: inherit

publish:
name: Promote qualified candidate
if: inputs.validation_only != true
needs: [candidate, qualify]
runs-on: ubuntu-latest
steps:
- name: Create release app token
id: release-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ vars.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-pull-requests: write
permission-issues: write
permission-actions: write
permission-contents: write
permission-workflows: write

- uses: actions/checkout@v7
with:
ref: ${{ needs.candidate.outputs.sha }}
fetch-depth: 0

- name: Publish the qualified candidate
env:
GH_TOKEN: ${{ steps.release-token.outputs.token }}
CANDIDATE_SHA: ${{ needs.candidate.outputs.sha }}
RELEASE_TAG: ${{ needs.candidate.outputs.tag }}
run: node scripts/promote-release-candidate.mjs
42 changes: 2 additions & 40 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,48 +59,10 @@ jobs:
token: ${{ steps.release-token.outputs.token }}
config-file: release-please-config.json
manifest-file: .release-please-manifest.json
# Keep tag/Release creation active when a frozen PR has merged.
# Version PRs land on master; only the release branch publishes.
skip-github-release: true
skip-github-pull-request: ${{ steps.release-pr.outputs.frozen == 'true' }}

# A merge queue can push several merged PRs together. The release tag
# then points at an earlier commit than github.sha. Publish the tag that
# release-please actually created, including on scheduled/manual runs.
- name: Queue package publication for this release
if: steps.release.outputs.release_created == 'true'
env:
GH_TOKEN: ${{ steps.release-token.outputs.token }}
RELEASE_TAG: ${{ steps.release.outputs.tag_name }}
shell: bash
run: |
release_tag="$RELEASE_TAG"
if [[ ! "$release_tag" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Expected a v-prefixed stable release tag, got $release_tag." >&2
exit 1
fi

published_tag="$(
gh release view "$release_tag" \
--repo "$GITHUB_REPOSITORY" \
--json tagName,isDraft,isPrerelease \
--jq 'select(.isDraft == false and .isPrerelease == false) | .tagName'
)"
if [ "$published_tag" != "$release_tag" ]; then
echo "Published GitHub Release $release_tag was not found." >&2
exit 1
fi

jq -n \
--arg tag "$release_tag" \
'{event_type: "napi-release", client_payload: {tag: $tag}}' \
| gh api \
--method POST \
"repos/$GITHUB_REPOSITORY/dispatches" \
--input -

gh workflow run publish-crates.yml \
--repo "$GITHUB_REPOSITORY" \
--ref "$release_tag"

queue-release:
name: Queue weekly release
needs: release-please
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/stage-release-candidate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Stage Release Candidate

on:
pull_request:
types: [closed]
branches: [master]

# Each merged release PR must reach staging. Do not put these one-shot events
# in a concurrency group: even cancel-in-progress: false replaces pending runs.
# The non-force push below prevents an older event from rewinding release.
permissions: {}

jobs:
stage-candidate:
name: Stage release candidate
if: >-
github.event_name == 'pull_request' && github.event.pull_request.merged == true &&
github.event.pull_request.head.repo.full_name == github.repository &&
github.event.pull_request.head.ref == 'release-please--branches--master--components--celox'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Create release app token
id: release-token
uses: actions/create-github-app-token@v3
with:
app-id: ${{ vars.RELEASE_APP_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
permission-contents: write
permission-workflows: write

- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.merge_commit_sha }}
fetch-depth: 0
token: ${{ steps.release-token.outputs.token }}

- name: Advance release to the merged candidate
env:
CANDIDATE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
run: |
test "$(git rev-parse HEAD)" = "$CANDIDATE_SHA"
node scripts/check-release-version.mjs
# No force push: release contains only successive master candidates.
git push origin "$CANDIDATE_SHA:refs/heads/release"

Loading
Loading