Skip to content

Commit d2f83f0

Browse files
committed
ci: parameterize ios engine release dry runs
1 parent db5f595 commit d2f83f0

1 file changed

Lines changed: 46 additions & 5 deletions

File tree

.github/workflows/npm_release.yml

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,23 @@ on:
55
- "v*"
66
workflow_dispatch:
77
inputs:
8+
engine:
9+
description: "Runtime engine to build and dry-run publish"
10+
required: true
11+
type: choice
12+
default: v8
13+
options:
14+
- v8
15+
- quickjs
16+
- hermes
17+
- jsc
818
dry_run:
919
description: "Run npm publish with --dry-run"
1020
required: true
1121
type: boolean
1222
default: true
1323

1424
env:
15-
EXPECTED_NPM_TAG: "napi-v8"
1625
XCODE_VERSION: "26.2.0"
1726

1827
jobs:
@@ -22,6 +31,7 @@ jobs:
2231
outputs:
2332
npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }}
2433
npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }}
34+
build_engine: ${{ steps.npm_version_output.outputs.BUILD_ENGINE }}
2535
steps:
2636
- name: Harden the runner (Audit all outbound calls)
2737
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
@@ -61,17 +71,48 @@ jobs:
6171
fi
6272
- name: Get Current Version
6373
run: |
64-
NPM_VERSION=$(node -e "console.log(require('./packages/ios/package.json').version);")
74+
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
75+
ENGINE="${{ inputs.engine }}"
76+
NPM_VERSION=$(node -e "
77+
const semver = require('semver');
78+
const engine = process.argv[1];
79+
const pkg = require('./packages/ios/package.json');
80+
const parsed = semver.parse(pkg.version);
81+
if (!parsed) {
82+
throw new Error('Invalid package version: ' + pkg.version);
83+
}
84+
const number = Number.isInteger(parsed.prerelease[1]) ? parsed.prerelease[1] : 1;
85+
console.log(parsed.format().replace(/-.*/, '') + '-napi-' + engine + '.' + number);
86+
" "$ENGINE")
87+
PACKAGE_VERSION="$NPM_VERSION" ./scripts/update_version.sh ios
88+
else
89+
NPM_VERSION=$(node -e "console.log(require('./packages/ios/package.json').version);")
90+
fi
6591
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
6692
- name: Output NPM Version and tag
6793
id: npm_version_output
6894
run: |
69-
NPM_TAG=$(node ./scripts/get-npm-tag.js ios)
70-
test "$NPM_TAG" = "$EXPECTED_NPM_TAG"
95+
NPM_TAG=$(NPM_VERSION="$NPM_VERSION" node ./scripts/get-npm-tag.js ios)
96+
case "$NPM_TAG" in
97+
napi-v8) BUILD_ENGINE=v8 ;;
98+
napi-quickjs) BUILD_ENGINE=quickjs ;;
99+
napi-hermes) BUILD_ENGINE=hermes ;;
100+
napi-jsc) BUILD_ENGINE=jsc ;;
101+
latest) BUILD_ENGINE=v8 ;;
102+
*)
103+
echo "Unsupported npm tag '$NPM_TAG'. Expected latest or napi-{v8,quickjs,hermes,jsc}." >&2
104+
exit 1
105+
;;
106+
esac
107+
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ] && [ "$BUILD_ENGINE" != "${{ inputs.engine }}" ]; then
108+
echo "Selected engine '${{ inputs.engine }}' does not match package tag '$NPM_TAG'." >&2
109+
exit 1
110+
fi
71111
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT
72112
echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT
113+
echo BUILD_ENGINE=$BUILD_ENGINE >> $GITHUB_OUTPUT
73114
- name: Build
74-
run: npm run build-ios
115+
run: ./scripts/build_all_ios.sh --${{ steps.npm_version_output.outputs.BUILD_ENGINE }}
75116
- name: Upload npm package artifact
76117
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
77118
with:

0 commit comments

Comments
 (0)