-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ci): Add Release Pipeline (NPM) #13
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
13f8bf2
v0.0.5 [skip ci]
Firaenix e313751
feat(ci): Add Release Pipeline (NPM)
Firaenix 4267f72
no need for awk
Firaenix c8724ee
Merge branch 'main' into release-pipeline
Firaenix b0fc44c
fix version
Firaenix 324a0c2
integrate npm release into release plz workflow
Firaenix f5d86de
Address comments
Firaenix fa1b0e4
Merge branch 'main' into release-pipeline
Firaenix 059ac8f
ensure release plz doesnt create multiple tags
Firaenix File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| name: "Build" | ||
| description: "Sets up environment and builds the WASM package" | ||
|
|
||
| inputs: | ||
| node-version: | ||
| description: "Node.js version to install" | ||
| required: false | ||
| default: "24" | ||
| setup-npm-registry: | ||
| description: "Setup NPM registry URL" | ||
| required: false | ||
| default: "false" | ||
|
|
||
| runs: | ||
| using: "composite" | ||
| steps: | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6 | ||
| with: | ||
| node-version: ${{ inputs.node-version }} | ||
| registry-url: ${{ inputs.setup-npm-registry == 'true' && 'https://registry.npmjs.org' || '' }} | ||
|
|
||
| - name: Setup Rust | ||
| uses: dtolnay/rust-toolchain@stable | ||
| with: | ||
| targets: wasm32-unknown-unknown | ||
|
|
||
| - name: Rust cache | ||
| uses: Swatinem/rust-cache@v2 | ||
|
|
||
| - name: Install cargo-binstall | ||
| uses: cargo-bins/cargo-binstall@main | ||
|
|
||
| - name: Install wasm-pack | ||
| shell: bash | ||
| run: cargo binstall wasm-pack -y | ||
|
|
||
| - name: Install just | ||
| uses: extractions/setup-just@v2 | ||
|
|
||
| - name: Install npm dependencies | ||
| shell: bash | ||
| working-directory: ./wasm | ||
| run: npm install | ||
|
|
||
| - name: Build WASM | ||
| shell: bash | ||
| run: just build-wasm | ||
|
cursor[bot] marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Publishes @bulletxyz/sdk-wasm to npm. Triggered by the `v<version>` git tag | ||
| # release-plz creates after a release PR is merged (see release-plz.yml). | ||
| # release-plz.toml pins this to a single workspace-wide `v<version>` tag rather | ||
| # than per-crate tags, so both crates ship under one release. | ||
| # | ||
| # The version is already baked into wasm/Cargo.toml and wasm/package.json at this | ||
| # point, so this workflow only builds and publishes — no version bump, no commits. | ||
| # | ||
| # Authentication uses npm OIDC Trusted Publishers; configure at: | ||
| # https://www.npmjs.com/package/@bulletxyz/sdk-wasm/access | ||
| # See: https://docs.npmjs.com/generating-provenance-statements#publishing-packages-with-provenance-via-github-actions | ||
|
|
||
| name: NPM Publish | ||
|
|
||
| on: | ||
| push: | ||
| tags: | ||
| - "v*" | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| workflow_dispatch: | ||
| inputs: | ||
| tag: | ||
| description: "Existing git tag to publish (e.g. v0.0.14)" | ||
| required: true | ||
| type: string | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
| CARGO_NET_GIT_FETCH_WITH_CLI: true | ||
| CI: 1 | ||
|
|
||
| concurrency: | ||
| group: npm-publish | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| id-token: write | ||
| steps: | ||
| - name: Resolve ref | ||
| id: ref | ||
| env: | ||
| INPUT_TAG: ${{ inputs.tag }} | ||
| PUSH_REF: ${{ github.ref }} | ||
| run: | | ||
| if [ -n "${INPUT_TAG:-}" ]; then | ||
| echo "ref=${INPUT_TAG}" >> "$GITHUB_OUTPUT" | ||
| else | ||
| echo "ref=${PUSH_REF}" >> "$GITHUB_OUTPUT" | ||
| fi | ||
|
|
||
| - name: Checkout tag | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| ref: ${{ steps.ref.outputs.ref }} | ||
| persist-credentials: false | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Verify tag matches Cargo + package.json versions | ||
| id: version | ||
| env: | ||
| REF: ${{ steps.ref.outputs.ref }} | ||
| run: | | ||
| set -euo pipefail | ||
| TAG="${REF#refs/tags/}" | ||
| V="${TAG#v}" | ||
| if ! echo "$V" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then | ||
| echo "::error::Tag '$TAG' is not a valid semver tag" >&2 | ||
| exit 1 | ||
| fi | ||
| CARGO_V=$(grep -m1 '^version' wasm/Cargo.toml | sed -E 's/.*"([^"]+)".*/\1/') | ||
| PKG_V=$(node -p "require('./wasm/package.json').version") | ||
| if [ "$V" != "$CARGO_V" ] || [ "$V" != "$PKG_V" ]; then | ||
| echo "::error::Version mismatch — tag=$V wasm/Cargo.toml=$CARGO_V wasm/package.json=$PKG_V" >&2 | ||
| exit 1 | ||
| fi | ||
| echo "version=$V" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Build | ||
| uses: ./.github/actions/build | ||
| with: | ||
| setup-npm-registry: "true" | ||
|
|
||
| - name: Publish to npm | ||
| working-directory: wasm | ||
| env: | ||
| VERSION: ${{ steps.version.outputs.version }} | ||
| run: | | ||
| set -euo pipefail | ||
| TAG=$(echo "$VERSION" | grep -q '-' && echo "rc" || echo "latest") | ||
| npm publish --provenance --tag "$TAG" --access public | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -87,6 +87,7 @@ | |
| packages = [ | ||
| rust | ||
| pkgs.cargo-nextest | ||
| pkgs.cargo-edit | ||
| pkgs.just | ||
| (makeWasmPack pkgs) | ||
| pkgs.pkg-config | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Unpinned third-party action in release publish pipeline
Medium Severity
cargo-bins/cargo-binstall@mainreferences a mutable branch rather than a commit SHA, unlike the other actions in this pipeline (e.g.,actions/checkoutandactions/setup-nodeare SHA-pinned). Since this composite action is used in thenpm-publish.ymlworkflow that hasid-token: writepermission and publishes to npm with provenance, a compromisedmainbranch in the cargo-binstall repo could inject malicious code into the published package. At minimum, theversioninput available on this action could be set to pin the installed binary version.Reviewed by Cursor Bugbot for commit 059ac8f. Configure here.