diff --git a/codemagic.yaml b/codemagic.yaml index 3f31ad0..81a9ae1 100644 --- a/codemagic.yaml +++ b/codemagic.yaml @@ -42,10 +42,17 @@ workflows: - name: Publish to Gitea script: | - set -e + set -exo pipefail + echo "TAG=$CM_TAG BUILD_DIR=$CM_BUILD_DIR" + echo "GITEA_API=$GITEA_API TOKEN_SET=$([ -n "$GITEA_TOKEN" ] && echo yes || echo NO)" + 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") @@ -64,30 +71,36 @@ workflows: altstore-source.json > altstore-source.tmp.json mv altstore-source.tmp.json altstore-source.json - # Update altstore-source.json via Gitea API (avoids git push auth) - FILE_SHA=$(curl -sf \ + # 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 -sf -X PUT "$GITEA_API/repos/$GITEA_REPO/contents/altstore-source.json" \ + 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\"}" + -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 -sf -X POST "$GITEA_API/repos/$GITEA_REPO/releases" \ + 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 -sf -X POST "$GITEA_API/repos/$GITEA_REPO/releases/$RELEASE_ID/assets" \ + 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" + -F "attachment=@$IPA;type=application/octet-stream" \ + | jq -r '.name // "UPLOAD_FAILED"' - echo "Published release $TAG → $DOWNLOAD_URL" + echo "Done: $TAG → $DOWNLOAD_URL" artifacts: - $CM_BUILD_DIR/SilverApple.ipa