Release #7
Workflow file for this run
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: | |
release: | |
types: [created] | |
jobs: | |
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 | |
# Get current version from Cargo.toml | |
CURRENT_VERSION=$(grep -m 1 'version = ' walletkit-core/Cargo.toml | cut -d '"' -f 2) | |
# Compare versions using sort -V (natural version sort) | |
if echo -e "$CURRENT_VERSION\n$TAG" | sort -V | head -n1 | grep -q "^$TAG$"; then | |
echo "Error: New version $TAG is not greater than current version $CURRENT_VERSION" | |
# exit 1 | |
fi | |
echo "Tag $TAG is valid and newer than current version $CURRENT_VERSION" | |
echo "release_tag=$TAG" >> $GITHUB_OUTPUT | |
- name: Set up Rust | |
run: | | |
rustup update stable && rustup default stable | |
- name: Cache Cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry- | |
- name: Cache Cargo index | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-index- | |
- name: Cache Cargo build | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build- | |
- 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 origin HEAD:main | |
build-swift: | |
runs-on: macos-latest | |
needs: update-cargo-version | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Rust | |
run: | | |
rustup update stable && rustup default stable | |
- name: Cache Cargo registry | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/registry | |
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-registry- | |
- name: Cache Cargo index | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cargo/git | |
key: ${{ runner.os }}-cargo-index-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-index- | |
- name: Cache Cargo build | |
uses: actions/cache@v4 | |
with: | |
path: target | |
key: ${{ runner.os }}-cargo-build-${{ hashFiles('**/Cargo.lock') }} | |
restore-keys: | | |
${{ runner.os }}-cargo-build- | |
- name: Install dependencies | |
run: | | |
cargo fetch | |
- name: Build the project (iOS) | |
run: ./build_swift.sh | |
- name: Checkout swift repo | |
uses: actions/checkout@v4 | |
with: | |
repository: worldcoin/walletkit-swift | |
token: ${{ secrets.GIT_HUB_TOKEN }} | |
path: target-repo | |
- name: Commit swift build | |
env: | |
GITHUB_TOKEN: ${{ secrets.GIT_HUB_TOKEN }} | |
run: | | |
cp -r WalletKitCore.xcframework target-repo/ | |
cp -r Sources/ target-repo/ | |
cp Package.swift target-repo/ | |
cd target-repo | |
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 "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 }} |