Skip to content

Build, Tag and Create Release #2

Build, Tag and Create Release

Build, Tag and Create Release #2

Workflow file for this run

name: Build, Tag and Create Release
on:
workflow_dispatch:
inputs:
version:
description: "New release version, eg. 0.MINOR.PATCH"
required: true
type: string
ffitag:
description: "The bbqr-ffi tag to use for the release"
required: true
type: string
jobs:
build-publish:
name: Build, tag and create release
runs-on: macos-12
steps:
- name: "Checkout build repo"
uses: actions/checkout@v3
with:
repository: "${{ github.repository_owner }}/bbqr-ffi"
path: build
ref: "${{ inputs.ffitag }}"
- name: "Checkout dist repo"
uses: actions/checkout@v3
with:
path: dist
- name: "Install Rust targets"
working-directory: build/bbqr-ffi
run: |
rustup default 1.78.0
rustup component add rust-src
rustup target add aarch64-apple-ios # iOS ARM64
rustup target add x86_64-apple-ios # iOS x86_64
rustup target add aarch64-apple-ios-sim # simulator mac M1
rustup target add aarch64-apple-darwin # mac M1
rustup target add x86_64-apple-darwin # mac x86_64
- name: "Run bbqrffi-bindgen"
working-directory: build/bbqr-ffi
run: |
cargo run --bin uniffi-bindgen generate --library ./target/aarch64-apple-ios/release-smaller/libbbqrffi.dylib --language swift --out-dir ../bbqr-swift/Sources/Bbqr
- name: "Build bbqr-ffi for all targets"
working-directory: build/bbqr-ffi
run: |
cargo build --profile release-smaller --target x86_64-apple-darwin
cargo build --profile release-smaller --target aarch64-apple-darwin
cargo build --profile release-smaller --target x86_64-apple-ios
cargo build --profile release-smaller --target aarch64-apple-ios
cargo build --profile release-smaller --target aarch64-apple-ios-sim
- name: "Create lipo-ios-sim and lipo-macos"
working-directory: build/bbqr-ffi
run: |
mkdir -p target/lipo-ios-sim/release-smaller
lipo target/aarch64-apple-ios-sim/release-smaller/libbbqrffi.a target/x86_64-apple-ios/release-smaller/libbbqrffi.a -create -output target/lipo-ios-sim/release-smaller/libbbqrffi.a
mkdir -p target/lipo-macos/release-smaller
lipo target/aarch64-apple-darwin/release-smaller/libbbqrffi.a target/x86_64-apple-darwin/release-smaller/libbbqrffi.a -create -output target/lipo-macos/release-smaller/libbbqrffi.a
- name: "Create Bbqr.xcframework"
working-directory: build/bbqr-swift
run: |
mv Sources/Bbqr/bbqrffi.swift Sources/Bbqr/Bbqr.swift
cp Sources/Bbqr/bbqrffiFFI.h Bbqr.xcframework/ios-arm64/bbqrffiFFI.framework/Headers
cp Sources/Bbqr/bbqrffiFFI.h Bbqr.xcframework/ios-arm64_x86_64-simulator/bbqrffiFFI.framework/Headers
cp Sources/Bbqr/bbqrffiFFI.h Bbqr.xcframework/macos-arm64_x86_64/bbqrffiFFI.framework/Headers
cp ../bbqr-ffi/target/aarch64-apple-ios/release-smaller/libbbqrffi.a Bbqr.xcframework/ios-arm64/bbqrffiFFI.framework/bbqrffiFFI
cp ../bbqr-ffi/target/lipo-ios-sim/release-smaller/libbbqrffi.a Bbqr.xcframework/ios-arm64_x86_64-simulator/bbqrffiFFI.framework/bbqrffiFFI
cp ../bbqr-ffi/target/lipo-macos/release-smaller/libbbqrffi.a Bbqr.xcframework/macos-arm64_x86_64/bbqrffiFFI.framework/bbqrffiFFI
rm Sources/Bbqr/bbqrffiFFI.h
rm Sources/Bbqr/bbqrffiFFI.modulemap
rm Bbqr.xcframework.zip || true
zip -9 -r Bbqr.xcframework.zip Bbqr.xcframework
echo "FFI_CHECKSUM=`swift package compute-checksum Bbqr.xcframework.zip`" >> $GITHUB_ENV
echo "FFI_URL=https\:\/\/github\.com\/$\{{ github.repository_owner }}\/bbqr\-swift\/releases\/download\/${{ inputs.version }}\/{{module_name}}\.xcframework\.zip" >> $GITHUB_ENV
- name: "Update and tag release dist repo"
working-directory: build/bbqr-swift
run: |
echo checksum = ${{ env.FFI_CHECKSUM }}
echo url = ${{ env.FFI_URL }}
sed "s/FFI_CHECKSUM/${FFI_CHECKSUM}/;s/FFI_URL/${FFI_URL}/" Package.swift.txt > ../../dist/Package.swift
cp Sources/Bbqr/Bbqr.swift ../../dist/Sources/Bbqr/Bbqr.swift
cd ../../dist
git add Sources/Bbqr/Bbqr.swift
git add Package.swift
git commit -m "Update Bbqr.swift and Package.swift for release ${{ inputs.version }}"
git push
git tag ${{ inputs.version }} -m "Release ${{ inputs.version }}"
git push --tags
- name: "Create release"
uses: ncipollo/release-action@v1
with:
artifacts: "build/bbqr-swift/Bbqrxcframework.zip"
tag: ${{ inputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
name: Release ${{ inputs.version }}
prerelease: true