Skip to content

Release

Release #44

Workflow file for this run

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 main branch
if: github.ref_name != github.event.repository.default_branch
run: |
echo "Branch is not main"
exit 0
- 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 MobileSdkRs --release
- name: Compress XCFramework
run: |
zip -9 -r RustFramework.xcframework.zip MobileSdkRs/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\/mobile-sdk-rs\/releases\/download\/${{ github.event.inputs.version }}\/RustFramework.xcframework.zip", checksum: "${{ env.XCF_CHECKSUM }}"),/' Package.swift
- name: Update Cocoapods definitions
run: |
sed -i '' -r 's/[0-9]+.[0-9]+.[0-9]+/${{ github.event.inputs.version }}/' SpruceIDMobileSdkRsRustFramework.podspec
sed -i '' -r 's/[0-9]+.[0-9]+.[0-9]+/${{ github.event.inputs.version }}/' SpruceIDMobileSdkRs.podspec
- name: Push changes and tag
run: |
git config user.name github-actions
git config user.email [email protected]
git add Package.swift SpruceIDMobileSdkRs.podspec SpruceIDMobileSdkRsRustFramework.podspec
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 }}
- name: Publish to CocoaPod register
env:
COCOAPODS_TRUNK_TOKEN: ${{ secrets.COCOAPODS_TRUNK_TOKEN }}
run: |
pod trunk push SpruceIDMobileSdkRsRustFramework.podspec
pod trunk push SpruceIDMobileSdkRs.podspec --synchronous
kotlin:
runs-on: ubuntu-latest
needs: validation
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: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.MAVEN_GPG_KEY }}
- name: Populate local.properties
run: echo "sdk.dir=$ANDROID_SDK_ROOT" > local.properties
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Publish package to GHCR
uses: gradle/gradle-build-action@v2
with:
arguments: publish
build-root-directory: ./kotlin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ github.event.inputs.version }}
- name: Publish package to Central
uses: gradle/gradle-build-action@v2
with:
arguments: publishReleasePublicationToCentralPortal
build-root-directory: ./kotlin
env:
MAVEN_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
VERSION: ${{ github.event.inputs.version }}