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:
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
SOURCE_URL: https://packages.quineglobal.com/altstore.json
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
- 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
- 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")
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
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"