Adding GitHub Actions for XCFrameworks #15
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- x86_64-apple-ios | |
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: | | |
echo -e '\n[lib]\ncrate-type = ["staticlib"]' >> openmls/Cargo.toml | |
- name: Build for ${{ matrix.arch }} | |
run: cargo build --release --lib --target ${{ matrix.arch }} -p openmls --verbose | |
- name: List Output Directory | |
run: ls -la target/${{ matrix.arch }}/release | |
- 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: Verify Downloaded Artifacts | |
run: ls -R 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 |