Skip to content
26 changes: 15 additions & 11 deletions .github/workflows/cli-package-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,20 @@ jobs:
echo "checkout_ref=$CHECKOUT_REF" >> "$GITHUB_OUTPUT"
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"

web-ui:
name: CLI Web UI
needs: prepare
uses: ./.github/workflows/cli-web-ui.yml
with:
checkout_ref: ${{ needs.prepare.outputs.checkout_ref }}
artifact_name: cli-manual-web-ui

build:
name: Build (${{ matrix.platform.name }})
runs-on: ${{ matrix.platform.os }}
needs: prepare
needs: [prepare, web-ui]
env:
OPENBITFUN_CLI_WEB_UI_DIR: ${{ github.workspace }}/target/cli-release-web-ui

strategy:
fail-fast: false
Expand Down Expand Up @@ -167,17 +177,11 @@ jobs:
shared-key: "cli-manual-v1-${{ matrix.platform.name }}"
cache-bin: false

- name: Setup Node.js
uses: actions/setup-node@v5
- name: Download the shared CLI web UI
uses: actions/download-artifact@v7
with:
node-version-file: package.json
package-manager-cache: false

- name: Build the CLI's web UI
# Browsers load the web UI from the device they control, so the CLI
# embeds the one built from this commit (src/apps/cli/build.rs).
shell: bash
run: node scripts/ci/build-cli-web-ui.mjs
name: cli-manual-web-ui
path: target/cli-release-web-ui

- name: Build CLI (Unix)
if: runner.os != 'Windows'
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/cli-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,17 @@ jobs:
shared-key: "cli-v1-${{ matrix.platform.name }}"
cache-bin: false

- name: Setup pnpm
uses: pnpm/action-setup@v6

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version-file: package.json
package-manager-cache: false
cache: pnpm

- name: Install web UI dependencies
run: pnpm install --frozen-lockfile

- name: Build the CLI's web UI
# Browsers load the web UI from the device they control, so the CLI
Expand Down
63 changes: 63 additions & 0 deletions .github/workflows/cli-web-ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: CLI Web UI

on:
workflow_call:
inputs:
checkout_ref:
required: true
type: string
version:
type: string
artifact_name:
required: true
type: string

permissions:
contents: read

jobs:
build:
name: Build CLI Web UI
# The pinned NSH CLI requires glibc 2.39. Its output is portable to the
# older Linux runners that compile the CLI and Relay release binaries.
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- uses: actions/checkout@v5
with:
ref: ${{ inputs.checkout_ref }}

- uses: pnpm/action-setup@v6

- uses: actions/setup-node@v5
with:
node-version-file: package.json
cache: pnpm

- uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-unknown-unknown

- name: Install LLVM tools
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang llvm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Project build version
if: inputs.version != ''
env:
VERSION: ${{ inputs.version }}
run: node scripts/set-build-version.mjs --version "${VERSION%%+*}"

- name: Build the CLI's web UI
run: node scripts/ci/build-cli-web-ui.mjs

- uses: actions/upload-artifact@v6
with:
name: ${{ inputs.artifact_name }}
path: ${{ env.OPENBITFUN_CLI_WEB_UI_DIR }}
if-no-files-found: error
retention-days: 1
2 changes: 2 additions & 0 deletions .github/workflows/desktop-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
clang \
llvm \
pkg-config \
libglib2.0-dev \
libgtk-4-dev \
Expand Down
20 changes: 15 additions & 5 deletions .github/workflows/linux-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,16 @@ permissions:
contents: read

jobs:
web-ui:
name: CLI Web UI
uses: ./.github/workflows/cli-web-ui.yml
with:
checkout_ref: ${{ inputs.checkout_ref }}
version: ${{ inputs.version }}
artifact_name: ${{ inputs.artifact_prefix }}-cli-web-ui

build:
needs: web-ui
name: Linux Binaries (${{ matrix.platform.name }})
runs-on: ${{ matrix.platform.os }}
timeout-minutes: 90
Expand Down Expand Up @@ -181,11 +190,11 @@ jobs:
- name: Verify projected Cargo metadata
run: cargo metadata --locked --no-deps

- name: Build the CLI's web UI
# Browsers load the web UI from the device they control, so the CLI
# embeds the one built from this commit (src/apps/cli/build.rs).
shell: bash
run: node scripts/ci/build-cli-web-ui.mjs
- name: Download the shared CLI web UI
uses: actions/download-artifact@v7
with:
name: ${{ inputs.artifact_prefix }}-cli-web-ui
path: target/cli-release-web-ui

- name: Build CLI and Relay Server
shell: bash
Expand All @@ -194,6 +203,7 @@ jobs:
# mandatory for self-update. Unset on forks, which then fall back to
# checksum-only.
OPENBITFUN_RELEASE_PUBKEY: ${{ secrets.release_pubkey }}
OPENBITFUN_CLI_WEB_UI_DIR: ${{ github.workspace }}/target/cli-release-web-ui
run: |
cargo build --locked --release \
--target ${{ matrix.platform.target }} \
Expand Down
105 changes: 105 additions & 0 deletions .github/workflows/mobile-nsh-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: Mobile NSH Package

on:
workflow_dispatch:
push:
paths:
- '.github/workflows/mobile-nsh-package.yml'

permissions:
contents: read

jobs:
package:
name: Package (${{ matrix.platform }})
runs-on: ${{ matrix.os }}
# The unsigned iOS device build can exceed one hour on a cold macOS
# runner while compiling the Rust native bridge and NSH runtime.
timeout-minutes: 120
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/target/mobile-nsh-native
strategy:
fail-fast: false
matrix:
include:
- platform: android
os: ubuntu-24.04
rust_targets: aarch64-linux-android,armv7-linux-androideabi
- platform: ios
os: macos-15-intel
rust_targets: aarch64-apple-ios

steps:
- uses: actions/checkout@v5

- uses: pnpm/action-setup@v6

- uses: actions/setup-node@v5
with:
node-version: 22
cache: pnpm

- uses: actions/setup-java@v5
if: matrix.platform == 'android'
with:
distribution: temurin
java-version: '17'

- name: Select Xcode with the matching iOS simulator runtime
if: matrix.platform == 'ios'
run: |
test -d /Applications/Xcode_26.2.app/Contents/Developer
echo "DEVELOPER_DIR=/Applications/Xcode_26.2.app/Contents/Developer" >> "$GITHUB_ENV"

- name: Install NSH CLI
run: node scripts/ci/install-nsh.mjs

- name: Install dependencies
run: pnpm install --frozen-lockfile

- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.rust_targets }}

- name: Cache mobile Rust dependencies
uses: swatinem/rust-cache@v2
with:
workspaces: src/apps/mobile-nsh/native -> ../../../../target/mobile-nsh-native
shared-key: mobile-nsh-package-${{ matrix.platform }}
cache-bin: false

- name: Check Android SDK and NDK
if: matrix.platform == 'android'
run: |
test -f "$ANDROID_HOME/platforms/android-35/android.jar"
test -x "$ANDROID_HOME/build-tools/35.0.0/apksigner"
test -d "$ANDROID_NDK_HOME/toolchains/llvm/prebuilt"

- name: Build Android APK
if: matrix.platform == 'android'
run: pnpm run mobile-nsh:package:android

- name: Verify Android APK signature
if: matrix.platform == 'android'
run: |
for apk in target/mobile-nsh/android/*.apk; do
"$ANDROID_HOME/build-tools/35.0.0/apksigner" verify "$apk"
done

- name: Build unsigned iOS device app
if: matrix.platform == 'ios'
run: pnpm run mobile-nsh:package:ios

- name: Archive iOS device app
if: matrix.platform == 'ios'
working-directory: target/mobile-nsh/ios
run: tar -czf OpenBitFun-ios-unsigned.app.tar.gz -- *.app

- uses: actions/upload-artifact@v6
with:
name: openbitfun-mobile-nsh-${{ matrix.platform }}
path: |
target/mobile-nsh/android/*.apk
target/mobile-nsh/ios/*.app.tar.gz
if-no-files-found: error
retention-days: 7
2 changes: 2 additions & 0 deletions .github/workflows/nightly-artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
clang \
llvm \
pkg-config \
libglib2.0-dev \
libgtk-4-dev \
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/windows-signing-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@ jobs:
timeout-minutes: 5
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v6
- uses: actions/setup-node@v5
with:
node-version: 22
package-manager-cache: false
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Test native Windows package tooling
run: node --test scripts/ci/native-release-tooling.test.mjs
- name: Test signing failure handling without credentials
Expand Down
14 changes: 14 additions & 0 deletions scripts/ci/native-release-tooling.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,20 @@ test('desktop:dev keeps the installed data by default and isolates it on request
assert.doesNotMatch(stampCheck.stderr, /unsettled top-level await/i);
});

test('stamps the Windows icon before the dev bundle directory exists', async (t) => {
const { stampDevAppIdentity } = await import('../desktop-nsh-package-common.mjs');
const work = mkdtempSync(path.join(tmpdir(), 'openbitfun-stamp-dev-'));
t.after(() => rmSync(work, { recursive: true, force: true }));
const appDir = path.join(work, 'target', 'nsh');

stampDevAppIdentity(appDir, root, 'win32');

assert.deepEqual(
readFileSync(path.join(appDir, 'icon.ico')),
readFileSync(path.join(root, 'src/apps/desktop/icons/openbitfun-app-icon.ico')),
);
});

test('install-nsh ensure/postinstall reuses existing versions, skips in CI/opt-out, and links node_modules/.bin', async (t) => {
assert.equal(parseNshVersion('nsh 0.6.1 (2f51d86)'), 'v0.6.1');
assert.equal(parseNshVersion('nsh v0.6.1'), 'v0.6.1');
Expand Down
1 change: 1 addition & 0 deletions scripts/desktop-nsh-package-common.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ export function stampDevAppIdentity(appDir, rootDir = root, platform = process.p
const winIcon = join(rootDir, "src", "apps", "desktop", "icons", "openbitfun-app-icon.ico");
const destIcon = join(appDir, "icon.ico");
if (existsSync(winIcon)) {
mkdirSync(appDir, { recursive: true });
copyFileSync(winIcon, destIcon);
}
}
Expand Down
13 changes: 8 additions & 5 deletions scripts/nsh-motion-runtime.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ const checksum = {
};
const sha256 = bytes => createHash('sha256').update(bytes).digest('hex');

function prepare(name, inputs, build) {
export function prepare(name, inputs, build, { cacheDir = cache, isComplete = existsSync } = {}) {
const hash = createHash('sha256').update(readFileSync(fileURLToPath(import.meta.url)));
for (const input of inputs) hash.update(readFileSync(input));
const dest = path.join(cache, `${name}-${hash.digest('hex').slice(0, 20)}`);
if (!existsSync(dest)) {
mkdirSync(cache, { recursive: true });
const stage = mkdtempSync(path.join(cache, `.${name}-`));
const dest = path.join(cacheDir, `${name}-${hash.digest('hex').slice(0, 20)}`);
if (!isComplete(dest)) {
rmSync(dest, { recursive: true, force: true });
mkdirSync(cacheDir, { recursive: true });
const stage = mkdtempSync(path.join(cacheDir, `.${name}-`));
try {
build(stage);
try { renameSync(stage, dest); }
Expand Down Expand Up @@ -184,6 +185,8 @@ export function webRuntimeEnv(env, development = false) {
cpSync(source, web, { recursive: true });
applyPatch(web, patch);
buildWebModule(web, development, env);
}, {
isComplete: runtime => existsSync(path.join(runtime, 'web', 'nsh.js')) && existsSync(path.join(runtime, 'web', module)),
});
return { ...env, NSH_RUNTIME: runtime };
}
Expand Down
Loading