|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*.*.*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Build and Release |
| 11 | + runs-on: macos-26 |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + steps: |
| 15 | + - name: Checkout |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Setup Xcode |
| 19 | + uses: maxim-lobanov/setup-xcode@v1 |
| 20 | + with: |
| 21 | + xcode-version: '26.2' |
| 22 | + |
| 23 | + - name: Run tests |
| 24 | + run: swift test |
| 25 | + |
| 26 | + - name: Build arm64 |
| 27 | + run: swift build -c release --arch arm64 |
| 28 | + |
| 29 | + - name: Build x86_64 |
| 30 | + run: swift build -c release --arch x86_64 |
| 31 | + |
| 32 | + - name: Create universal binary |
| 33 | + run: | |
| 34 | + mkdir -p .build/universal |
| 35 | + lipo -create \ |
| 36 | + .build/arm64-apple-macosx/release/xcodecloud \ |
| 37 | + .build/x86_64-apple-macosx/release/xcodecloud \ |
| 38 | + -output .build/universal/xcodecloud |
| 39 | +
|
| 40 | + - name: Ad-hoc codesign |
| 41 | + run: codesign --force --sign - .build/universal/xcodecloud |
| 42 | + |
| 43 | + - name: Verify binary |
| 44 | + run: | |
| 45 | + file .build/universal/xcodecloud |
| 46 | + .build/universal/xcodecloud --version |
| 47 | +
|
| 48 | + - name: Package binary |
| 49 | + run: | |
| 50 | + cd .build/universal |
| 51 | + tar czf xcodecloud-macos-universal.tar.gz xcodecloud |
| 52 | + shasum -a 256 xcodecloud-macos-universal.tar.gz > xcodecloud-macos-universal.tar.gz.sha256 |
| 53 | +
|
| 54 | + - name: Generate release notes |
| 55 | + id: notes |
| 56 | + run: | |
| 57 | + TAG=${GITHUB_REF#refs/tags/} |
| 58 | + # Extract notes for this version from CHANGELOG.md if it exists |
| 59 | + if [ -f CHANGELOG.md ]; then |
| 60 | + # Get content between this version header and the next |
| 61 | + NOTES=$(sed -n "/^## .*${TAG}/,/^## /{ /^## .*${TAG}/d; /^## /d; p; }" CHANGELOG.md) |
| 62 | + fi |
| 63 | + if [ -z "$NOTES" ]; then |
| 64 | + NOTES="Release ${TAG}" |
| 65 | + fi |
| 66 | + # Write to file to preserve newlines |
| 67 | + echo "$NOTES" > /tmp/release-notes.md |
| 68 | +
|
| 69 | + - name: Create GitHub Release |
| 70 | + env: |
| 71 | + GH_TOKEN: ${{ github.token }} |
| 72 | + run: | |
| 73 | + TAG=${GITHUB_REF#refs/tags/} |
| 74 | + gh release create "$TAG" \ |
| 75 | + --title "$TAG" \ |
| 76 | + --notes-file /tmp/release-notes.md \ |
| 77 | + .build/universal/xcodecloud-macos-universal.tar.gz \ |
| 78 | + .build/universal/xcodecloud-macos-universal.tar.gz.sha256 |
0 commit comments