- Replace #if os(watchOS) with #if canImport(WatchKit) for all .accessoryCorner usages. When the CI builds with forced iphoneos SDK, os(watchOS) evaluates to true (target platform is watchOS) but the SDK doesn't have WatchKit, so accessoryCorner is unavailable. canImport(WatchKit) correctly checks SDK availability rather than target platform. - Wrap CornerComplicationView struct and its preview in #if canImport(WatchKit) with @available(watchOS 10.0, *) annotation. - Change CI build from -target TabataGo -sdk iphoneos to -scheme TabataGo (without -sdk). This lets xcodebuild pick the correct SDK per target: iphoneos for iOS, watchos for watchOS. The scheme already exists in project.yml.
154 lines
5.1 KiB
YAML
154 lines
5.1 KiB
YAML
# =============================================================================
|
|
# TabataGo — PR → Build → Archive → Firebase OTA → Wait LGTM → Merge
|
|
# =============================================================================
|
|
|
|
name: PR → Build → Firebase OTA → LGTM
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [main]
|
|
types: [opened, synchronize, reopened]
|
|
|
|
permissions:
|
|
contents: write
|
|
pull-requests: write
|
|
|
|
jobs:
|
|
|
|
build-deploy:
|
|
name: Build & Deploy to Firebase OTA
|
|
runs-on: macos
|
|
timeout-minutes: 20
|
|
|
|
steps:
|
|
- name: Checkout
|
|
run: |
|
|
git clone --depth 1 https://x-access-token:${PR_TOKEN}@gitea.1000co.fr/${REPO}.git .
|
|
env:
|
|
PR_TOKEN: ${{ secrets.PR_API_TOKEN }}
|
|
REPO: ${{ github.repository }}
|
|
|
|
- name: Setup Xcode
|
|
run: |
|
|
sudo xcode-select -s /Applications/Xcode.app
|
|
xcodebuild -version
|
|
|
|
- name: Setup PATH
|
|
run: echo "/opt/homebrew/bin" >> $GITHUB_PATH
|
|
|
|
- name: Install tools (xcodegen, node, firebase)
|
|
run: |
|
|
brew install xcodegen node || true
|
|
npm install -g firebase-tools
|
|
|
|
- name: Generate Xcode project
|
|
run: |
|
|
cd tabatago-swift
|
|
xcodegen generate
|
|
|
|
- name: Resolve SPM packages
|
|
run: |
|
|
cd tabatago-swift
|
|
xcodebuild -resolvePackageDependencies -project TabataGo.xcodeproj -scmProvider system
|
|
|
|
- name: Build app
|
|
run: |
|
|
cd tabatago-swift
|
|
rm -rf ~/Library/Developer/Xcode/DerivedData ~/Library/Caches/org.swift.swiftpm
|
|
xcodebuild -list
|
|
xcodebuild build \
|
|
-project TabataGo.xcodeproj \
|
|
-scheme TabataGo \
|
|
-destination "generic/platform=iOS" \
|
|
-configuration Debug \
|
|
-allowProvisioningUpdates \
|
|
-skipPackagePluginValidation \
|
|
CODE_SIGN_STYLE=Automatic DEVELOPMENT_TEAM=2MJF39L8VY SWIFT_ENABLE_EXPLICIT_MODULES=NO
|
|
|
|
- name: Package IPA
|
|
run: |
|
|
mkdir -p Payload
|
|
cp -R "$(find build -name '*.app' -type d | head -1)" Payload/
|
|
zip -r build/TabataGo.ipa Payload/
|
|
rm -rf Payload
|
|
|
|
- name: Deploy to Firebase
|
|
env:
|
|
FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }}
|
|
run: |
|
|
echo "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}" | base64 -d > /tmp/firebase-key.json
|
|
export GOOGLE_APPLICATION_CREDENTIALS=/tmp/f...on
|
|
firebase appdistribution:distribute tabatago-swift/build/TabataGo.ipa \
|
|
--app "${FIREBASE_APP_ID}" \
|
|
--groups "millian-test" \
|
|
--release-notes "PR: ${{ github.event.pull_request.title }}"
|
|
rm /tmp/firebase-key.json
|
|
|
|
- name: Post "Ready to test" comment
|
|
env:
|
|
GT_TOKEN: ${{ secrets.PR_API_TOKEN }}
|
|
GITEA_URL: https://gitea.1000co.fr
|
|
run: |
|
|
PR="${{ github.event.pull_request.number }}"
|
|
REPO="${{ github.repository }}"
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${GT_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"body\":\"## 📱 Prêt à tester !\\n\\nL\'app est déployée via Firebase.\\n\\n- Teste les changements\\n- Reply **LGTM** pour merger\\n- Reply **KO** pour bloquer\"}" \
|
|
"${GITEA_URL}/api/v1/repos/${REPO}/issues/${PR}/comments"
|
|
|
|
wait-approval:
|
|
name: Wait for LGTM comment
|
|
needs: build-deploy
|
|
runs-on: macos
|
|
timeout-minutes: 120
|
|
|
|
steps:
|
|
- name: Poll for LGTM
|
|
env:
|
|
GT_TOKEN: ${{ secrets.PR_API_TOKEN }}
|
|
GITEA_URL: https://gitea.1000co.fr
|
|
run: |
|
|
PR="${{ github.event.pull_request.number }}"
|
|
REPO="${{ github.repository }}"
|
|
PR_TITLE="${{ github.event.pull_request.title }}"
|
|
API="${GITEA_URL}/api/v1/repos/${REPO}"
|
|
MAX=240
|
|
TRIES=0
|
|
|
|
echo "⏳ Attente LGTM sur PR #${PR}..."
|
|
|
|
LAST_ID=$(curl -s -H "Authorization: token ${GT_TOKEN}" \
|
|
"${API}/issues/${PR}/comments" | \
|
|
python3 -c "import json,sys; cs=json.load(sys.stdin); print(cs[-1]['id'] if cs else 0)" 2>/dev/null || echo 0)
|
|
|
|
while [ $TRIES -lt $MAX ]; do
|
|
sleep 30
|
|
TRIES=$((TRIES + 1))
|
|
|
|
COMMENTS=$(curl -s -H "Authorization: token ${GT_TOKEN}" \
|
|
"${API}/issues/${PR}/comments?since_id=${LAST_ID}")
|
|
|
|
if echo "$COMMENTS" | grep -qi '"body": *"LGTM"'; then
|
|
echo "✅ LGTM reçu ! Merge..."
|
|
curl -s -X POST \
|
|
-H "Authorization: token ${GT_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"Do\":\"merge\"}" \
|
|
"${API}/pulls/${PR}/merge"
|
|
echo "✅ Mergée."
|
|
exit 0
|
|
fi
|
|
|
|
if echo "$COMMENTS" | grep -qi '"body": *"KO"'; then
|
|
echo "❌ KO reçu. Bloquée."
|
|
exit 1
|
|
fi
|
|
|
|
if [ $((TRIES % 4)) -eq 0 ]; then
|
|
echo " ⏳ ... (${TRIES}/240, $(date +%H:%M))"
|
|
fi
|
|
done
|
|
echo "❌ Timeout 2h."
|
|
exit 1
|