# Builds Quple for iPhone (mobile/) and publishes it to Quine's AltStore # source: on every push to main that touches mobile/, build the .ipa on the # Mac runner (unsigned: AltStore signs it with the person's own Apple ID) # and put it and its icon on this repo's `altstore` release, with the # source's source.json. # # The source is Quine's, for all our iPhone apps; Quple is the first. # Each app's build replaces only its own entry and files # (.forgejo/altstore-source.py). For now it lives on this release; another # app publishes here too (with a token that can write to this repo), until # the source gets a home of its own. # # In AltStore: Sources → + → https://packages.quineglobal.com/altstore.json # (petersweb-infra's edge.nix serves this release's source.json there; the # .ipa and icons download from git.quineglobal.com, which serves public # repos' release files from the forge, itself tailnet-only.) New builds # then show up as updates. # # Versions: 1.0., build , so each build is newer. name: ios on: push: branches: [main] paths: ['mobile/**', '.forgejo/workflows/ios.yml', '.forgejo/altstore-source.py'] workflow_dispatch: concurrency: group: ios-altstore cancel-in-progress: false jobs: ipa: # The Mac mini: Xcode, CocoaPods and Node on the host. runs-on: macos-latest timeout-minutes: 90 env: BUILD: ${{ github.run_number }} VERSION: 1.0.${{ github.run_number }} RELEASE_TAG: altstore PUBLIC: https://git.quineglobal.com/${{ github.repository }}/releases/download/altstore # The source's own address (what people add in AltStore). SOURCE_URL: https://packages.quineglobal.com/altstore.json # This app's files on the release: -.ipa, -icon.png. APP: Quple SLUG: quple steps: - uses: https://forge.in.quineglobal.com/quine-global/mirror-actions-checkout@v4 - name: Dependencies working-directory: mobile env: LANG: en_US.UTF-8 run: | npm ci --no-audit --no-fund npx tsc --noEmit (cd ios && pod install) - name: Build working-directory: mobile/ios run: | set -o pipefail xcodebuild -workspace QupleMobile.xcworkspace -scheme QupleMobile \ -configuration Release -sdk iphoneos -destination generic/platform=iOS \ -derivedDataPath build \ MARKETING_VERSION="$VERSION" CURRENT_PROJECT_VERSION="$BUILD" \ CODE_SIGNING_ALLOWED=NO CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY="" \ build > build.log 2>&1 || { grep -E "error:" build.log | head -40; tail -20 build.log; exit 1; } grep -E '\*\* BUILD' build.log rm -rf ipa && mkdir -p ipa/Payload out cp -R build/Build/Products/Release-iphoneos/QupleMobile.app ipa/Payload/ (cd ipa && zip -qry "../out/$APP-$BUILD.ipa" Payload) cp QupleMobile/Images.xcassets/AppIcon.appiconset/AppIcon-1024.png "out/$SLUG-icon.png" ls -l out # The source as published now, with this app's entry replaced. - name: AltStore source run: | set -euo pipefail curl -fsSL "$PUBLIC/source.json" -o current-source.json || : > current-source.json python3 .forgejo/altstore-source.py --existing current-source.json \ --listing mobile/altstore.json --ipa "mobile/ios/out/$APP-$BUILD.ipa" \ --version "$VERSION" --build "$BUILD" \ --download-url "$PUBLIC/$APP-$BUILD.ipa" --icon-url "$PUBLIC/$SLUG-icon.png" \ --source-url "$SOURCE_URL" --notes "Build $BUILD (commit ${GITHUB_SHA::7})." \ > mobile/ios/out/source.json cat mobile/ios/out/source.json # The `altstore` release holds each app's latest build: this app's files # are replaced (older builds removed), other apps' left alone. - name: Publish env: TOKEN: ${{ secrets.GITHUB_TOKEN }} API: https://forge.in.quineglobal.com/api/v1/repos/${{ github.repository }} run: | set -euo pipefail auth=(-H "Authorization: token $TOKEN") release=$(curl -sS "${auth[@]}" "$API/releases/tags/$RELEASE_TAG") id=$(echo "$release" | python3 -c 'import json,sys; print(json.load(sys.stdin).get("id") or "")') about="{\"name\": \"Quine apps for iPhone (AltStore source)\", \"body\": \"Quine's AltStore source: each iPhone app's latest build. In AltStore: Sources → + → $SOURCE_URL\"}" if [ -z "$id" ]; then id=$(curl -fsS "${auth[@]}" -H 'Content-Type: application/json' -X POST "$API/releases" \ -d "$(echo "$about" | python3 -c 'import json,sys,os; d=json.load(sys.stdin); d.update(tag_name=os.environ["RELEASE_TAG"], target_commitish=os.environ["GITHUB_SHA"]); print(json.dumps(d))')" \ | python3 -c 'import json,sys; print(json.load(sys.stdin)["id"])') else curl -fsS -o /dev/null "${auth[@]}" -H 'Content-Type: application/json' -X PATCH "$API/releases/$id" -d "$about" fi release=$(curl -fsS "${auth[@]}" "$API/releases/$id") # Remove what this run replaces: this app's builds and icon, and the # source (icon.png: the first, single-app version's). echo "$release" | APP="$APP" SLUG="$SLUG" python3 -c ' import json, os, sys app, slug = os.environ["APP"], os.environ["SLUG"] for a in json.load(sys.stdin).get("assets", []): n = a["name"] if n in ("source.json", "icon.png", slug + "-icon.png") or (n.startswith(app + "-") and n.endswith(".ipa")): print(a["id"], n)' | while read -r aid name; do curl -fsS "${auth[@]}" -X DELETE "$API/releases/$id/assets/$aid" echo "removed $name" done # The ipa and icon first: source.json points at them. for f in "$APP-$BUILD.ipa" "$SLUG-icon.png" source.json; do curl -fsS -o /dev/null "${auth[@]}" -X POST "$API/releases/$id/assets?name=$f" \ -F "attachment=@mobile/ios/out/$f" echo "uploaded $f" done echo "AltStore source: $SOURCE_URL"