Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
130 changes: 25 additions & 105 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
name: CI
on:
push:
branches: [main]
branches: [main, "release/**"]
pull_request:
branches: [main]
branches: [main, "release/**"]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

# All React Native jobs run on the org/repo self-hosted runner.
# Runner should have: Node (see .nvmrc), Yarn, JDK 17+, Android SDK ($ANDROID_HOME).
# Public repo: GitHub-hosted runners (free for open source).

jobs:
lint:
runs-on: self-hosted
runs-on: ubuntu-latest

steps:
- name: Checkout
Expand All @@ -31,7 +30,7 @@ jobs:
run: yarn typecheck

test:
runs-on: self-hosted
runs-on: ubuntu-latest

steps:
- name: Checkout
Expand All @@ -45,7 +44,7 @@ jobs:

security-audit:
name: Security audit
runs-on: self-hosted
runs-on: ubuntu-latest

steps:
- name: Checkout
Expand All @@ -60,7 +59,7 @@ jobs:
run: yarn npm audit --recursive --all --severity high

build-library:
runs-on: self-hosted
runs-on: ubuntu-latest

steps:
- name: Checkout
Expand All @@ -73,37 +72,19 @@ jobs:
run: yarn prepare

build-android:
runs-on: self-hosted
# Google Linux aapt2 is x86_64-only. On ARM64 self-hosted runners the native
# example build cannot run; skip successfully and keep JS quality gates green.
# To enable this job, register an x86_64 self-hosted runner and change to:
# runs-on: [self-hosted, X64]
runs-on: ubuntu-latest

env:
TURBO_CACHE_DIR: .turbo/android

steps:
- name: Check runner architecture
id: arch
run: |
echo "runner_arch=${{ runner.arch }}"
if [[ "${{ runner.arch }}" == "ARM64" ]]; then
echo "::warning::Skipping Android native build on ARM64. aapt2 is x86_64-only. Add a self-hosted X64 runner labeled X64 to run this job."
echo "skip=true" >> "$GITHUB_OUTPUT"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
fi

- name: Checkout
if: steps.arch.outputs.skip != 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1

- name: Setup
if: steps.arch.outputs.skip != 'true'
uses: ./.github/actions/setup

- name: Cache turborepo for Android
if: steps.arch.outputs.skip != 'true'
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: ${{ env.TURBO_CACHE_DIR }}
Expand All @@ -112,109 +93,51 @@ jobs:
${{ runner.os }}-turborepo-android-

- name: Check turborepo cache for Android
if: steps.arch.outputs.skip != 'true'
run: |
TURBO_CACHE_STATUS=$(node -p "($(yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}" --dry=json)).tasks.find(t => t.task === 'build:android').cache.status")

if [[ $TURBO_CACHE_STATUS == "HIT" ]]; then
echo "turbo_cache_hit=1" >> $GITHUB_ENV
echo "turbo_cache_hit=1" >> "$GITHUB_ENV"
fi

- name: Ensure JDK
if: steps.arch.outputs.skip != 'true' && env.turbo_cache_hit != 1
- name: Setup JDK
if: env.turbo_cache_hit != 1
uses: actions/setup-java@d1374f8ac74474200d16ef8ecee22c7ae7a51880 # v6.3.0
with:
distribution: 'zulu'
java-version: '17'

- name: Ensure Android SDK
if: steps.arch.outputs.skip != 'true' && env.turbo_cache_hit != 1
- name: Configure Android SDK (preinstalled on ubuntu-latest)
if: env.turbo_cache_hit != 1
run: |
set -euo pipefail
# Empty proxy strings on this runner break sdkmanager URL parsing.
unset HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy || true

SDK_ROOT=""
if [[ -n "${ANDROID_HOME:-}" && -d "${ANDROID_HOME}" ]]; then
SDK_ROOT="${ANDROID_HOME}"
elif [[ -n "${ANDROID_SDK_ROOT:-}" && -d "${ANDROID_SDK_ROOT}" ]]; then
SDK_ROOT="${ANDROID_SDK_ROOT}"
else
for candidate in \
"${HOME}/.android/sdk" \
"${HOME}/Android/Sdk" \
/opt/android-sdk \
/usr/lib/android-sdk \
/usr/local/lib/android/sdk
do
if [[ -d "$candidate" ]]; then
SDK_ROOT="$candidate"
break
fi
done
fi

if [[ -z "$SDK_ROOT" ]]; then
SDK_ROOT="${HOME}/.android/sdk"
mkdir -p "$SDK_ROOT"
fi

# GitHub-hosted Ubuntu images ship an Android SDK; avoid setup-android's
# obsolete `tools` package install.
SDK_ROOT="${ANDROID_HOME:-${ANDROID_SDK_ROOT:-/usr/local/lib/android/sdk}}"
echo "ANDROID_HOME=${SDK_ROOT}" >> "$GITHUB_ENV"
echo "ANDROID_SDK_ROOT=${SDK_ROOT}" >> "$GITHUB_ENV"
export ANDROID_HOME="$SDK_ROOT"
export ANDROID_SDK_ROOT="$SDK_ROOT"
echo "Using ANDROID_HOME=${SDK_ROOT}"

find_sdkmanager() {
if [[ -x "${SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager" ]]; then
echo "${SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager"
return 0
fi
find "${SDK_ROOT}/cmdline-tools" -type f -name sdkmanager 2>/dev/null | head -1 || true
}

SDKMANAGER="$(find_sdkmanager)"
if [[ -z "$SDKMANAGER" ]]; then
echo "Installing Android cmdline-tools..."
TMP="$(mktemp -d)"
curl -fsSL -o "$TMP/cmdline-tools.zip" \
https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
unzip -q "$TMP/cmdline-tools.zip" -d "$TMP"
mkdir -p "${SDK_ROOT}/cmdline-tools/latest"
cp -R "$TMP"/cmdline-tools/. "${SDK_ROOT}/cmdline-tools/latest/"
rm -rf "$TMP"
SDKMANAGER="$(find_sdkmanager)"
SDKMANAGER="$(find "${SDK_ROOT}/cmdline-tools" -type f -name sdkmanager 2>/dev/null | head -1 || true)"
if [[ -z "$SDKMANAGER" && -x "${SDK_ROOT}/tools/bin/sdkmanager" ]]; then
SDKMANAGER="${SDK_ROOT}/tools/bin/sdkmanager"
fi

if [[ -z "$SDKMANAGER" ]]; then
echo "sdkmanager still missing under ${SDK_ROOT}" >&2
echo "sdkmanager not found under ${SDK_ROOT}" >&2
exit 1
fi

yes | "$SDKMANAGER" --sdk_root="${SDK_ROOT}" --licenses >/dev/null || true

install_pkg() {
local pkg="$1"
echo "Installing ${pkg}..."
if "$SDKMANAGER" --sdk_root="${SDK_ROOT}" --install "${pkg}"; then
return 0
fi
echo "Warning: failed to install ${pkg}" >&2
return 1
}

install_pkg "platform-tools" || true
install_pkg "build-tools;37.0.0" || install_pkg "build-tools;36.1.0" || install_pkg "build-tools;36.0.0" || true
if ! install_pkg "platforms;android-37"; then
install_pkg "platforms;android-36" || true
fi
"$SDKMANAGER" --sdk_root="${SDK_ROOT}" --install "platform-tools" || true
"$SDKMANAGER" --sdk_root="${SDK_ROOT}" --install "platforms;android-36" "build-tools;36.0.0"

mkdir -p example/android
echo "sdk.dir=${SDK_ROOT}" > example/android/local.properties
echo "sdk.dir=${SDK_ROOT}" > android/local.properties || true
echo "sdk.dir=${SDK_ROOT}" > android/local.properties

- name: Cache Gradle
if: steps.arch.outputs.skip != 'true' && env.turbo_cache_hit != 1
if: env.turbo_cache_hit != 1
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: |
Expand All @@ -225,9 +148,6 @@ jobs:
${{ runner.os }}-gradle-

- name: Build example for Android
if: steps.arch.outputs.skip != 'true'
env:
JAVA_OPTS: "-XX:MaxHeapSize=6g"
run: |
unset HTTP_PROXY HTTPS_PROXY ALL_PROXY http_proxy https_proxy all_proxy || true
yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
run: yarn turbo run build:android --cache-dir="${{ env.TURBO_CACHE_DIR }}"
9 changes: 5 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
name: CodeQL

# Disabled on pull_request/push until GitHub Advanced Security is enabled
# for this private repo (code scanning upload otherwise fails the check).
on:
push:
branches: [main, "release/**"]
pull_request:
branches: [main, "release/**"]
schedule:
- cron: '0 6 * * 1'
workflow_dispatch:
Expand All @@ -14,8 +16,7 @@ concurrency:
jobs:
analyze:
name: Analyze
runs-on: self-hosted
continue-on-error: true
runs-on: ubuntu-latest
permissions:
security-events: write
contents: read
Expand Down
107 changes: 107 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
name: Release

# Build, attach GitHub Release .tgz, and publish to GitHub Packages
# (npm.pkg.github.com). Does NOT publish to registry.npmjs.org.

on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
tag:
description: 'Existing tag to build/upload/publish (e.g. v0.3.3). Leave empty to use package.json version.'
required: false
type: string

permissions:
contents: write
packages: write

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
release:
name: Build, GitHub Release & Packages
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
ref: ${{ github.event_name == 'workflow_dispatch' && (inputs.tag || github.ref) || github.ref }}
fetch-depth: 0

- name: Setup
uses: ./.github/actions/setup

- name: Resolve version
id: meta
run: |
set -euo pipefail
VERSION="$(node -p "require('./package.json').version")"
NAME="$(node -p "require('./package.json').name")"
if [[ "${{ github.event_name }}" == "push" ]]; then
TAG="${GITHUB_REF_NAME}"
elif [[ -n "${{ inputs.tag }}" ]]; then
TAG="${{ inputs.tag }}"
else
TAG="v${VERSION}"
fi
# yarn pack replaces / with - but keeps @ in scoped package filenames
ASSET_NAME="${NAME//\//-}-${VERSION}.tgz"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "name=${NAME}" >> "$GITHUB_OUTPUT"
echo "asset=${ASSET_NAME}" >> "$GITHUB_OUTPUT"
echo "Resolved tag=${TAG} name=${NAME} version=${VERSION} asset=${ASSET_NAME}"

- name: Build package (bob + plugin)
run: yarn prepare

- name: Pack tarball
run: |
set -euo pipefail
yarn pack --out "${{ steps.meta.outputs.asset }}"
ls -lh "${{ steps.meta.outputs.asset }}"

- name: Ensure GitHub Release exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="${{ steps.meta.outputs.tag }}"
if gh release view "$TAG" >/dev/null 2>&1; then
echo "Release ${TAG} already exists"
else
gh release create "$TAG" \
--title "$TAG" \
--generate-notes \
--verify-tag \
--latest=false
fi

- name: Upload release assets
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
TAG="${{ steps.meta.outputs.tag }}"
ASSET="${{ steps.meta.outputs.asset }}"
gh release upload "$TAG" "$ASSET" --clobber
echo "Uploaded ${ASSET} to ${TAG}"

- name: Publish to GitHub Packages
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
{
echo "@solutionforest:registry=https://npm.pkg.github.com"
echo "//npm.pkg.github.com/:_authToken=${NODE_AUTH_TOKEN}"
} > .npmrc
# Maintenance line: keep `latest` dist-tag on main's 0.3.x.
npm publish --access public --tag release-0.2 --registry=https://npm.pkg.github.com
echo "Published ${{ steps.meta.outputs.name }}@${{ steps.meta.outputs.version }} to GitHub Packages (dist-tag release-0.2)"
15 changes: 3 additions & 12 deletions .github/workflows/version-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
jobs:
check:
name: Check upstream & library versions
runs-on: self-hosted
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
Expand All @@ -27,17 +27,8 @@ jobs:
with:
node-version-file: .nvmrc

- name: Ensure ripgrep
run: |
if command -v rg >/dev/null 2>&1; then
exit 0
fi
if command -v apt-get >/dev/null 2>&1; then
sudo apt-get update && sudo apt-get install -y ripgrep
exit 0
fi
echo "ripgrep (rg) must be installed on the self-hosted runner" >&2
exit 1
- name: Install ripgrep
run: sudo apt-get update && sudo apt-get install -y ripgrep

- name: Check versions and open upgrade reminder
env:
Expand Down
5 changes: 5 additions & 0 deletions .npmrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copy to your app's .npmrc (or ~/.npmrc) to install from GitHub Packages.
# Create a classic PAT with read:packages (authorize SSO for solutionforest if needed).

@solutionforest:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT
Loading
Loading