-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #146 from EATSTEAK/dev
[ci] iOS 배포 워크플로 등록
- Loading branch information
Showing
16 changed files
with
320 additions
and
55 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
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
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,23 @@ | ||
name: Lint | ||
|
||
on: | ||
workflow_dispatch: | ||
pull_request: | ||
branches: [ "main", "dev" ] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Rust | ||
uses: dtolnay/rust-toolchain@nightly | ||
with: | ||
components: clippy, rustfmt | ||
- name: Retrieve cache | ||
uses: Leafwing-Studios/cargo-cache@v2 | ||
with: | ||
cache-group: build | ||
- name: Check rustfmt | ||
run: cargo +nightly fmt | ||
- name: Check clippy | ||
run: cargo +nightly clippy -- -D warnings |
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,150 @@ | ||
name: Release (iOS) | ||
|
||
on: | ||
push: | ||
branches: [ dev ] | ||
paths: | ||
- './Cargo.toml' | ||
workflow_dispatch: | ||
permissions: | ||
actions: write | ||
jobs: | ||
release-ios: | ||
runs-on: macos-latest | ||
steps: | ||
- name: Checkout Cargo.toml to check version | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.IOS_GITHUB_TOKEN }} | ||
sparse-checkout: | | ||
Cargo.toml | ||
sparse-checkout-cone-mode: false | ||
- name: Get rusaint version | ||
id: current_version | ||
uses: mikefarah/yq@v4 | ||
with: | ||
cmd: yq '.workspace.package.version | "v" + .' Cargo.toml | ||
- name: Fetch latest release tag | ||
id: latest_release | ||
run: | | ||
curl -L \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.IOS_GITHUB_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/EATSTEAK/rusaint/releases \ | ||
| jq '.[0].tag_name | "result=" + .' \ | ||
| tr -d '"' >> $GITHUB_OUTPUT | ||
- name: Cancel workflow if version is not updated | ||
if: steps.current_version.outputs.result == steps.latest_release.outputs.result | ||
env: | ||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh run cancel ${{ github.run_id }} | ||
gh run watch ${{ github.run_id }} | ||
- name: Checkout the repository | ||
uses: actions/checkout@v4 | ||
with: | ||
token: ${{ secrets.IOS_GITHUB_TOKEN }} | ||
submodules: 'recursive' | ||
- name: Attach HEAD in submodule | ||
working-directory: languages/swift/Rusaint | ||
run: git switch main | ||
- name: Setup Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
with: | ||
targets: 'aarch64-apple-ios, x86_64-apple-ios, aarch64-apple-ios-sim' | ||
- name: Retrieve cache | ||
uses: Leafwing-Studios/cargo-cache@v2 | ||
- name: Install the Apple certificate | ||
env: | ||
BUILD_CERTIFICATE_BASE64: ${{ secrets.IOS_BUILD_CERTIFICATE_BASE64 }} | ||
P12_PASSWORD: ${{ secrets.IOS_P12_PASSWORD }} | ||
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }} | ||
run: | | ||
# create variables | ||
CERTIFICATE_PATH=$RUNNER_TEMP/build_certificate.p12 | ||
KEYCHAIN_PATH=$RUNNER_TEMP/signing.keychain-db | ||
# import certificate from secrets | ||
echo -n "$BUILD_CERTIFICATE_BASE64" | base64 --decode -o $CERTIFICATE_PATH | ||
# create temporary keychain | ||
security create-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
security set-keychain-settings -lut 21600 $KEYCHAIN_PATH | ||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
# import certificate to keychain | ||
security import $CERTIFICATE_PATH -P "$P12_PASSWORD" -A -t cert -f pkcs12 -k $KEYCHAIN_PATH | ||
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH | ||
security list-keychain -d user -s $KEYCHAIN_PATH | ||
- name: Build native library | ||
env: | ||
IPHONEOS_DEPLOYMENT_TARGET: ${{ vars.IOS_DEPLOYMENT_TARGET || '14.0' }} | ||
RUSTFLAGS: '-C link-arg=-Wl,-application_extension' | ||
run: | | ||
mkdir $RUNNER_TEMP/target | ||
CARGO_TARGET_DIR=$RUNNER_TEMP/target | ||
cargo build --package rusaint-ffi --target aarch64-apple-ios-sim --release | ||
cargo build --package rusaint-ffi --target aarch64-apple-ios --release | ||
cargo build --package rusaint-ffi --target x86_64-apple-ios --release | ||
- name: Create universal libraries for simulator | ||
run: | | ||
mkdir -p $RUNNER_TEMP/target/universal-ios-sim/release | ||
lipo -create \ | ||
$RUNNER_TEMP/target/aarch64-apple-ios-sim/release/librusaint_ffi.a \ | ||
$RUNNER_TEMP/target/x86_64-apple-ios/release/librusaint_ffi.a \ | ||
-output $RUNNER_TEMP/target/universal-ios-sim/release/librusaint_ffi.a | ||
- name: Generate swift bindings | ||
run: | | ||
cargo run -p uniffi-bindgen generate \ | ||
$RUNNER_TEMP/target/aarch64-apple-ios/release/librusaint_ffi.dylib \ | ||
--library \ | ||
--language swift \ | ||
--no-format \ | ||
--out-dir $RUNNER_TEMP/bindings | ||
- name: Move generated swift bindgs | ||
run: mv $RUNNER_TEMP/bindings/*.swift ./languages/swift/Rusaint/Sources/Rusaint/ | ||
- name: Massage the generated files to fit xcframework | ||
run: | | ||
mkdir $RUNNER_TEMP/Headers | ||
mv $RUNNER_TEMP/bindings/*.h $RUNNER_TEMP/Headers/ | ||
cat $RUNNER_TEMP/bindings/*.modulemap > $RUNNER_TEMP/Headers/module.modulemap | ||
- name: Create xcframework | ||
run: | | ||
rm -r ./languages/swift/Rusaint/Artifacts/RusaintFFI.xcframework | ||
xcodebuild -create-xcframework \ | ||
-library $RUNNER_TEMP/target/aarch64-apple-ios/release/librusaint_ffi.a \ | ||
-headers $RUNNER_TEMP/Headers \ | ||
-library $RUNNER_TEMP/target/universal-ios-sim/release/librusaint_ffi.a \ | ||
-headers $RUNNER_TEMP/Headers \ | ||
-output ./languages/swift/Rusaint/Artifacts/RusaintFFI.xcframework | ||
- name: Sign xcframework | ||
env: | ||
KEYCHAIN_PASSWORD: ${{ secrets.IOS_KEYCHAIN_PASSWORD }} | ||
run: | | ||
security unlock-keychain -p "$KEYCHAIN_PASSWORD" $RUNNER_TEMP/signing.keychain-db | ||
codesign --timestam-p -s "Apple Development" ./languages/swift/Rusaint/Artifacts/RusaintFFI.xcframework | ||
- name: Push to submodule | ||
working-directory: languages/swift/Rusaint | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "" | ||
git add . | ||
git commit -m "release: ${{ steps.current_version.outputs.result }}" | ||
git push | ||
- name: Commit submodule in main repository | ||
run: | | ||
git config user.name "GitHub Actions" | ||
git config user.email "" | ||
git add languages/swift/Rusaint | ||
git commit -m "release(ios): ${{ steps.current_version.outputs.result }}" | ||
git push | ||
- name: Create release | ||
run: | | ||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.IOS_GITHUB_TOKEN }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/EATSTEAK/rusaint-ios/releases \ | ||
-d '{"tag_name":"${{ steps.current_version.outputs.result }}","name":"${{ steps.current_version.outputs.result }}"}' |
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
Submodule Rusaint
updated
10 files
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
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
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
Oops, something went wrong.