Update: clone via localhost like Kiosk, macos-tahoe label, package IPA from archive
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
name: Build iOS App
|
name: Build iOS App
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
@@ -14,126 +15,85 @@ on:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: macos
|
runs-on: macos-tahoe
|
||||||
steps:
|
steps:
|
||||||
- name: Clone target repo
|
- 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:
|
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
|
- name: Generate Xcode project (if xcodegen)
|
||||||
id: detect
|
|
||||||
run: |
|
run: |
|
||||||
cd workspace
|
cd workspace
|
||||||
if [ -f project.yml ]; then
|
if [ -f project.yml ]; then
|
||||||
echo "build_system=xcodegen" >> "$GITHUB_OUTPUT"
|
export PATH="/opt/homebrew/bin:$PATH"
|
||||||
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"
|
|
||||||
else
|
|
||||||
echo "::error::No Xcode project found"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Generate Xcode project (if xcodegen)
|
|
||||||
if: steps.detect.outputs.build_system == 'xcodegen'
|
|
||||||
run: |
|
|
||||||
cd workspace
|
|
||||||
xcodegen generate
|
xcodegen generate
|
||||||
|
echo "XcodeGen project generated"
|
||||||
|
else
|
||||||
|
echo "No project.yml — using existing Xcode project"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Resolve scheme
|
- name: Resolve scheme
|
||||||
id: scheme
|
id: scheme
|
||||||
run: |
|
run: |
|
||||||
cd workspace
|
cd workspace
|
||||||
if [ -f *.xcworkspace ]; then
|
PROJ=""
|
||||||
PROJ=$(ls -d *.xcworkspace | head -1)
|
PROJ_FLAG=""
|
||||||
SCHEME=$(xcodebuild -workspace "$PROJ" -list 2>/dev/null | awk '/Schemes:/{found=1;next} found && /^[[:space:]]+/{print $1; exit}')
|
for f in *.xcworkspace; do
|
||||||
else
|
if [ -d "$f" ]; then PROJ="$f"; PROJ_FLAG="-workspace"; break; fi
|
||||||
PROJ=$(ls -d *.xcodeproj | head -1)
|
done
|
||||||
SCHEME=$(xcodebuild -project "$PROJ" -list 2>/dev/null | awk '/Schemes:/{found=1;next} found && /^[[:space:]]+/{print $1; exit}')
|
if [ -z "$PROJ" ]; then
|
||||||
|
for f in *.xcodeproj; do
|
||||||
|
if [ -d "$f" ]; then PROJ="$f"; PROJ_FLAG="-project"; break; fi
|
||||||
|
done
|
||||||
fi
|
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 "scheme=$SCHEME" >> "$GITHUB_OUTPUT"
|
||||||
echo "project=$PROJ" >> "$GITHUB_OUTPUT"
|
echo "Resolved: $PROJ_FLAG $PROJ -scheme $SCHEME"
|
||||||
echo "Detected scheme: $SCHEME in $PROJ"
|
|
||||||
|
|
||||||
- name: Archive
|
- name: Archive
|
||||||
run: |
|
run: |
|
||||||
cd workspace
|
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 \
|
xcodebuild \
|
||||||
$PROJ_FLAG "$PROJ" \
|
${{ steps.scheme.outputs.proj_flag }} "${{ steps.scheme.outputs.proj }}" \
|
||||||
-scheme "$SCHEME" \
|
-scheme "${{ steps.scheme.outputs.scheme }}" \
|
||||||
-configuration Release \
|
-configuration Release \
|
||||||
-archivePath ../build/App.xcarchive \
|
-archivePath ../build/App.xcarchive \
|
||||||
-destination 'generic/platform=iOS' \
|
-destination 'generic/platform=iOS' \
|
||||||
-allowProvisioningUpdates \
|
|
||||||
CODE_SIGN_IDENTITY="-" \
|
CODE_SIGN_IDENTITY="-" \
|
||||||
CODE_SIGNING_ALLOWED=NO \
|
CODE_SIGNING_ALLOWED=NO \
|
||||||
archive
|
archive
|
||||||
|
|
||||||
- name: Export IPA
|
- name: Package IPA
|
||||||
run: |
|
run: |
|
||||||
# Create export options for ad-hoc (SauceLabs re-signs)
|
REPO="${{ inputs.target_repo }}"
|
||||||
cat > ExportOptions.plist << 'EXPORTEOF'
|
BRANCH="${{ inputs.target_branch }}"
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
SHA=$(cd workspace && git rev-parse --short HEAD)
|
||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
TS=$(date +%Y%m%d-%H%M%S)
|
||||||
<plist version="1.0">
|
IPA_NAME="${REPO}-${BRANCH}-${SHA}-${TS}.ipa"
|
||||||
<dict>
|
IPA_NAME=$(echo "$IPA_NAME" | tr '/' '-')
|
||||||
<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
|
|
||||||
|
|
||||||
xcodebuild -exportArchive \
|
mkdir -p build/Payload
|
||||||
-archivePath build/App.xcarchive \
|
cp -R build/App.xcarchive/Products/Applications/*.app build/Payload/
|
||||||
-exportPath build/export \
|
cd build
|
||||||
-exportOptionsPlist ExportOptions.plist \
|
zip -r "$IPA_NAME" Payload/
|
||||||
-allowProvisioningUpdates \
|
echo "Built: $IPA_NAME ($(stat -f %z "$IPA_NAME") bytes)"
|
||||||
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 ../..
|
|
||||||
}
|
|
||||||
|
|
||||||
- name: Locate IPA
|
echo "ipa_name=$IPA_NAME" >> "$GITHUB_OUTPUT"
|
||||||
id: ipa
|
echo "ipa_path=build/$IPA_NAME" >> "$GITHUB_OUTPUT"
|
||||||
run: |
|
id: package
|
||||||
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)"
|
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
with:
|
with:
|
||||||
name: "${{ inputs.target_repo }}-${{ inputs.target_branch }}"
|
name: "${{ inputs.target_repo }}-${{ inputs.target_branch }}"
|
||||||
path: "${{ steps.ipa.outputs.path }}"
|
path: "${{ steps.package.outputs.ipa_path }}"
|
||||||
retention-days: 7
|
retention-days: 7
|
||||||
|
|||||||
Reference in New Issue
Block a user