|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '[0-9]+.[0-9]+.[0-9]+' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + name: Build and Publish Release |
| 11 | + runs-on: macos-15 |
| 12 | + permissions: |
| 13 | + contents: write |
| 14 | + env: |
| 15 | + GH_TOKEN: ${{ github.token }} |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + - name: Setup Xcode |
| 21 | + uses: OpenSwiftUIProject/OpenSwiftUI/.github/actions/setup-xcode@main |
| 22 | + with: |
| 23 | + xcode-version: "16.4" |
| 24 | + - name: Checkout Swift headers |
| 25 | + uses: ./.github/actions/checkout-swift-headers |
| 26 | + - name: Build XCFramework |
| 27 | + run: ./Scripts/build_xcframework.sh |
| 28 | + - name: Compute Checksum |
| 29 | + id: checksum |
| 30 | + run: | |
| 31 | + echo "checksum=$(swift package compute-checksum .build/Xcode/Frameworks/OpenAttributeGraph.xcframework.zip)" >> $GITHUB_OUTPUT |
| 32 | + - name: Collect Build Info |
| 33 | + id: build_info |
| 34 | + run: | |
| 35 | + echo "xcode_version=$(xcodebuild -version | head -1)" >> $GITHUB_OUTPUT |
| 36 | + echo "swift_version=$(swift --version 2>&1 | head -1)" >> $GITHUB_OUTPUT |
| 37 | + - name: Generate Release Notes |
| 38 | + id: release_notes |
| 39 | + run: | |
| 40 | + TAG_NAME="${GITHUB_REF#refs/tags/}" |
| 41 | + # Find the previous tag |
| 42 | + PREV_TAG=$(git tag --sort=-v:refname | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | sed -n '2p') |
| 43 | + REPO="${GITHUB_REPOSITORY}" |
| 44 | + DOWNLOAD_URL="https://github.com/${REPO}/releases/download/${TAG_NAME}/OpenAttributeGraph.xcframework.zip" |
| 45 | +
|
| 46 | + { |
| 47 | + echo 'body<<RELEASE_NOTES_EOF' |
| 48 | +
|
| 49 | + # Binary Target section first |
| 50 | + echo "## Binary Target" |
| 51 | + echo "" |
| 52 | + echo '```swift' |
| 53 | + echo '.binaryTarget(' |
| 54 | + echo ' name: "OpenAttributeGraph",' |
| 55 | + echo " url: \"${DOWNLOAD_URL}\"," |
| 56 | + echo " checksum: \"${{ steps.checksum.outputs.checksum }}\"" |
| 57 | + echo ')' |
| 58 | + echo '```' |
| 59 | + echo "" |
| 60 | +
|
| 61 | + # Build info |
| 62 | + echo "## Build Info" |
| 63 | + echo "" |
| 64 | + echo "- ${{ steps.build_info.outputs.xcode_version }}" |
| 65 | + echo "- ${{ steps.build_info.outputs.swift_version }}" |
| 66 | + echo "" |
| 67 | +
|
| 68 | + # What's Changed section |
| 69 | + if [ -n "$PREV_TAG" ]; then |
| 70 | + echo "## What's Changed" |
| 71 | + git log "${PREV_TAG}..HEAD" --pretty=format:"* %s by @%an in ${GITHUB_SERVER_URL}/${REPO}/commit/%H" --no-merges |
| 72 | + echo "" |
| 73 | + echo "" |
| 74 | + echo "**Full Changelog**: ${GITHUB_SERVER_URL}/${REPO}/compare/${PREV_TAG}...${TAG_NAME}" |
| 75 | + else |
| 76 | + echo "## What's Changed" |
| 77 | + git log --pretty=format:"* %s by @%an in ${GITHUB_SERVER_URL}/${REPO}/commit/%H" --no-merges |
| 78 | + echo "" |
| 79 | + fi |
| 80 | +
|
| 81 | + echo 'RELEASE_NOTES_EOF' |
| 82 | + } >> "$GITHUB_OUTPUT" |
| 83 | + - name: Create Release |
| 84 | + uses: ncipollo/release-action@v1 |
| 85 | + with: |
| 86 | + body: ${{ steps.release_notes.outputs.body }} |
| 87 | + allowUpdates: true |
| 88 | + artifacts: ".build/Xcode/Frameworks/OpenAttributeGraph.xcframework.zip" |
| 89 | + token: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments