Release #3
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: Release | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Tag in SemVer format' | |
required: true | |
type: string | |
jobs: | |
validation: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Validate tag | |
run: | | |
echo "${{ github.event.inputs.version }}" | grep -P '^[0-9]+\.[0-9]+\.[0-9]+' | |
swift: | |
runs-on: macos-latest | |
needs: validation | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: "aarch64-apple-ios-sim,aarch64-apple-ios,x86_64-apple-ios" | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: "true" | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-swift | |
- name: Generate Swift package | |
run: cargo swift package -p ios -n WalletSdkRs --release | |
- name: Compress XCFramework | |
run: | | |
zip -9 -r RustFramework.xcframework.zip WalletSdkRs/RustFramework.xcframework | |
echo "XCF_CHECKSUM=`swift package compute-checksum RustFramework.xcframework.zip`" >> $GITHUB_ENV | |
- name: Update Swift Package definition | |
run: | | |
sed -i '' 's/.binaryTarget.*/.binaryTarget(name: "RustFramework", url: "https:\/\/github.com\/spruceid\/wallet-sdk-rs\/releases\/download\/${{ github.event.inputs.version }}\/RustFramework.xcframework.zip", checksum: "${{ env.XCF_CHECKSUM }}"),/' Package.swift | |
- name: Push changes and tag | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add Package.swift | |
git commit -m "Release ${{ github.event.inputs.version }}" | |
git push | |
git tag ${{ github.event.inputs.version }} -m "${{ github.event.inputs.version }}" | |
git push --tags | |
- name: Create release and attach XCFramework binary artifact | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "RustFramework.xcframework.zip" | |
tag: ${{ github.event.inputs.version }} | |
name: ${{ github.event.inputs.version }} | |
kotlin: | |
runs-on: ubuntu-latest | |
needs: swift | |
defaults: | |
run: | |
working-directory: ./kotlin | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@stable | |
with: | |
targets: "aarch64-linux-android,armv7-linux-androideabi,x86_64-linux-android,i686-linux-android" | |
- name: Rust Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
cache-on-failure: "true" | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: cargo-ndk | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Validate Gradle wrapper | |
uses: gradle/wrapper-validation-action@v1 | |
- name: Publish package | |
uses: gradle/gradle-build-action@v2 | |
with: | |
arguments: publish | |
build-root-directory: ./kotlin | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
VERSION: ${{ github.event.inputs.version }} |