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
45 changes: 38 additions & 7 deletions .github/workflows/package-ios.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
name: package-ios

# Manual only. A macOS runner is required and this file does not run on push.
# Manual, or called by package.yml. A macOS runner is required.
# unsigned: device IPA with no Apple signature, for TrollStore or a jailbroken device only.
on:
workflow_dispatch:
inputs:
target:
description: simulator builds a .app for the iOS Simulator. device exports an IPA only when signing secrets are set.
description: unsigned = device IPA without an Apple signature (TrollStore / jailbreak sideload). simulator = .app for the iOS Simulator. device = signed IPA, only when signing secrets are set.
type: choice
options:
- unsigned
- simulator
- device
default: simulator
default: unsigned
workflow_call:
inputs:
target:
type: string
default: unsigned

permissions:
contents: read

jobs:
ios:
runs-on: macos-latest
timeout-minutes: 90
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand All @@ -31,9 +39,23 @@ jobs:
- uses: Swatinem/rust-cache@v2
with:
workspaces: src-tauri
- name: CocoaPods
run: brew install cocoapods
- name: Build tools
run: |
brew install cocoapods xcodegen
brew install ldid || echo "ldid is unavailable; the IPA will carry no ad-hoc signature."
- run: npm ci
- name: Unsigned IPA
if: inputs.target == 'unsigned'
run: bash scripts/package-ios.sh --unsigned
- name: Check the unsigned IPA
if: inputs.target == 'unsigned'
run: |
cd packaging/out
ls -l
shasum -a 256 -c SHA256SUMS
ipa="$(ls *-ios-unsigned.ipa)"
unzip -l "$ipa" | grep -E 'Payload/[^/]+\.app/(Info\.plist|AppIcon)' | head -20
cat PROVENANCE-ios.txt
- name: Simulator app
if: inputs.target == 'simulator'
run: bash scripts/package-ios.sh --simulator
Expand All @@ -48,10 +70,19 @@ jobs:
APPLE_API_KEY_PATH: ${{ secrets.APPLE_API_KEY_PATH }}
run: bash scripts/package-ios.sh --device
- uses: actions/upload-artifact@v4
if: always() && hashFiles('packaging/out/**') != ''
if: inputs.target == 'unsigned'
with:
name: mathscrap-ios
path: |
packaging/out/*.ipa
packaging/out/PROVENANCE-ios.txt
packaging/out/SHA256SUMS
if-no-files-found: error
- uses: actions/upload-artifact@v4
if: always() && inputs.target != 'unsigned' && hashFiles('packaging/out/**') != ''
with:
name: mathscrap-ios-${{ inputs.target }}
path: |
packaging/out/*
src-tauri/gen/apple/**/*.app
if-no-files-found: warn
if-no-files-found: warn
178 changes: 147 additions & 31 deletions .github/workflows/package.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: package

# Change-aware CI. The scope job classifies the diff (scripts/ci-scope.mjs):
# docs consistency checks only; no math suite, no packages
# version consistency checks; packages build on push to main (release bump)
# packaging consistency checks plus real package builds (also on pull requests); no math suite
# full the whole math suite, then packages on push to main
# Mixed or unclassified changes are full. ci-ok is the single status to require:
# skipped jobs pass it, failed or cancelled jobs fail it.
on:
push:
branches:
Expand All @@ -15,9 +22,13 @@ on:
type: boolean
default: false
sign_android:
description: Sign the release APK with ANDROID_KEY_*
description: Sign the release APK with ANDROID_KEY_*
type: boolean
default: false
build_ios:
description: Build the unsigned iOS IPA (TrollStore / jailbreak sideload only)
type: boolean
default: true

permissions:
contents: read
Expand All @@ -27,16 +38,17 @@ concurrency:
cancel-in-progress: true

jobs:
test:
scope:
runs-on: ubuntu-latest
outputs:
mode: ${{ steps.scope.outputs.mode }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Classify changes
id: scope
env:
Expand All @@ -48,22 +60,58 @@ jobs:
PR_NUMBER: ${{ github.event.pull_request.number }}
PUSH_BEFORE: ${{ github.event.before }}
run: node scripts/ci-scope.mjs

# Lightweight consistency checks. They run for every change, in seconds.
checks:
needs: scope
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- name: Check recorded versions
if: steps.scope.outputs.mode == 'light'
run: node scripts/ci-version-check.mjs
- name: Classifier regression
run: node scripts/ci-scope-smoke.mjs
- name: Packaging script syntax
run: |
for f in scripts/package-*.sh; do bash -n "$f"; echo "ok $f"; done
for f in scripts/*.mjs; do node --check "$f"; done
set +e
bash scripts/package-ios.sh --unsigned > /tmp/ios.txt 2>&1
code=$?
set -e
if [ "$code" -ne 3 ]; then cat /tmp/ios.txt; echo "package-ios.sh on Linux should stop with exit 3, got $code"; exit 1; fi
- name: Workflow YAML
run: |
python3 - <<'PY'
import glob, yaml
for path in sorted(glob.glob('.github/workflows/*.yml')):
with open(path, encoding='utf-8') as fh:
doc = yaml.safe_load(fh)
assert isinstance(doc, dict) and doc.get('jobs'), path
print('ok', path)
PY

# The math suite. Only for full changes.
test:
needs: scope
if: needs.scope.outputs.mode == 'full'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- uses: dtolnay/rust-toolchain@stable
if: steps.scope.outputs.mode == 'full'
with:
toolchain: 1.90.0
- uses: Swatinem/rust-cache@v2
if: steps.scope.outputs.mode == 'full'
with:
workspaces: crates/mathcore
- name: Classifier regression
if: steps.scope.outputs.mode == 'full'
run: node scripts/ci-scope-smoke.mjs
- name: Chrome for sheet end-to-end
if: steps.scope.outputs.mode == 'full'
run: |
if ! command -v google-chrome >/dev/null 2>&1 && ! command -v google-chrome-stable >/dev/null 2>&1; then
sudo apt-get update
Expand All @@ -72,29 +120,20 @@ jobs:
fi
(google-chrome --version || google-chrome-stable --version)
- run: npm ci
if: steps.scope.outputs.mode == 'full'
- run: npm run lint
if: steps.scope.outputs.mode == 'full'
- run: npm run test:rust
if: steps.scope.outputs.mode == 'full'
- name: Packaged MCP protocol
if: steps.scope.outputs.mode == 'full'
run: cargo test --manifest-path crates/mcpserve/Cargo.toml
- run: npm run smoke
if: steps.scope.outputs.mode == 'full'
- run: npm run smoke:ocr
if: steps.scope.outputs.mode == 'full'
- name: Real CoMER smoke
if: steps.scope.outputs.mode == 'full'
run: npx tsx scripts/ocr-real-smoke.ts
- run: npm run smoke:ai
if: steps.scope.outputs.mode == 'full'
- run: npm run test:pack
if: steps.scope.outputs.mode == 'full'
- run: npm run smoke:ink
if: steps.scope.outputs.mode == 'full'
- name: Ink unit tests
run: npx tsx --test src/ink/*.test.ts
- name: Start the dev server
if: steps.scope.outputs.mode == 'full'
run: |
npm run dev > dev-server.log 2>&1 &
echo $! > dev-server.pid
Expand All @@ -108,17 +147,14 @@ jobs:
cat dev-server.log
exit 1
- name: Sheet end-to-end
if: steps.scope.outputs.mode == 'full'
env:
SHOTS: e2e-shots
run: npm run e2e:sheet
- name: Ink gestures
if: steps.scope.outputs.mode == 'full'
env:
SHOTS: e2e-shots
run: npm run e2e:ink
- name: Per-formula plot end-to-end
if: steps.scope.outputs.mode == 'full'
env:
SHOTS: e2e-plots
run: npm run e2e
Expand All @@ -134,8 +170,13 @@ jobs:
if-no-files-found: ignore

web:
needs: test
if: github.event_name != 'pull_request'
needs: [scope, checks, test]
if: >-
!cancelled() && needs.scope.result == 'success' && needs.checks.result == 'success' &&
(needs.test.result == 'success' || needs.test.result == 'skipped') &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && needs.scope.outputs.mode != 'docs') ||
(github.event_name == 'pull_request' && needs.scope.outputs.mode == 'packaging'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -152,8 +193,13 @@ jobs:
if-no-files-found: error

android:
needs: test
if: github.event_name != 'pull_request'
needs: [scope, checks, test]
if: >-
!cancelled() && needs.scope.result == 'success' && needs.checks.result == 'success' &&
(needs.test.result == 'success' || needs.test.result == 'skipped') &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && needs.scope.outputs.mode != 'docs') ||
(github.event_name == 'pull_request' && needs.scope.outputs.mode == 'packaging'))
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -174,7 +220,7 @@ jobs:
workspaces: src-tauri
- run: npm ci
- name: Debug APK
if: github.event_name != 'workflow_dispatch' || inputs.sign_android == false
if: github.event_name != 'workflow_dispatch' || !inputs.sign_android
run: bash scripts/package-android.sh --debug --install-sdk
- name: Release APK
if: github.event_name == 'workflow_dispatch' && inputs.sign_android
Expand All @@ -192,8 +238,13 @@ jobs:
if-no-files-found: error

windows:
needs: test
if: github.event_name != 'pull_request'
needs: [scope, checks, test]
if: >-
!cancelled() && needs.scope.result == 'success' && needs.checks.result == 'success' &&
(needs.test.result == 'success' || needs.test.result == 'skipped') &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && needs.scope.outputs.mode != 'docs') ||
(github.event_name == 'pull_request' && needs.scope.outputs.mode == 'packaging'))
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -238,3 +289,68 @@ jobs:
packaging/out/*.msi
packaging/out/SHA256SUMS
if-no-files-found: error

ios:
needs: [scope, checks, test]
if: >-
!cancelled() && needs.scope.result == 'success' && needs.checks.result == 'success' &&
(needs.test.result == 'success' || needs.test.result == 'skipped') &&
(github.event_name == 'workflow_dispatch' ||
(github.event_name == 'push' && needs.scope.outputs.mode != 'docs') ||
(github.event_name == 'pull_request' && needs.scope.outputs.mode == 'packaging')) &&
(github.event_name != 'workflow_dispatch' || inputs.build_ios)
uses: ./.github/workflows/package-ios.yml
with:
target: unsigned

# One SHA256SUMS over every package, next to the per-job sums.
checksums:
needs: [android, windows, ios]
if: >-
!cancelled() && needs.android.result == 'success' && needs.windows.result == 'success' &&
(needs.ios.result == 'success' || needs.ios.result == 'skipped')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
- uses: actions/download-artifact@v4
with:
pattern: mathscrap-*
path: artifacts
- name: Verify per-job sums and combine
run: |
mkdir -p release
for d in artifacts/mathscrap-android artifacts/mathscrap-windows artifacts/mathscrap-ios; do
[ -d "$d" ] || continue
(cd "$d" && sha256sum -c --ignore-missing SHA256SUMS)
find "$d" -maxdepth 1 -type f ! -name SHA256SUMS ! -name 'PROVENANCE*' -exec cp {} release/ \;
done
node scripts/checksum-artifacts.mjs release
- uses: actions/upload-artifact@v4
with:
name: mathscrap-release-checksums
path: release/SHA256SUMS
if-no-files-found: error

# The one status to require on main. Skipped jobs pass; failed or cancelled jobs fail.
ci-ok:
if: always()
needs: [scope, checks, test, web, android, windows, ios, checksums]
runs-on: ubuntu-latest
steps:
- name: Summarize
env:
NEEDS: ${{ toJSON(needs) }}
run: |
node -e '
const needs = JSON.parse(process.env.NEEDS)
let bad = 0
for (const [name, job] of Object.entries(needs)) {
console.log(name.padEnd(10), job.result)
if (job.result === "failure" || job.result === "cancelled") bad++
}
if (needs.scope.result !== "success") bad++
process.exit(bad ? 1 : 0)
'
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ The dev server forwards the browser's model request through `POST /__mathscrap/a

## Packages

外壳是 Tauri 2。它把 `dist/` 放进系统 WebView。安装之后不连接 Vite,也不从公共 CDN 拉数学库或 OCR。标识是 `app.mathscrap`,版本 `0.0.1`。图标用纸面的牛皮色 `#c9a473`。
外壳是 Tauri 2。它把 `dist/` 放进系统 WebView。安装之后不连接 Vite,也不从公共 CDN 拉数学库或 OCR。标识是 `app.mathscrap`,版本 `0.0.2`。图标用纸面的牛皮色 `#c9a473`。

The shell is Tauri 2. It puts `dist/` in the system WebView. After install it does not connect to Vite and does not fetch the math library or OCR from a public CDN. The identifier is `app.mathscrap`, version `0.0.1`. The icon uses the kraft color `#c9a473`.
The shell is Tauri 2. It puts `dist/` in the system WebView. After install it does not connect to Vite and does not fetch the math library or OCR from a public CDN. The identifier is `app.mathscrap`, version `0.0.2`. The icon uses the kraft color `#c9a473`.

| 命令 Command | 在哪里跑 / Where it runs | 得到什么 / What you get |
| --- | --- | --- |
Expand All @@ -173,9 +173,9 @@ Android 调试包用 SDK 的 debug keystore 签名。正式签名要已有的 ke

The Android debug package is signed with the SDK debug keystore. A release signature needs an existing keystore: `ANDROID_KEY_ALIAS`, `ANDROID_KEY_PASSWORD`, `ANDROID_KEY_BASE64`. The script does not generate a keystore.

iOS 最低系统是 16.4。能装到别人手机上的 IPA 需要 Apple Developer 证书和描述文件:`IOS_CERTIFICATE`、`IOS_CERTIFICATE_PASSWORD`、`IOS_MOBILE_PROVISION`,或 `APPLE_API_ISSUER`、`APPLE_API_KEY`、`APPLE_API_KEY_PATH`。这里不注册开发者账号,不上传 TestFlight 或 App Store,也没有在 iPhone 上安装过。
iOS 最低系统是 15.0(arm64,例如 iPad Air 2 的 iPadOS 15)。笔迹和数学引擎在 15.x 上可用;手写识别在 iOS 16.4 以上用 WebAssembly SIMD;更旧的系统(没有 SIMD)自动改用 onnxruntime-web 1.18 的非 SIMD 兼容运行时,结果相同但慢数倍,自动识别暂停、改为手动点「识别」。兼容路径只在 Chromium 里模拟过,未在 iPad 真机验证。能装到别人手机上的 IPA 需要 Apple Developer 证书和描述文件:`IOS_CERTIFICATE`、`IOS_CERTIFICATE_PASSWORD`、`IOS_MOBILE_PROVISION`,或 `APPLE_API_ISSUER`、`APPLE_API_KEY`、`APPLE_API_KEY_PATH`。这里不注册开发者账号,不上传 TestFlight 或 App Store,也没有在 iPhone 上安装过。

The iOS minimum is 16.4. An IPA that installs on someone else's phone needs an Apple Developer certificate and profile: `IOS_CERTIFICATE`, `IOS_CERTIFICATE_PASSWORD`, `IOS_MOBILE_PROVISION`, or `APPLE_API_ISSUER`, `APPLE_API_KEY`, `APPLE_API_KEY_PATH`. This repository does not enroll a developer account, does not upload to TestFlight or the App Store, and has not been installed on an iPhone.
The iOS minimum is 15.0 (arm64, for example iPadOS 15 on an iPad Air 2). Ink and the math engine work on 15.x; handwriting recognition uses WebAssembly SIMD on iOS 16.4 and later; older systems (no SIMD) fall back to onnxruntime-web 1.18's non-SIMD runtime, with the same results several times slower, automatic reading paused and Recognize done by hand. The fallback has been exercised in Chromium only, not on an iPad. An IPA that installs on someone else's phone needs an Apple Developer certificate and profile: `IOS_CERTIFICATE`, `IOS_CERTIFICATE_PASSWORD`, `IOS_MOBILE_PROVISION`, or `APPLE_API_ISSUER`, `APPLE_API_KEY`, `APPLE_API_KEY_PATH`. This repository does not enroll a developer account, does not upload to TestFlight or the App Store, and has not been installed on an iPhone.

`.github/workflows/package.yml` 在推送到 `main` 或 `cursor/mathscrap-packaging-*` 时,以及指向 `main` 的 pull request 上运行。`test` 作业没有额外的跳过条件:这三种情况都会在 `ubuntu-latest` 上跑 `npm run lint`、`npm run test:rust`、`npm run smoke`、`npm run smoke:ocr`、`npm run smoke:ai`、`npm run test:pack`、`npm run smoke:ink`,然后拉起 dev 服务器,依次跑 `npm run e2e:sheet`、`npm run e2e:ink` 和 `npm run e2e`(逐条作图)。失败时上传 `e2e-shots`、`e2e-plots` 和 `dev-server.log`。这些步骤不需要密钥。网页、debug APK 和未签名 Windows 安装程序仍只在 push 上、并且 `test` 通过之后构建;pull request 不打安装包。`.github/workflows/package-ios.yml` 只在手动启动时使用 macOS runner。这些 workflow 不创建 GitHub Release。本文件不提供下载地址。

Expand Down
Loading
Loading