Update: clone via localhost like Kiosk, macos-tahoe label, package IPA from archive

This commit is contained in:
2026-04-17 17:35:17 +00:00
parent 1960541480
commit 561eb772de

View File

@@ -1,4 +1,5 @@
name: Build iOS App
on:
workflow_dispatch:
inputs:
@@ -14,126 +15,85 @@ on:
jobs:
build:
runs-on: macos
runs-on: macos-tahoe
steps:
- name: Clone target repo
run: |
git clone --depth 1 --branch "${{ inputs.target_branch }}" \
"https://code.all-win.local/${{ inputs.target_owner }}/${{ inputs.target_repo }}.git" \
workspace
env:
GIT_SSL_NO_VERIFY: "true"
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: Detect build system
id: detect
- name: Generate Xcode project (if xcodegen)
run: |
cd workspace
if [ -f project.yml ]; then
echo "build_system=xcodegen" >> "$GITHUB_OUTPUT"
elif ls *.xcworkspace 1>/dev/null 2>&1; then
echo "build_system=workspace" >> "$GITHUB_OUTPUT"
elif ls *.xcodeproj 1>/dev/null 2>&1; then
echo "build_system=xcodeproj" >> "$GITHUB_OUTPUT"
export PATH="/opt/homebrew/bin:$PATH"
xcodegen generate
echo "XcodeGen project generated"
else
echo "::error::No Xcode project found"
exit 1
echo "No project.yml — using existing Xcode project"
fi
- name: Generate Xcode project (if xcodegen)
if: steps.detect.outputs.build_system == 'xcodegen'
run: |
cd workspace
xcodegen generate
- name: Resolve scheme
id: scheme
run: |
cd workspace
if [ -f *.xcworkspace ]; then
PROJ=$(ls -d *.xcworkspace | head -1)
SCHEME=$(xcodebuild -workspace "$PROJ" -list 2>/dev/null | awk '/Schemes:/{found=1;next} found && /^[[:space:]]+/{print $1; exit}')
else
PROJ=$(ls -d *.xcodeproj | head -1)
SCHEME=$(xcodebuild -project "$PROJ" -list 2>/dev/null | awk '/Schemes:/{found=1;next} found && /^[[:space:]]+/{print $1; exit}')
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 "project=$PROJ" >> "$GITHUB_OUTPUT"
echo "Detected scheme: $SCHEME in $PROJ"
echo "Resolved: $PROJ_FLAG $PROJ -scheme $SCHEME"
- name: Archive
run: |
cd workspace
PROJ="${{ steps.scheme.outputs.project }}"
SCHEME="${{ steps.scheme.outputs.scheme }}"
# Determine -workspace vs -project flag
if [[ "$PROJ" == *.xcworkspace ]]; then
PROJ_FLAG="-workspace"
else
PROJ_FLAG="-project"
fi
xcodebuild \
$PROJ_FLAG "$PROJ" \
-scheme "$SCHEME" \
${{ steps.scheme.outputs.proj_flag }} "${{ steps.scheme.outputs.proj }}" \
-scheme "${{ steps.scheme.outputs.scheme }}" \
-configuration Release \
-archivePath ../build/App.xcarchive \
-destination 'generic/platform=iOS' \
-allowProvisioningUpdates \
CODE_SIGN_IDENTITY="-" \
CODE_SIGNING_ALLOWED=NO \
archive
- name: Export IPA
- name: Package IPA
run: |
# Create export options for ad-hoc (SauceLabs re-signs)
cat > ExportOptions.plist << 'EXPORTEOF'
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>method</key>
<string>development</string>
<key>compileBitcode</key>
<false/>
<key>signingStyle</key>
<string>automatic</string>
<key>teamID</key>
<string>4A9S8YXM74</string>
</dict>
</plist>
EXPORTEOF
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 '/' '-')
xcodebuild -exportArchive \
-archivePath build/App.xcarchive \
-exportPath build/export \
-exportOptionsPlist ExportOptions.plist \
-allowProvisioningUpdates \
2>/dev/null || {
# Fallback: manually package the .app as .ipa
echo "Export failed — packaging .app as .ipa directly"
mkdir -p build/export/Payload
cp -R build/App.xcarchive/Products/Applications/*.app build/export/Payload/
cd build/export
zip -r "../${{ inputs.target_repo }}.ipa" Payload/
cd ../..
}
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)"
- name: Locate IPA
id: ipa
run: |
IPA=$(find build -name "*.ipa" -type f | head -1)
if [ -z "$IPA" ]; then
echo "::error::No .ipa found after build"
exit 1
fi
echo "path=$IPA" >> "$GITHUB_OUTPUT"
echo "name=$(basename $IPA)" >> "$GITHUB_OUTPUT"
echo "Found: $IPA ($(stat -f %z "$IPA") 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.ipa.outputs.path }}"
path: "${{ steps.package.outputs.ipa_path }}"
retention-days: 7