forked from openmls/openmls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding GitHub Actions for XCFrameworks
- Loading branch information
Showing
1 changed file
with
102 additions
and
0 deletions.
There are no files selected for viewing
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
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 |