ci(mobile): build Android and iOS on tags and manual runs
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d7d476e5ec
commit
bed1dfaa8f
2 files changed
+119
No files matched your search
@@ -0,0 +1,97 @@
|
|||||||
|
name: Mobile Build
|
||||||
|
|
||||||
|
# Tags build preview Android and iOS and attach them to the tag's release.
|
||||||
|
# Manual runs pick the profile and platforms and keep the builds as run artifacts.
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
profile:
|
||||||
|
description: EAS build profile
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- preview
|
||||||
|
- development
|
||||||
|
default: preview
|
||||||
|
platforms:
|
||||||
|
description: Platforms to build
|
||||||
|
type: choice
|
||||||
|
options:
|
||||||
|
- all
|
||||||
|
- android
|
||||||
|
- ios
|
||||||
|
default: all
|
||||||
|
|
||||||
|
env:
|
||||||
|
# Tag pushes have no inputs, so they fall back to preview on all platforms.
|
||||||
|
PROFILE: ${{ inputs.profile || 'preview' }}
|
||||||
|
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
android:
|
||||||
|
if: inputs.platforms != 'ios'
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
- uses: actions/setup-java@v4
|
||||||
|
with:
|
||||||
|
distribution: temurin
|
||||||
|
java-version: 17
|
||||||
|
- uses: android-actions/setup-android@v3
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: build
|
||||||
|
working-directory: apps/mobile
|
||||||
|
run: |
|
||||||
|
version=$([[ "$GITHUB_REF" == refs/tags/* ]] && echo "$GITHUB_REF_NAME" || echo "${GITHUB_SHA::7}")
|
||||||
|
out="$PWD/otunes-$PROFILE-$version.apk"
|
||||||
|
npx --yes eas-cli@latest build --local --non-interactive --platform android --profile "$PROFILE" --output "$out"
|
||||||
|
echo "file=$out" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: android-${{ env.PROFILE }}
|
||||||
|
path: ${{ steps.build.outputs.file }}
|
||||||
|
|
||||||
|
- name: Attach to release
|
||||||
|
if: startsWith(gitea.ref, 'refs/tags/')
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
run: scripts/upload-release-asset.sh "${{ steps.build.outputs.file }}"
|
||||||
|
|
||||||
|
ios:
|
||||||
|
if: inputs.platforms != 'android'
|
||||||
|
# Queues until a self-hosted macOS runner (Xcode, CocoaPods, fastlane) picks it up.
|
||||||
|
runs-on: macos
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: pnpm/action-setup@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: 24
|
||||||
|
|
||||||
|
- name: Build
|
||||||
|
id: build
|
||||||
|
working-directory: apps/mobile
|
||||||
|
run: |
|
||||||
|
version=$([[ "$GITHUB_REF" == refs/tags/* ]] && echo "$GITHUB_REF_NAME" || echo "${GITHUB_SHA::7}")
|
||||||
|
out="$PWD/otunes-$PROFILE-$version.ipa"
|
||||||
|
npx --yes eas-cli@latest build --local --non-interactive --platform ios --profile "$PROFILE" --output "$out"
|
||||||
|
echo "file=$out" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: ios-${{ env.PROFILE }}
|
||||||
|
path: ${{ steps.build.outputs.file }}
|
||||||
|
|
||||||
|
- name: Attach to release
|
||||||
|
if: startsWith(gitea.ref, 'refs/tags/')
|
||||||
|
env:
|
||||||
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
||||||
|
run: scripts/upload-release-asset.sh "${{ steps.build.outputs.file }}"
|
||||||
Executable
+22
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Uploads a file to the Gitea release for the current tag, creating the release
|
||||||
|
# if it does not exist yet. Used by .gitea/workflows/mobile-build.yml.
|
||||||
|
# Usage: GITEA_TOKEN=... upload-release-asset.sh <file>
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
file=$1
|
||||||
|
api="$GITHUB_SERVER_URL/api/v1/repos/$GITHUB_REPOSITORY/releases"
|
||||||
|
auth=(-H "Authorization: token $GITEA_TOKEN")
|
||||||
|
json_id() { node -pe 'JSON.parse(require("fs").readFileSync(0, "utf8")).id'; }
|
||||||
|
|
||||||
|
existing_id() { curl -fsS "${auth[@]}" "$api/tags/$GITHUB_REF_NAME" | json_id; }
|
||||||
|
create_id() {
|
||||||
|
curl -fsS "${auth[@]}" -H "Content-Type: application/json" \
|
||||||
|
-d "{\"tag_name\":\"$GITHUB_REF_NAME\",\"name\":\"$GITHUB_REF_NAME\"}" "$api" | json_id
|
||||||
|
}
|
||||||
|
|
||||||
|
# Android and iOS race to create the release; whoever loses re-reads it.
|
||||||
|
id=$(existing_id 2>/dev/null || create_id || existing_id)
|
||||||
|
|
||||||
|
curl -fsS "${auth[@]}" -F "attachment=@$file" \
|
||||||
|
"$api/$id/assets?name=$(basename "$file")" > /dev/null
|
||||||
Reference in new issue
Block a user