1+ on :
2+ workflow_dispatch :
3+ inputs :
4+ publish :
5+ description : ' If true, run publish after build (default: false)'
6+ required : false
7+ default : ' false'
8+ run_tests :
9+ description : ' If true, run gradle runtestsAndVerifyResults before builds (default: false)'
10+ required : false
11+ default : ' false'
12+ custom_version :
13+ description : ' Optional custom NPM version (overrides computed version).'
14+ required : false
15+ default : ' '
16+ enable_HERMES :
17+ description : ' Enable HERMES in the matrix'
18+ required : false
19+ default : ' true'
20+ enable_V8 :
21+ description : ' Enable V8 in the matrix'
22+ required : false
23+ default : ' true'
24+ enable_QUICKS :
25+ description : ' Enable QUICKS in the matrix'
26+ required : false
27+ default : ' true'
28+ enable_JSC :
29+ description : ' Enable JSC in the matrix'
30+ required : false
31+ default : ' true'
32+
33+ jobs :
34+ set-matrix :
35+ name : Build matrix from inputs
36+ runs-on : ubuntu-latest
37+ outputs :
38+ matrix : ${{ steps.emit.outputs.matrix }}
39+ steps :
40+ - name : Emit matrix JSON
41+ id : emit
42+ run : |
43+ set -e
44+ # Build the engine list based on workflow dispatch inputs.
45+ engines=()
46+ if [ "${{ github.event.inputs.enable_HERMES }}" != "false" ]; then engines+=("HERMES"); fi
47+ if [ "${{ github.event.inputs.enable_V8 }}" != "false" ]; then engines+=("V8"); fi
48+ if [ "${{ github.event.inputs.enable_QUICKS }}" != "false" ]; then engines+=("QUICKS"); fi
49+ if [ "${{ github.event.inputs.enable_JSC }}" != "false" ]; then engines+=("JSC"); fi
50+
51+ # If user disabled everything, fall back to a safe default (all engines).
52+ if [ ${#engines[@]} -eq 0 ]; then
53+ echo "All engines were disabled; defaulting to all engines."
54+ engines=(HERMES V8 QUICKS JSC)
55+ fi
56+
57+ # Build a JSON array string like ["HERMES","V8"]
58+ json="["
59+ for e in "${engines[@]}"; do
60+ json="${json}\"${e}\","
61+ done
62+ json="${json%,}" # remove trailing comma
63+ json="${json}]"
64+
65+ echo "Computed matrix JSON: $json"
66+ echo "matrix=$json" >> $GITHUB_OUTPUT
67+
68+ engine :
69+ name : Test · Build · Publish (engine=${{ matrix.engine }})
70+ needs : set-matrix
71+ runs-on : ubuntu-latest
72+ strategy :
73+ fail-fast : false
74+ matrix :
75+ # fromJson converts the JSON string emitted by set-matrix into the matrix array
76+ engine : ${{ fromJson(needs.set-matrix.outputs.matrix) }}
77+ env :
78+ JS_PARSER_DIR : test-app/build-tools/jsparser
79+ ENGINE : ${{ matrix.engine }}
80+ steps :
81+ - name : Checkout
82+ uses : actions/checkout@v4
83+ with :
84+ fetch-depth : 0
85+ persist-credentials : true
86+
87+ - name : Setup Node.js 18
88+ uses : actions/setup-node@v4
89+ with :
90+ node-version : 18
91+
92+ - name : set up JDK 17
93+ uses : actions/setup-java@v4
94+ with :
95+ java-version : ' 17'
96+ distribution : ' temurin'
97+
98+ - name : Restore npm cache for jsparser
99+ uses : actions/cache@v4
100+ with :
101+ path : |
102+ ~/.npm
103+ ${{ github.workspace }}/${{ env.JS_PARSER_DIR }}/node_modules
104+ key : ${{ runner.os }}-node-${{ hashFiles('test-app/build-tools/jsparser/package-lock.json') }}
105+ restore-keys : |
106+ ${{ runner.os }}-node-
107+
108+ - name : Install dependencies (jsparser)
109+ working-directory : ${{ env.JS_PARSER_DIR }}
110+ run : npm ci
111+
112+ - name : Grant execute permission for gradlew
113+ run : chmod +x gradlew
114+
115+ - name : Run runSbgTests (no emulator) for ${{ matrix.engine }}
116+ if : ${{ github.event.inputs.run_tests == 'true' }}
117+ run : |
118+ echo "Running runSbgTests with ENGINE=${ENGINE}"
119+ ./gradlew -Pengine="${ENGINE}" runSbgTests
120+ env :
121+ ENGINE : ${{ matrix.engine }}
122+
123+ - name : Run runtestsAndVerifyResults inside emulator for ${{ matrix.engine }}
124+ if : ${{ github.event.inputs.run_tests == 'true' }}
125+ uses : reactivecircus/android-emulator-runner@v2
126+ with :
127+ api-level : 35
128+ arch : x86_64
129+ target : google_apis
130+ emulator-options : -no-window
131+ script : |
132+ echo "Running runtestsAndVerifyResults with ENGINE=${ENGINE}"
133+ ./gradlew -Pengine="${ENGINE}" runtestsAndVerifyResults
134+ env :
135+ ENGINE : ${{ matrix.engine }}
136+
137+ - name : Build with engine ${{ matrix.engine }}
138+ run : |
139+ echo "Building with ENGINE=${ENGINE}"
140+ ./gradlew -Pengine="${ENGINE}"
141+ env :
142+ ENGINE : ${{ matrix.engine }}
143+
144+ - name : Publish tarball (or add dist-tag if version already exists)
145+ id : npm_publish
146+ run : |
147+ set -e
148+ eng_lc="${ENG_LC}"
149+ TARBALL="${TARBALL:-dist-${eng_lc}-${NPM_VERSION}.tgz}"
150+ TAG="${eng_lc}-${NPM_VERSION}"
151+ echo "Publishing tarball $TARBALL with npm tag $TAG (package version: $NPM_VERSION)..."
152+ echo "//registry.npmjs.org/:_authToken=${NODE_AUTH_TOKEN}" > .npmrc
153+
154+ if npm publish "$TARBALL" --tag "$TAG" --provenance --access public; then
155+ echo "npm publish succeeded for $TARBALL"
156+ echo "PUBLISHED=true" >> $GITHUB_ENV
157+ else
158+ echo "npm publish failed; attempting to add dist-tag pointing to existing version"
159+ npm dist-tag add @nativescript/android@"${NPM_VERSION}" "${TAG}"
160+ echo "DIST_TAG_ADDED=true" >> $GITHUB_ENV
161+ fi
162+ env :
163+ NODE_AUTH_TOKEN : ${{ secrets.NPM_PUBLISH_TOKEN }}
164+ NPM_VERSION : ${{ env.NPM_VERSION }}
165+ ENG_LC : ${{ env.ENG_LC }}
166+ TARBALL : ${{ env.TARBALL }}
167+
168+ - name : Create and push git tag for engine/version
169+ if : always()
170+ id : tag_release
171+ run : |
172+ set -e
173+ eng_lc="${ENG_LC}"
174+ TAG_NAME="${eng_lc}-v${NPM_VERSION}"
175+ echo "Creating tag $TAG_NAME"
176+ git config user.name "github-actions[bot]"
177+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
178+ if git rev-parse --verify "$TAG_NAME" >/dev/null 2>&1; then
179+ git tag -d "$TAG_NAME" || true
180+ fi
181+ git tag -a "$TAG_NAME" -m "Release ${TAG_NAME}"
182+ git push origin "refs/tags/${TAG_NAME}" || true
183+ echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
184+
185+ - name : Update CHANGELOG
186+ id : changelog
187+ uses : requarks/changelog-action@v1
188+ with :
189+ useGitmojis : false
190+ excludeTypes : build,docs,other,style,chore,perf,doc
191+ token : ${{ secrets.GITHUB_TOKEN }}
192+ tag : v${{ env.TAG_NAME }}
193+ writeToFile : false
194+
195+ - name : Create GitHub release for engine
196+ uses : actions/create-release@v1
197+ if : always()
198+ with :
199+ tag_name : ${{ env.TAG_NAME }}
200+ release_name : ${{ env.ENGINE }} ${{ env.NPM_VERSION }}
201+ body : ${{ steps.changelog.outputs.changes }}
202+ draft : false
203+ prerelease : ${{ contains(env.NPM_VERSION, '-dev') }}
204+ env :
205+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
206+ ENGINE : ${{ matrix.engine }}
207+ NPM_VERSION : ${{ env.NPM_VERSION }}
208+
209+ - name : Final status print
210+ run : |
211+ echo "Engine: ${ENGINE}"
212+ echo "NPM_VERSION: ${NPM_VERSION}"
213+ echo "Published: ${PUBLISHED:-false}"
214+ echo "Dist-tag added: ${DIST_TAG_ADDED:-false}"
215+ echo "Tag created: ${TAG_NAME:-none}"
216+ env :
217+ PUBLISHED : ${{ env.PUBLISHED }}
218+ DIST_TAG_ADDED : ${{ env.DIST_TAG_ADDED }}
219+ TAG_NAME : ${{ env.TAG_NAME }}
0 commit comments