From 78a7ad2e32a5eb939f4c17da0a68906bf69e4bf4 Mon Sep 17 00:00:00 2001 From: Kyle Date: Sun, 18 Oct 2026 02:21:13 +0800 Subject: [PATCH] Create the GitHub release from the release workflow After the XCFramework build, create the release for the pushed tag and upload Compute.xcframework.zip to it. The release notes start with the notes that GitHub generates from the changes since the previous release, followed by a binaryTarget snippet with the download URL and SwiftPM checksum. Tags that contain a hyphen create a prerelease. A rerun for an existing release replaces the asset and the notes. --- .github/workflows/release.yml | 51 +++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99b0105..e21de98 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,6 +4,9 @@ on: push: tags: ["*.*.*"] +permissions: + contents: write + jobs: macos-build: name: macOS @@ -24,3 +27,51 @@ jobs: with: path: .build/Xcode/Frameworks/Compute.xcframework.zip archive: false + - name: Create release + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ github.ref_name }} + REPOSITORY: ${{ github.repository }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + zip_path=".build/Xcode/Frameworks/Compute.xcframework.zip" + checksum="$(swift package compute-checksum "$zip_path")" + url="https://github.com/$REPOSITORY/releases/download/$TAG/Compute.xcframework.zip" + + # Start with the release notes that GitHub generates from the changes since the previous release. + gh api "repos/$REPOSITORY/releases/generate-notes" \ + -f tag_name="$TAG" \ + --jq .body > release-notes.md + cat >> release-notes.md < /dev/null 2>&1; then + gh release upload "$TAG" "$zip_path" --clobber + gh release edit "$TAG" --notes-file release-notes.md + else + gh release create "$TAG" "$zip_path" \ + --verify-tag \ + --title "Version $TAG" \ + --notes-file release-notes.md \ + ${prerelease[@]+"${prerelease[@]}"} + fi