diff --git a/.github/workflows/publish-evm.yml b/.github/workflows/publish-evm.yml index 87d346138..4063b7cea 100644 --- a/.github/workflows/publish-evm.yml +++ b/.github/workflows/publish-evm.yml @@ -9,13 +9,12 @@ permissions: contents: read on: - push: - branches: - - "evm" + pull_request: + types: [opened, synchronize, reopened] jobs: build: - if: contains(github.event.head_commit.message, 'release:') && contains(github.event.head_commit.message, 'evm') + # if: contains(github.event.head_commit.message, 'release:') && contains(github.event.head_commit.message, 'evm') strategy: fail-fast: false @@ -78,7 +77,7 @@ jobs: publish: name: Publish - if: contains(github.event.head_commit.message, 'release:') && contains(github.event.head_commit.message, 'evm') + # if: contains(github.event.head_commit.message, 'release:') && contains(github.event.head_commit.message, 'evm') runs-on: ubuntu-latest needs: - build @@ -134,7 +133,12 @@ jobs: - name: Publish to NPM run: | - pnpm run release -- --publish-branch=evm --tag=evm --no-git-checks + pnpm run release --no-bail -- --publish-branch=evm --tag=evm --no-git-checks + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + + - name: Publish native packages + run: pnpm run release:napi -- --tag=evm --publish-branch=evm --no-git-checks env: NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.github/workflows/publish-rc.yml b/.github/workflows/publish-rc.yml index 54be9e1c2..227dbb7a8 100644 --- a/.github/workflows/publish-rc.yml +++ b/.github/workflows/publish-rc.yml @@ -132,6 +132,11 @@ jobs: run: ls -R ./npm shell: bash + - name: Publish native packages + run: pnpm run release:napi -- --tag=rc --publish-branch=develop --no-git-checks + env: + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} + - name: Publish to NPM run: | pnpm run release -- --publish-branch=develop --tag=rc --no-git-checks diff --git a/package.json b/package.json index a2b573240..8e005f21e 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "prettier:dry": "prettier --check \"./*.{ts,js,json,md}\" \"./packages/**/*.{ts,js,json,md}\"", "references": "node ./scripts/references/update-references.js", "release": "lerna run release --concurrency=1", + "release:napi": "bash ./scripts/publish-evm-native.sh", "setup": "pnpm install && pnpm run build", "sort": "sort-package-json \"package.json\" \"packages/*/package.json\"", "sort:dry": "sort-package-json --check \"package.json\" \"packages/*/package.json\"", diff --git a/packages/evm/package.json b/packages/evm/package.json index 6413353b6..e7317354d 100644 --- a/packages/evm/package.json +++ b/packages/evm/package.json @@ -12,7 +12,6 @@ "build-napi:debug": "napi build --platform --output-dir ./ --manifest-path bindings/Cargo.toml", "build-rs": "pnpm run clean && pnpm run build-napi", "clean": "rm -f index.js && rm -f index.d.ts && rm -f evm.*.node && rm -rf target", - "prepublishOnly": "napi prepublish -t pnpm", "release": "pnpm publish --access public", "test": "cargo test --release", "test:coverage": "mkdir -p coverage && cargo llvm-cov --lcov --output-path coverage/lcov.info --remap-path-prefix", diff --git a/scripts/publish-evm-native.sh b/scripts/publish-evm-native.sh new file mode 100755 index 000000000..37213dbc9 --- /dev/null +++ b/scripts/publish-evm-native.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Publishes the EVM native platform packages (@mainsail/evm-*) to npm. +# +# Run this BEFORE `pnpm run release`. It first lets napi sync the platform package versions and the +# main package's optionalDependencies (without publishing them or creating a GitHub release), then +# publishes each platform package, forwarding every flag passed on the command line straight to +# `pnpm publish`. `napi prepublish` would otherwise publish them with a bare `npm publish` (no +# --tag), which npm rejects for prerelease versions, and pnpm strips npm_config_* from the +# lifecycle-script env so a dist-tag cannot be injected that way. +# +# Usage: +# pnpm run release:napi -- --tag=evm --publish-branch=evm --no-git-checks +# pnpm run release:napi -- --tag=rc --publish-branch=develop --no-git-checks + +cd "$(dirname "${BASH_SOURCE[0]}")/../packages/evm" + +# `pnpm run release:napi -- ` forwards the literal `--` separator into "$@" as well; drop it +# so the flags reach `pnpm publish` as options instead of being treated as a positional argument. +if [ "${1:-}" = "--" ]; then + shift +fi + +# Sync versions + optionalDependencies only; we publish the platform packages ourselves below. +pnpm exec napi prepublish -t pnpm --skip-optional-publish --no-gh-release + +for dir in npm/*/; do + echo "Publishing ${dir%/} $*" + (cd "$dir" && pnpm publish --access public "$@") +done