Skip to content

Adding GitHub Actions for XCFrameworks #4

Adding GitHub Actions for XCFrameworks

Adding GitHub Actions for XCFrameworks #4

Workflow file for this run

name: Build XCFramework and Release
on:
push:
branches:
- xcframeworks
workflow_dispatch:
jobs:
build:
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
arch:
- x86_64-apple-darwin
- aarch64-apple-darwin
- aarch64-apple-ios
- aarch64-apple-ios-sim
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
target: ${{ matrix.arch }}
- uses: Swatinem/rust-cache@v2
- name: Modify Cargo.toml to Add Crate Type
run: |
sed -i.bak '/^\[lib\]/a\
crate-type = ["rlib", "staticlib"]
' openmls/Cargo.toml
- name: Build for ${{ matrix.arch }}
run: cargo build --release --target ${{ matrix.arch }} -p openmls --verbose
- name: List Output Directory
run: ls -la target/${{ matrix.arch }}/release/
- name: Restore Original Cargo.toml
run: |
mv openmls/Cargo.toml.bak openmls/Cargo.toml
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: libopenmls-${{ matrix.arch }}
path: target/${{ matrix.arch }}/release/libopenmls.a
create_xcframework:
runs-on: macos-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Merge iOS Simulator Libraries
run: |
lipo -create -output artifacts/libopenmls_ios_sim.a \
artifacts/libopenmls-aarch64-apple-ios-sim/libopenmls.a \
artifacts/libopenmls-x86_64-apple-ios/libopenmls.a
- name: Create XCFramework
run: |
xcodebuild -create-xcframework \
-library artifacts/libopenmls-x86_64-apple-darwin/libopenmls.a \
-library artifacts/libopenmls-aarch64-apple-darwin/libopenmls.a \
-library artifacts/libopenmls-aarch64-apple-ios/libopenmls.a \
-library artifacts/libopenmls_ios_sim.a \
-output openmls.xcframework
- name: Archive XCFramework
run: 7z a -tzip -mx=9 openmls.xcframework.zip openmls.xcframework
release:
runs-on: ubuntu-latest
needs: create_xcframework
steps:
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.run_number }}
release_name: Release ${{ github.run_number }}
draft: false
prerelease: true
- name: Upload XCFramework to GitHub Release
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./openmls.xcframework.zip
asset_name: openmls.xcframework.zip
asset_content_type: application/zip