From 93ddc0e22f6ef85ffe42f0cd3f42d9d79db3c67f Mon Sep 17 00:00:00 2001 From: pdtfh <149602456+pdtfh@users.noreply.github.com> Date: Mon, 18 Nov 2024 15:36:57 +0100 Subject: [PATCH] full release workflow & fix swift release (#6) --- .github/workflows/release.yml | 46 +++++++++++++++++++++++++++++++---- .gitignore | 1 + Package.swift | 1 - 3 files changed, 42 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 51559cfd..3b72f7cc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,17 +1,50 @@ name: Release on: - workflow_dispatch: # TODO: Temporary for testing release: types: [created] jobs: - # TODO: Implement me update-cargo-version: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + # TODO: Ensure tag is not repeated or older + - name: Validate release tag + id: validate-tag + run: | + TAG=${{ github.ref_name }} + SEMVER_REGEX="^[0-9]\.[0-9]{1,2}\.[0-9]{1,2}$" + + if [[ ! $TAG =~ $SEMVER_REGEX ]]; then + echo "Tag $TAG does not match semantic versioning (MAJOR.MINOR.PATCH)." + exit 1 + fi + + echo "Tag $TAG is valid." + echo "release_tag=$TAG" >> $GITHUB_OUTPUT + + - name: Set up Rust + run: | + rustup update stable && rustup default stable + + - name: Install cargo-edit + run: cargo install cargo-edit + + - name: Update version + run: cargo set-version --package walletkit-core ${{ steps.validate-tag.outputs.release_tag }} + + - name: Commit and Push Changes + env: + GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }} + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + git add walletkit-core/Cargo.toml + git commit -m "Bump crate version to ${{ steps.validate-tag.outputs.release_tag }}" + git push + build-swift: runs-on: macos-latest needs: update-cargo-version @@ -53,7 +86,7 @@ jobs: cargo fetch - name: Build the project (iOS) - run: swift/build_swift.sh + run: ./build_swift.sh - name: Checkout swift repo uses: actions/checkout@v4 @@ -65,7 +98,6 @@ jobs: - name: Commit swift build env: GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }} - # TODO: Bump relevant version in Package.swift and in commit message run: | cp -r WalletKitCore.xcframework target-repo/ cp -r Sources/ target-repo/ @@ -74,5 +106,9 @@ jobs: git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" git add . - git commit -m "Version release" + git commit -m "Release ${{ steps.validate-tag.outputs.release_tag }}" + + # Tag the release + git tag ${{ steps.validate-tag.outputs.release_tag }} git push + git push origin ${{ steps.validate-tag.outputs.release_tag }} diff --git a/.gitignore b/.gitignore index 7d89ef60..3c56df93 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ target/ .DS_Store **/ios_build +.swiftpm/ # Swift build outputs are not commited to this repo. WalletKitCore.xcframework/ diff --git a/Package.swift b/Package.swift index c42bf195..37fcbbc8 100644 --- a/Package.swift +++ b/Package.swift @@ -10,7 +10,6 @@ let package = Package( platforms: [ .iOS(.v13), ], - version: "0.0.1", products: [ .library( name: "WalletKitCore",