Skip to content

Commit

Permalink
Adding GitHub Actions for XCFrameworks
Browse files Browse the repository at this point in the history
  • Loading branch information
csjones committed Oct 25, 2024
1 parent 5067034 commit e96242e
Showing 1 changed file with 102 additions and 0 deletions.
102 changes: 102 additions & 0 deletions .github/workflows/xcframeworks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
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

0 comments on commit e96242e

Please sign in to comment.