Skip to content

Commit 351e7c4

Browse files
committed
feat: add macOS support and enhance build scripts
- Introduced new build scripts for macOS, including `build_all_macos.sh` and `build_npm_macos.sh`, to streamline the build process for macOS applications. - Updated existing build scripts to integrate versioning into the runtime for iOS builds. - Enhanced metadata generation and packaging for Node-API, ensuring compatibility with macOS. - Improved handling of platform-specific configurations in the CMake setup and project templates. - Added CI workflows for npm releases and testing, ensuring robust build and deployment processes.
1 parent 7455e22 commit 351e7c4

38 files changed

+1654
-22
lines changed
Lines changed: 231 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,231 @@
1+
on:
2+
push:
3+
branches:
4+
- main
5+
tags:
6+
- "v*"
7+
8+
env:
9+
NPM_TAG: "next"
10+
XCODE_VERSION: "^15.0"
11+
12+
jobs:
13+
build:
14+
name: Build
15+
runs-on: macos-14
16+
outputs:
17+
npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }}
18+
npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }}
19+
steps:
20+
- name: Harden the runner (Audit all outbound calls)
21+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
22+
with:
23+
egress-policy: audit
24+
- uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
25+
with:
26+
xcode-version: ${{env.XCODE_VERSION}}
27+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
28+
with:
29+
fetch-depth: 0
30+
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
31+
with:
32+
node-version: 22
33+
registry-url: "https://registry.npmjs.org"
34+
- name: Install Python
35+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
36+
with:
37+
python-version: "3"
38+
- name: Install Dependencies
39+
run: |
40+
npm install
41+
python3 -m pip install --upgrade pip six
42+
# Ensure CMake is available without conflicting with pinned Homebrew formula
43+
if ! command -v cmake >/dev/null; then
44+
brew list cmake || brew install cmake
45+
fi
46+
# Some scripts expect cmake at /usr/local/bin; create a shim if needed
47+
if [ ! -x /usr/local/bin/cmake ]; then
48+
sudo mkdir -p /usr/local/bin
49+
sudo ln -sf "$(command -v cmake)" /usr/local/bin/cmake
50+
fi
51+
- name: Get Current Version
52+
run: |
53+
NPM_VERSION=$(node -e "console.log(require('./package.json').version);")
54+
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
55+
- name: Bump version for dev release
56+
if: ${{ !contains(github.ref, 'refs/tags/') }}
57+
run: |
58+
NPM_VERSION=$(node ./scripts/get-next-version.js)
59+
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
60+
npm version $NPM_VERSION --no-git-tag-version
61+
- name: Output NPM Version and tag
62+
id: npm_version_output
63+
run: |
64+
NPM_TAG=$(node ./scripts/get-npm-tag.js)
65+
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT
66+
echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT
67+
- name: Build
68+
run: npm run build-ios
69+
- name: Upload npm package artifact
70+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
71+
with:
72+
name: npm-package
73+
path: dist/nativescript-ios-${{steps.npm_version_output.outputs.NPM_VERSION}}.tgz
74+
- name: Upload dSYMs artifact
75+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
76+
with:
77+
name: NativeScript-dSYMs
78+
path: dist/dSYMs
79+
test:
80+
name: Test
81+
runs-on: macos-14
82+
needs: build
83+
steps:
84+
- name: Harden the runner (Audit all outbound calls)
85+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
86+
with:
87+
egress-policy: audit
88+
- uses: maxim-lobanov/setup-xcode@60606e260d2fc5762a71e64e74b2174e8ea3c8bd # v1.6.0
89+
with:
90+
xcode-version: ${{env.XCODE_VERSION}}
91+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
92+
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
93+
with:
94+
node-version: 22
95+
- name: Install Python
96+
uses: actions/setup-python@83679a892e2d95755f2dac6acb0bfd1e9ac5d548 # v6.1.0
97+
with:
98+
python-version: "3"
99+
- name: Install Dependencies
100+
run: |
101+
npm install
102+
python3 -m pip install --upgrade pip six
103+
# Ensure CMake is available without conflicting with pinned Homebrew formula
104+
if ! command -v cmake >/dev/null; then
105+
brew list cmake || brew install cmake
106+
fi
107+
# Some scripts expect cmake at /usr/local/bin; create a shim if needed
108+
if [ ! -x /usr/local/bin/cmake ]; then
109+
sudo mkdir -p /usr/local/bin
110+
sudo ln -sf "$(command -v cmake)" /usr/local/bin/cmake
111+
fi
112+
brew install chargepoint/xcparse/xcparse
113+
npm install -g @edusperoni/junit-cli-report-viewer verify-junit-xml
114+
- name: Prepare
115+
run: npm run setup-ci
116+
- name: Prepare test folder
117+
run: |
118+
mkdir -p dist-test
119+
echo TEST_FOLDER=$(pwd)/dist-test >> $GITHUB_ENV
120+
- name: Xcode Tests
121+
uses: nick-fields/retry@ce71cc2ab81d554ebbe88c79ab5975992d79ba08 # v3.0.2
122+
# try to run the tests with xcpretty. If it fails then try again without xcpretty twice for better log output
123+
# the xcode tests are a bit flaky and they should never fail on this step, as this step only collects the JS test results as junit xml
124+
with:
125+
timeout_minutes: 20
126+
max_attempts: 2
127+
command: set -o pipefail && xcodebuild -project v8ios.xcodeproj -scheme TestRunner -resultBundlePath $TEST_FOLDER/test_results -destination platform\=iOS\ Simulator,OS\=17.2,name\=iPhone\ 15\ Pro\ Max build test | xcpretty
128+
on_retry_command: rm -rf $TEST_FOLDER/test_results* && xcrun simctl shutdown all
129+
new_command_on_retry: xcodebuild -project v8ios.xcodeproj -scheme TestRunner -resultBundlePath $TEST_FOLDER/test_results -destination platform\=iOS\ Simulator,OS\=17.2,name\=iPhone\ 15\ Pro\ Max build test
130+
- name: Validate Test Results
131+
run: |
132+
xcparse attachments $TEST_FOLDER/test_results.xcresult $TEST_FOLDER/test-out
133+
find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx junit-cli-report-viewer
134+
find $TEST_FOLDER/test-out -name "*junit*.xml" -maxdepth 1 -print0 | xargs -n 1 -0 npx verify-junit-xml
135+
- name: Archive Test Result Data
136+
if: always()
137+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
138+
with:
139+
name: test-results
140+
path: ${{env.TEST_FOLDER}}/test_results.xcresult
141+
publish:
142+
runs-on: ubuntu-latest
143+
environment: npm-publish
144+
needs:
145+
- build
146+
- test
147+
permissions:
148+
contents: read
149+
id-token: write
150+
env:
151+
NPM_VERSION: ${{needs.build.outputs.npm_version}}
152+
NPM_TAG: ${{needs.build.outputs.npm_tag}}
153+
steps:
154+
- name: Harden the runner (Audit all outbound calls)
155+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
156+
with:
157+
egress-policy: audit
158+
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
159+
with:
160+
node-version: 22
161+
registry-url: "https://registry.npmjs.org"
162+
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
163+
with:
164+
name: npm-package
165+
path: dist
166+
- name: Update npm (required for OIDC trusted publishing)
167+
run: |
168+
npm install -g npm@^11.5.1
169+
npm --version
170+
- name: Publish package (OIDC trusted publishing)
171+
if: ${{ vars.USE_NPM_TOKEN != 'true' }}
172+
run: |
173+
echo "Publishing @nativescript/ios@$NPM_VERSION to NPM with tag $NPM_TAG via OIDC trusted publishing..."
174+
unset NODE_AUTH_TOKEN
175+
if [ -n "${NPM_CONFIG_USERCONFIG:-}" ]; then
176+
rm -f "$NPM_CONFIG_USERCONFIG"
177+
fi
178+
npm publish ./dist/nativescript-ios-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --access public --provenance
179+
env:
180+
NODE_AUTH_TOKEN: ""
181+
182+
- name: Publish package (granular token)
183+
if: ${{ vars.USE_NPM_TOKEN == 'true' }}
184+
run: |
185+
echo "Publishing @nativescript/ios@$NPM_VERSION to NPM with tag $NPM_TAG via granular token..."
186+
npm publish ./dist/nativescript-ios-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --access public --provenance
187+
env:
188+
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
189+
github-release:
190+
runs-on: ubuntu-latest
191+
# only runs on tagged commits
192+
if: ${{ contains(github.ref, 'refs/tags/') }}
193+
permissions:
194+
contents: write
195+
needs:
196+
- build
197+
- test
198+
env:
199+
NPM_VERSION: ${{needs.build.outputs.npm_version}}
200+
steps:
201+
- name: Harden the runner (Audit all outbound calls)
202+
uses: step-security/harden-runner@95d9a5deda9de15063e7595e9719c11c38c90ae2 # v2.13.2
203+
with:
204+
egress-policy: audit
205+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
206+
with:
207+
fetch-depth: 0
208+
- uses: actions/setup-node@2028fbc5c25fe9cf00d9f06a71cc4710d4507903 # v6.0.0
209+
with:
210+
node-version: 22
211+
- name: Setup
212+
run: npm install
213+
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
214+
with:
215+
name: npm-package
216+
path: dist
217+
- uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
218+
with:
219+
name: NativeScript-dSYMs
220+
path: dist/dSYMs
221+
- name: Zip dSYMs
222+
working-directory: dist/dSYMs
223+
run: find . -maxdepth 1 -name '*.dSYM' -print | xargs -I@ zip -r @.zip @
224+
- name: Partial Changelog
225+
run: npx conventional-changelog -p angular -r2 > body.md
226+
- uses: ncipollo/release-action@b7eabc95ff50cbeeedec83973935c8f306dfcd0b # v1.20.0
227+
with:
228+
artifacts: "dist/nativescript-ios-*.tgz,dist/dSYMs/*.zip"
229+
bodyFile: "body.md"
230+
prerelease: ${{needs.build.outputs.npm_tag != 'latest'}}
231+
allowUpdates: true

0 commit comments

Comments
 (0)