Skip to content

Workflow file for this run

name: Build and Release Yttrium
on:
push:
branches:
- 'xcframework'
env:
CARGO_TERM_COLOR: always
VERSION: ${{ github.event.inputs.version || '0.0.6' }}
TARGET_BRANCH: ${{ github.ref_name }}
permissions:
contents: write # Grant write access to repository contents for this workflow
jobs:
release-swift-package:
runs-on: macos-14
strategy:
matrix:
config:
- debug
steps:
# 1. Checkout the Repository with full history
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history so that we can create and push tags
# 2. Setup ccache (Optional: Improve build speeds)
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
# 3. Setup pnpm (JavaScript Package Manager)
- name: Setup pnpm
uses: pnpm/action-setup@v4
with:
version: 9
# 4. Setup Rust Environment and Dependencies
- name: Setup Rust Environment and Dependencies
env:
VERSION: ${{ env.VERSION }}
run: |
rustup update stable && rustup default stable
git submodule update --init --recursive
make setup-thirdparty
# 5. Select Specific Xcode Version
- name: Select Xcode 15.4
run: |
sudo xcode-select -s /Applications/Xcode_15.4.app
# 6. Build and Package Rust XCFramework
- name: Build and Package Rust XCFramework
run: |
make build-ios-bindings-release
make zip-rust-xcframework
make compute-rust-checksum
make generate-package-swift
# 7. (Optional) Debug Environment Variables
- name: Debug Environment Variables
run: |
echo "VERSION: $VERSION"
echo "TARGET_BRANCH: $TARGET_BRANCH"
# 8. (Optional) Check Git Status
- name: Check Git Status
run: git status
# 9. (Optional) List Changes in Package.swift
- name: List Changes in Package.swift
run: git diff Package.swift
# 10. Compute Checksum and Update Package.swift
- name: Compute Checksum and Update Package.swift
id: compute_checksum
run: |
# Compute checksum
CHECKSUM=$(swift package compute-checksum ./Output/RustXcframework.xcframework.zip)
echo "Computed checksum: $CHECKSUM"
# Update Package.swift with the new checksum
# Assuming the binary target is named "RustXcframework"
sed -i '' "s/checksum: \".*\"/checksum: \"$CHECKSUM\"/" Package.swift
echo "Updated Package.swift with new checksum."
# 11. Commit and Push Package.swift
- name: Commit and Push Package.swift
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Use default token
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add Package.swift
if git diff --cached --quiet; then
echo "No changes to commit."
else
git commit -m "chore: update Package.swift for version $VERSION"
git push origin HEAD:$TARGET_BRANCH
fi
# 12. Create Git Tag
- name: Create Git Tag
env:
VERSION: ${{ env.VERSION }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Ensure we're on the latest commit
git fetch origin $TARGET_BRANCH
# Get the latest commit hash
COMMIT_HASH=$(git rev-parse HEAD)
echo "Tagging commit ${COMMIT_HASH} with version ${VERSION}"
# Create an annotated tag on the latest commit
git tag -a "${VERSION}" -m "Release version ${VERSION}" "${COMMIT_HASH}"
# Push the tag to the repository
git push origin "${VERSION}"
# 13. Create a GitHub Release
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.VERSION }}
release_name: Yttrium ${{ env.VERSION }}
draft: false
prerelease: true
# 14. Upload Rust XCFramework to the Release
- name: Upload Rust XCFramework to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./Output/RustXcframework.xcframework.zip
asset_name: RustXcframework.xcframework.zip
asset_content_type: application/zip