|
5 | 5 | - "v*" |
6 | 6 | workflow_dispatch: |
7 | 7 | 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 |
8 | 18 | dry_run: |
9 | 19 | description: "Run npm publish with --dry-run" |
10 | 20 | required: true |
11 | 21 | type: boolean |
12 | 22 | default: true |
13 | 23 |
|
14 | 24 | env: |
15 | | - EXPECTED_NPM_TAG: "napi-v8" |
16 | 25 | XCODE_VERSION: "26.2.0" |
17 | 26 |
|
18 | 27 | jobs: |
|
22 | 31 | outputs: |
23 | 32 | npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }} |
24 | 33 | npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }} |
| 34 | + build_engine: ${{ steps.npm_version_output.outputs.BUILD_ENGINE }} |
25 | 35 | steps: |
26 | 36 | - name: Harden the runner (Audit all outbound calls) |
27 | 37 | uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2 |
@@ -61,17 +71,48 @@ jobs: |
61 | 71 | fi |
62 | 72 | - name: Get Current Version |
63 | 73 | 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 |
65 | 91 | echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV |
66 | 92 | - name: Output NPM Version and tag |
67 | 93 | id: npm_version_output |
68 | 94 | 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 |
71 | 111 | echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT |
72 | 112 | echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT |
| 113 | + echo BUILD_ENGINE=$BUILD_ENGINE >> $GITHUB_OUTPUT |
73 | 114 | - name: Build |
74 | | - run: npm run build-ios |
| 115 | + run: ./scripts/build_all_ios.sh --${{ steps.npm_version_output.outputs.BUILD_ENGINE }} |
75 | 116 | - name: Upload npm package artifact |
76 | 117 | uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0 |
77 | 118 | with: |
|
0 commit comments