Private
Public Access
1
0
Files
SilverApple/codemagic.yaml
SilverLABS b7e4931e64 fix(ci): use xcodebuild archive to produce .app for IPA packaging
xcodebuild build on an SPM executableTarget only outputs the module/bundle,
not a .app. archive produces a .xcarchive with the .app under Products/.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-06 12:38:48 +01:00

116 lines
4.4 KiB
YAML

workflows:
ios-release:
name: SilverApple iOS Release
instance_type: mac_mini_m2
max_build_duration: 30
triggering:
events:
- tag
tag_patterns:
- pattern: 'v*'
include: true
environment:
xcode: latest
vars:
BUNDLE_ID: uk.silverlabs.silverapple
GITEA_REPO: SilverLABS/SilverApple
GITEA_API: https://git.silverlabs.uk/api/v1
# GITEA_TOKEN — set this in Codemagic App Settings → Environment variables (mark as secret)
scripts:
- name: Build (unsigned)
script: |
xcodebuild archive \
-scheme SilverApple \
-destination "generic/platform=iOS" \
-configuration Release \
-archivePath "$CM_BUILD_DIR/SilverApple.xcarchive" \
CODE_SIGNING_ALLOWED=NO \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGN_IDENTITY="" \
PROVISIONING_PROFILE=""
- name: Package IPA
script: |
cd "$CM_BUILD_DIR"
APP=$(find SilverApple.xcarchive/Products -name "*.app" -type d | head -1)
if [ -z "$APP" ]; then
echo "ERROR: No .app found in xcarchive. Contents:"
find SilverApple.xcarchive -type d | head -30
exit 1
fi
echo "Packaging: $APP"
mkdir -p Payload
cp -r "$APP" Payload/
zip -r SilverApple.ipa Payload/
rm -rf Payload
echo "IPA size: $(du -sh SilverApple.ipa | cut -f1)"
- name: Publish to Gitea
script: |
set -exo pipefail
[ -n "$GITEA_TOKEN" ] || { echo "ERROR: GITEA_TOKEN is not set in Codemagic env vars"; exit 1; }
echo "TAG=$CM_TAG BUILD_DIR=$CM_BUILD_DIR"
echo "GITEA_API=$GITEA_API TOKEN_SET=yes"
TAG="$CM_TAG"
VERSION="${TAG#v}"
IPA="$CM_BUILD_DIR/SilverApple.ipa"
# Verify IPA exists
ls -lh "$IPA"
SHA256=$(shasum -a 256 "$IPA" | awk '{print $1}')
SIZE=$(wc -c < "$IPA" | tr -d ' ')
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
DOWNLOAD_URL="https://git.silverlabs.uk/$GITEA_REPO/releases/download/$TAG/SilverApple.ipa"
# Update altstore-source.json
jq --arg version "$VERSION" \
--arg date "$DATE" \
--arg url "$DOWNLOAD_URL" \
--arg sha "$SHA256" \
--argjson size "$SIZE" \
'.apps[0].downloadURL = $url |
.apps[0].versions = [{"version": $version, "buildVersion": $version, "date": $date,
"localizedDescription": "See release notes.", "downloadURL": $url,
"sha256": $sha, "size": $size}] + .apps[0].versions' \
altstore-source.json > altstore-source.tmp.json
mv altstore-source.tmp.json altstore-source.json
# Get current file SHA from Gitea API
FILE_SHA=$(curl -s \
-H "Authorization: token $GITEA_TOKEN" \
"$GITEA_API/repos/$GITEA_REPO/contents/altstore-source.json" \
| jq -r '.sha')
echo "FILE_SHA=$FILE_SHA"
# Update altstore-source.json via Gitea contents API
CONTENT=$(base64 -i altstore-source.json | tr -d '\n')
curl -s -X PUT "$GITEA_API/repos/$GITEA_REPO/contents/altstore-source.json" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"message\":\"chore(altstore): update source for $TAG\",\"content\":\"$CONTENT\",\"sha\":\"$FILE_SHA\",\"branch\":\"main\"}" \
| jq -r '.commit.sha // "FAILED"'
# Create Gitea release
RELEASE_ID=$(curl -s -X POST "$GITEA_API/repos/$GITEA_REPO/releases" \
-H "Authorization: token $GITEA_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\":\"$TAG\",\"name\":\"SilverApple $TAG\",\"body\":\"AltStore / SideStore release.\",\"draft\":false,\"prerelease\":false}" \
| jq -r '.id')
echo "RELEASE_ID=$RELEASE_ID"
# Upload IPA
curl -s -X POST "$GITEA_API/repos/$GITEA_REPO/releases/$RELEASE_ID/assets" \
-H "Authorization: token $GITEA_TOKEN" \
-F "attachment=@$IPA;type=application/octet-stream" \
| jq -r '.name // "UPLOAD_FAILED"'
echo "Done: $TAG → $DOWNLOAD_URL"
artifacts:
- $CM_BUILD_DIR/SilverApple.ipa