-
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
Changes from 6 commits
13f8bf2
e313751
4267f72
c8724ee
b0fc44c
324a0c2
f5d86de
fa1b0e4
059ac8f
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,73 @@ | ||
| name: "Build" | ||
| description: "Sets up environment and builds the WASM package" | ||
|
|
||
| inputs: | ||
| github-app-token: | ||
| description: "GitHub App token for private git deps" | ||
| required: false | ||
| default: "" | ||
| configure-git-user: | ||
| description: "Configure git user for commits" | ||
| required: false | ||
| default: "false" | ||
| 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: Configure git for GitHub App auth (private deps and push) | ||
| if: ${{ inputs.github-app-token != '' }} | ||
| shell: bash | ||
| env: | ||
| BULLET_APP_TOKEN: ${{ inputs.github-app-token }} | ||
| run: | | ||
| git config --global --add url."https://x-access-token:${BULLET_APP_TOKEN}@github.com/".insteadOf "ssh://git@github.com/" | ||
| git config --global --add url."https://x-access-token:${BULLET_APP_TOKEN}@github.com/".insteadOf "git@github.com:" | ||
| git config --global --add url."https://x-access-token:${BULLET_APP_TOKEN}@github.com/".insteadOf "https://github.com/" | ||
|
cursor[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
|
Contributor
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. Which dependencies are needing these?
Contributor
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. None, good point, this was copied from the old js sdk |
||
| - name: Configure Git user | ||
| if: ${{ inputs.configure-git-user == 'true' }} | ||
| shell: bash | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
|
|
||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| 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 | ||
|
Contributor
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. Unpinned third-party action in release publish pipelineMedium Severity
Reviewed by Cursor Bugbot for commit 059ac8f. Configure here. |
||
|
|
||
| - 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.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| # Publishes @bulletxyz/sdk-wasm to npm. Triggered by the `v<version>` git tag | ||
| # that release-plz creates after a release PR is merged (see release-plz.yml). | ||
| # 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@v4 | ||
| with: | ||
| ref: ${{ steps.ref.outputs.ref }} | ||
| persist-credentials: false | ||
| fetch-depth: 1 | ||
|
|
||
| - name: Create GitHub App Token | ||
| id: app-token | ||
| uses: actions/create-github-app-token@v1 | ||
| with: | ||
| app-id: ${{ vars.BULLET_DEPLOY_APP_ID }} | ||
| private-key: ${{ secrets.BULLET_DEPLOY_KEY }} | ||
| owner: ${{ github.repository_owner }} | ||
|
|
||
| - 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: | ||
| github-app-token: ${{ steps.app-token.outputs.token }} | ||
| 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 --tag "$TAG" --access public | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,12 @@ | |
| members = ["rust", "wasm"] | ||
| resolver = "2" | ||
|
Contributor
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. We can upgrade this to 3 now with latest rust versions (we just moved to rust 1.94) |
||
|
|
||
| [workspace.package] | ||
| version = "0.0.9" | ||
|
cursor[bot] marked this conversation as resolved.
Outdated
|
||
| edition = "2024" | ||
| license = "MIT" | ||
| repository = "https://github.com/bulletxyz/bullet-rust-sdk" | ||
|
|
||
| [workspace.dependencies] | ||
| bon = "3.9.0" | ||
| bullet-exchange-interface = { version = "0.2", features = ["schema"] } | ||
|
|
||
| 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 | ||
|
|
||


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.
You should not need this if all outputs are public.