diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..196716dd --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +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 github-actions@github.com + 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 }} diff --git a/.gitignore b/.gitignore index 37eefdba..7f01167d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ /generated .build WalletSdkRs/Package.swift +WalletSdkRs/RustFramework .swiftpm