100 lines
3.3 KiB
YAML
100 lines
3.3 KiB
YAML
name: Build iOS App
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
target_owner:
|
|
description: "Gitea org/user that owns the target repo"
|
|
required: true
|
|
target_repo:
|
|
description: "Repository name to build"
|
|
required: true
|
|
target_branch:
|
|
description: "Branch to build"
|
|
required: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: macos-tahoe
|
|
steps:
|
|
- name: Clone target repo
|
|
env:
|
|
GITEA_TOKEN: ${{ github.token }}
|
|
run: |
|
|
REPO_URL="http://gitea-token:${GITEA_TOKEN}@localhost:3000/${{ inputs.target_owner }}/${{ inputs.target_repo }}.git"
|
|
git clone --depth 1 --branch "${{ inputs.target_branch }}" "$REPO_URL" workspace
|
|
|
|
- name: Generate Xcode project (if xcodegen)
|
|
run: |
|
|
cd workspace
|
|
if [ -f project.yml ]; then
|
|
export PATH="/opt/homebrew/bin:$PATH"
|
|
xcodegen generate
|
|
echo "XcodeGen project generated"
|
|
else
|
|
echo "No project.yml — using existing Xcode project"
|
|
fi
|
|
|
|
- name: Resolve scheme
|
|
id: scheme
|
|
run: |
|
|
cd workspace
|
|
PROJ=""
|
|
PROJ_FLAG=""
|
|
for f in *.xcworkspace; do
|
|
if [ -d "$f" ]; then PROJ="$f"; PROJ_FLAG="-workspace"; break; fi
|
|
done
|
|
if [ -z "$PROJ" ]; then
|
|
for f in *.xcodeproj; do
|
|
if [ -d "$f" ]; then PROJ="$f"; PROJ_FLAG="-project"; break; fi
|
|
done
|
|
fi
|
|
if [ -z "$PROJ" ]; then
|
|
echo "::error::No Xcode project or workspace found"
|
|
exit 1
|
|
fi
|
|
SCHEME=$(xcodebuild $PROJ_FLAG "$PROJ" -list 2>/dev/null | awk '/Schemes:/{found=1;next} found && /^[[:space:]]+/{gsub(/^[[:space:]]+/,""); print; exit}')
|
|
echo "proj=$PROJ" >> "$GITHUB_OUTPUT"
|
|
echo "proj_flag=$PROJ_FLAG" >> "$GITHUB_OUTPUT"
|
|
echo "scheme=$SCHEME" >> "$GITHUB_OUTPUT"
|
|
echo "Resolved: $PROJ_FLAG $PROJ -scheme $SCHEME"
|
|
|
|
- name: Archive
|
|
run: |
|
|
cd workspace
|
|
xcodebuild \
|
|
${{ steps.scheme.outputs.proj_flag }} "${{ steps.scheme.outputs.proj }}" \
|
|
-scheme "${{ steps.scheme.outputs.scheme }}" \
|
|
-configuration Release \
|
|
-archivePath ../build/App.xcarchive \
|
|
-destination 'generic/platform=iOS' \
|
|
CODE_SIGN_IDENTITY="-" \
|
|
CODE_SIGNING_ALLOWED=NO \
|
|
archive
|
|
|
|
- name: Package IPA
|
|
run: |
|
|
REPO="${{ inputs.target_repo }}"
|
|
BRANCH="${{ inputs.target_branch }}"
|
|
SHA=$(cd workspace && git rev-parse --short HEAD)
|
|
TS=$(date +%Y%m%d-%H%M%S)
|
|
IPA_NAME="${REPO}-${BRANCH}-${SHA}-${TS}.ipa"
|
|
IPA_NAME=$(echo "$IPA_NAME" | tr '/' '-')
|
|
|
|
mkdir -p build/Payload
|
|
cp -R build/App.xcarchive/Products/Applications/*.app build/Payload/
|
|
cd build
|
|
zip -r "$IPA_NAME" Payload/
|
|
echo "Built: $IPA_NAME ($(stat -f %z "$IPA_NAME") bytes)"
|
|
|
|
echo "ipa_name=$IPA_NAME" >> "$GITHUB_OUTPUT"
|
|
echo "ipa_path=build/$IPA_NAME" >> "$GITHUB_OUTPUT"
|
|
id: package
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: "${{ inputs.target_repo }}-${{ inputs.target_branch }}"
|
|
path: "${{ steps.package.outputs.ipa_path }}"
|
|
retention-days: 7
|