Skip to content

fix(inspector): make the Tracing domain protocol-correct and faster #246

fix(inspector): make the Tracing domain protocol-correct and faster

fix(inspector): make the Tracing domain protocol-correct and faster #246

Workflow file for this run

name: NPM Release
on:
push:
branches:
- main # -> prerelease published under the "next" dist-tag
tags:
- "v*" # -> release published under the "latest" dist-tag
workflow_dispatch:
inputs:
version:
description: "Release version to cut, e.g. 9.1.0 (creates tag v<version> and publishes 'latest'). Leave empty for a manual 'next' build."
required: false
default: ""
env:
NPM_TAG: "next"
EMULATOR_NAME: "runtime-emu"
NDK_VERSION: r29
CMAKE_VERSION: "3.31.6"
ANDROID_API: 33
ANDROID_ABI: x86_64
NDK_ARCH: linux
permissions:
contents: read
jobs:
build:
name: Build
runs-on: ubuntu-latest
outputs:
npm_version: ${{ steps.npm_version_output.outputs.NPM_VERSION }}
npm_tag: ${{ steps.npm_version_output.outputs.NPM_TAG }}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
submodules: true
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
with:
distribution: "temurin"
java-version: "21"
cache: gradle
- name: Setup Android SDK
uses: android-actions/setup-android@651bceb6f9ca583f16b8d75b62c36ded2ae6fc9c # v4.0.0
- name: Setup NDK
run: |
echo "y" | sdkmanager "cmake;$CMAKE_VERSION"
wget -q https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip
export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
- name: Setup ccache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.ccache
key: ccache-build-${{ github.sha }}
restore-keys: ccache-build-
- name: Configure build caches
run: |
command -v ccache || sudo apt-get install -y ccache
ccache --version
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
# the NDK is unzipped fresh every run, so mtime-based compiler
# identification (the default) would invalidate the whole cache
echo "CCACHE_COMPILERCHECK=content" >> $GITHUB_ENV
mkdir -p ~/.gradle
printf 'org.gradle.parallel=true\norg.gradle.caching=true\n' >> ~/.gradle/gradle.properties
- name: Install Dependencies
run: |
npm install
npm install --prefix ./test-app/tools
- name: Get Current Version
run: |
NPM_VERSION=$(node -e "console.log(require('./package.json').version);")
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
- name: Set manual release version
# manual dispatch with a version: cut tag v<input> and publish ('latest'
# unless the version is a prerelease)
if: ${{ inputs.version != '' }}
env:
INPUT_VERSION: ${{ inputs.version }}
run: |
NPM_VERSION="${INPUT_VERSION#v}"
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
npm version $NPM_VERSION --no-git-tag-version --allow-same-version
- name: Bump version for dev release
# branch push (main) or manual run without a version -> "next" prerelease
if: ${{ !contains(github.ref, 'refs/tags/') && inputs.version == '' }}
run: |
NPM_VERSION=$(node ./scripts/get-next-version.js)
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_ENV
npm version $NPM_VERSION --no-git-tag-version
- name: Output NPM Version and tag
id: npm_version_output
run: |
NPM_TAG=$(node ./scripts/get-npm-tag.js)
echo NPM_VERSION=$NPM_VERSION >> $GITHUB_OUTPUT
echo NPM_TAG=$NPM_TAG >> $GITHUB_OUTPUT
- name: Fetch prebuilt V8
run: ./download_v8.sh
- name: Build npm package
run: ./gradlew -PgitCommitVersion=${{ github.sha }} --stacktrace
- name: ccache stats
run: ccache -s
- name: Upload npm package artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: npm-package
path: dist/nativescript-android-${{steps.npm_version_output.outputs.NPM_VERSION}}.tgz
- name: Upload debug symbols
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: debug-symbols
path: test-app/runtime/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib/*
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
submodules: true
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- uses: actions/setup-java@03ad4de0992f5dab5e18fcb136590ce7c4a0ac95 # v5.6.0
with:
distribution: "temurin"
java-version: "21"
cache: gradle
- name: Setup Android SDK
uses: android-actions/setup-android@651bceb6f9ca583f16b8d75b62c36ded2ae6fc9c # v4.0.0
- name: Setup NDK
run: |
echo "y" | sdkmanager "cmake;$CMAKE_VERSION"
wget -q https://dl.google.com/android/repository/android-ndk-$NDK_VERSION-$NDK_ARCH.zip
chmod +x android-ndk-$NDK_VERSION-$NDK_ARCH.zip
unzip -q android-ndk-$NDK_VERSION-$NDK_ARCH.zip
rm -rf android-ndk-$NDK_VERSION-$NDK_ARCH.zip
export ANDROID_NDK_HOME=`pwd`/android-ndk-$NDK_VERSION
echo ANDROID_NDK_HOME=${ANDROID_NDK_HOME} >> $GITHUB_ENV
echo ANDROID_NDK=${ANDROID_NDK_HOME} >> $GITHUB_ENV
echo ${ANDROID_NDK_HOME} >> $GITHUB_PATH
- name: Setup ccache
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ~/.ccache
key: ccache-test-${{ github.sha }}
restore-keys: ccache-test-
- name: Configure build caches
# no org.gradle.caching here: the SBG AST tests spawn nested `gradlew -b`
# builds that fail with "Build cache controller already set" when the
# build cache is on
run: |
command -v ccache || sudo apt-get install -y ccache
ccache --version
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
# the NDK is unzipped fresh every run, so mtime-based compiler
# identification (the default) would invalidate the whole cache
echo "CCACHE_COMPILERCHECK=content" >> $GITHUB_ENV
mkdir -p ~/.gradle
printf 'org.gradle.parallel=true\n' >> ~/.gradle/gradle.properties
- name: Install Dependencies
run: |
npm install
npm install --prefix ./test-app/tools
- name: Fetch prebuilt V8
run: ./download_v8.sh
- name: SBG tests
run: ./gradlew runSbgTests --stacktrace
- name: Enable KVM
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
- name: Run unit tests
uses: ReactiveCircus/android-emulator-runner@a421e43855164a8197daf9d8d40fe71c6996bb0d # v2.38.0
with:
api-level: ${{env.ANDROID_API}}
# this is needed on API 30+
#target: google_apis
arch: ${{env.ANDROID_ABI}}
# only build native code for the ABI the emulator actually runs
script: ./gradlew runtestsAndVerifyResults -Pabis=${{env.ANDROID_ABI}} --stacktrace
- name: Upload Test Results
if: ${{ !cancelled() }} # run this step even if previous step failed
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: android-unit-test-results
path: test-app/dist/android_unit_test_results.xml
publish:
runs-on: ubuntu-latest
environment: npm-publish
needs:
- build
- test
permissions:
contents: read
id-token: write
env:
NPM_VERSION: ${{needs.build.outputs.npm_version}}
NPM_TAG: ${{needs.build.outputs.npm_tag}}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22
registry-url: "https://registry.npmjs.org"
- uses: actions/download-artifact@v8
with:
name: npm-package
path: dist
- name: Update npm (required for OIDC trusted publishing)
run: |
corepack enable npm
corepack install -g npm@11.5.1
test "$(npm --version)" = "11.5.1"
test "$(npx --version)" = "11.5.1"
- name: Publish package (OIDC trusted publishing)
if: ${{ vars.USE_NPM_TOKEN != 'true' }}
run: |
echo "Publishing @nativescript/android@$NPM_VERSION to NPM with tag $NPM_TAG via OIDC trusted publishing..."
unset NODE_AUTH_TOKEN
if [ -n "${NPM_CONFIG_USERCONFIG:-}" ]; then
rm -f "$NPM_CONFIG_USERCONFIG"
fi
npm publish ./dist/nativescript-android-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --access public --provenance
env:
NODE_AUTH_TOKEN: ""
- name: Publish package (granular token)
if: ${{ vars.USE_NPM_TOKEN == 'true' }}
run: |
echo "Publishing @nativescript/android@$NPM_VERSION to NPM with tag $NPM_TAG via granular token..."
npm publish ./dist/nativescript-android-${{env.NPM_VERSION}}.tgz --tag $NPM_TAG --access public --provenance
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
github-release:
runs-on: ubuntu-latest
# only runs on tagged commits, or a manual dispatch with a version (which
# creates tag v<version> itself via the release action below)
if: ${{ contains(github.ref, 'refs/tags/') || inputs.version != '' }}
permissions:
contents: write
needs:
- build
- test
env:
NPM_VERSION: ${{needs.build.outputs.npm_version}}
steps:
- name: Harden the runner (Audit all outbound calls)
uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: 22
- name: Setup
run: npm install
- uses: actions/download-artifact@v8
with:
name: npm-package
path: dist
- uses: actions/download-artifact@v8
with:
name: debug-symbols
path: dist/debug-symbols
- name: Zip debug symbols
working-directory: dist/debug-symbols
run: zip -r debug-symbols.zip .
- name: Partial Changelog
run: npx conventional-changelog -p angular -r2 > body.md
- uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0
with:
# explicit tag + commit so a manual dispatch (no pushed tag ref) creates
# tag v<version> at the dispatched commit; on tag pushes this resolves
# to the pushed tag itself
tag: "v${{ env.NPM_VERSION }}"
name: "v${{ env.NPM_VERSION }}"
commit: ${{ github.sha }}
artifacts: "dist/nativescript-android-*.tgz,dist/debug-symbols/debug-symbols.zip"
bodyFile: "body.md"
prerelease: ${{needs.build.outputs.npm_tag != 'latest'}}
allowUpdates: true