Skip to content

Commit e4f289c

Browse files
ci: fix native package build (#1327)
* Add publish evm * Remove prepublish * Add release napi * Publish rc * Publish evm * Rename script * Pnpm lock * Publish native packages first * Add release prepare * Add prepare release * Remove empty lines * style: resolve style guide violations [ci-lint-fix] * Update lockfile only
1 parent 562429c commit e4f289c

6 files changed

Lines changed: 48 additions & 6 deletions

File tree

.github/workflows/publish-evm.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ jobs:
132132
run: ls -R ./npm
133133
shell: bash
134134

135+
- name: Prepare release
136+
run: pnpm run release:prepare && pnpm install --lockfile-only
137+
138+
- name: Publish native to NPM
139+
run: pnpm run release:native -- --publish-branch=evm --tag=evm --no-git-checks
140+
env:
141+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
142+
135143
- name: Publish to NPM
136144
run: |
137145
pnpm run release -- --publish-branch=evm --tag=evm --no-git-checks

.github/workflows/publish-rc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ jobs:
132132
run: ls -R ./npm
133133
shell: bash
134134

135+
- name: Prepare release
136+
run: pnpm run release:prepare && pnpm install --lockfile-only
137+
138+
- name: Publish native to NPM
139+
run: pnpm run release:native -- --publish-branch=develop --tag=rc --no-git-checks
140+
env:
141+
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
142+
135143
- name: Publish to NPM
136144
run: |
137145
pnpm run release -- --publish-branch=develop --tag=rc --no-git-checks

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
"prettier:dry": "prettier --check \"./*.{ts,js,json,md}\" \"./packages/**/*.{ts,js,json,md}\"",
3737
"references": "node ./scripts/references/update-references.js",
3838
"release": "lerna run release --concurrency=1",
39+
"release:native": "bash ./scripts/publish-evm-native.sh",
40+
"release:prepare": "lerna run release:prepare --scope=@mainsail/evm",
3941
"setup": "pnpm install && pnpm run build",
4042
"sort": "sort-package-json \"package.json\" \"packages/*/package.json\"",
4143
"sort:dry": "sort-package-json --check \"package.json\" \"packages/*/package.json\"",

packages/evm/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
"build-napi:debug": "napi build --platform --output-dir ./ --manifest-path bindings/Cargo.toml",
1313
"build-rs": "pnpm run clean && pnpm run build-napi",
1414
"clean": "rm -f index.js && rm -f index.d.ts && rm -f evm.*.node && rm -rf target",
15-
"prepublishOnly": "napi prepublish -t pnpm",
1615
"release": "pnpm publish --access public",
16+
"release:prepare": "napi prepublish -t pnpm --skip-optional-publish --no-gh-release",
1717
"test": "cargo test --release",
1818
"test:coverage": "mkdir -p coverage && cargo llvm-cov --lcov --output-path coverage/lcov.info --remap-path-prefix",
1919
"test:coverage:html": "mkdir -p coverage && cargo llvm-cov --html --output-dir coverage/ --remap-path-prefix",

pnpm-lock.yaml

Lines changed: 1 addition & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

scripts/publish-evm-native.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# Publishes the EVM native platform packages (@mainsail/evm-*) to npm.
5+
#
6+
# Run this BEFORE `pnpm run release`. It first lets napi sync the platform package versions and the
7+
# main package's optionalDependencies (without publishing them or creating a GitHub release), then
8+
# publishes each platform package, forwarding every flag passed on the command line straight to
9+
# `pnpm publish`. `napi prepublish` would otherwise publish them with a bare `npm publish` (no
10+
# --tag), which npm rejects for prerelease versions, and pnpm strips npm_config_* from the
11+
# lifecycle-script env so a dist-tag cannot be injected that way.
12+
#
13+
# Usage:
14+
# pnpm run release:napi -- --tag=evm --publish-branch=evm --no-git-checks
15+
# pnpm run release:napi -- --tag=rc --publish-branch=develop --no-git-checks
16+
17+
cd "$(dirname "${BASH_SOURCE[0]}")/../packages/evm"
18+
19+
# `pnpm run release:napi -- <flags>` forwards the literal `--` separator into "$@" as well; drop it
20+
# so the flags reach `pnpm publish` as options instead of being treated as a positional argument.
21+
if [ "${1:-}" = "--" ]; then
22+
shift
23+
fi
24+
25+
for dir in npm/*/; do
26+
echo "Publishing ${dir%/} $*"
27+
(cd "$dir" && pnpm publish --access public "$@")
28+
done

0 commit comments

Comments
 (0)