Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
runs-on: macos-latest
needs: pre-release-checks
permissions:
contents: read
contents: write

steps:
- name: Checkout code
Expand All @@ -68,38 +68,66 @@ jobs:
- name: Build the project (iOS)
run: ./build_swift.sh

- name: Compress XCFramework binary
run: |
zip -r WalletKit.xcframework.zip WalletKit.xcframework

- name: Checkout swift repo
uses: actions/checkout@v4
with:
repository: worldcoin/walletkit-swift
token: ${{ secrets.WALLETKIT_BOT_TOKEN }}
path: target-repo

- name: Create draft release in walletkit-swift & upload binaries
uses: softprops/action-gh-release@v2
id: release
with:
repository: worldcoin/walletkit-swift
name: ${{ needs.pre-release-checks.outputs.new_version }}
tag_name: ${{ needs.pre-release-checks.outputs.new_version }}
Comment thread
sideround marked this conversation as resolved.
make_latest: false
draft: true
fail_on_unmatched_files: true
files: WalletKit.xcframework.zip
token: ${{ secrets.WALLETKIT_BOT_TOKEN }}
Comment thread
sideround marked this conversation as resolved.

- name: Get metadata
id: meta
run: |
ASSET_URL="${{ fromJSON(steps.release.outputs.assets)[0].browser_download_url }}"
echo "asset_url=${ASSET_URL}" >> $GITHUB_OUTPUT

CHECKSUM=$(swift package compute-checksum WalletKit.xcframework.zip)
echo "checksum=${CHECKSUM}" >> $GITHUB_OUTPUT

- name: Commit swift build
env:
GITHUB_TOKEN: ${{ secrets.WALLETKIT_BOT_TOKEN }}
ASSET_URL: ${{ steps.meta.outputs.asset_url }}
Comment thread
sideround marked this conversation as resolved.
CHECKSUM: ${{ steps.meta.outputs.checksum }}
NEW_VERSION: ${{ needs.pre-release-checks.outputs.new_version }}

run: |
cp -r WalletKit.xcframework target-repo/
# Copy non-binary source files
cp -r Sources/ target-repo/Sources

# Prepare Package.swift
brew install swiftlint
./archive_swift.sh --asset-url "$ASSET_URL" --checksum "$CHECKSUM" --release-version "$NEW_VERSION"
cp Package.swift target-repo/
echo "// Release version: ${{ needs.pre-release-checks.outputs.new_version }}" >> target-repo/Package.swift

# Commit changes
cd target-repo
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"

# TODO: Move away from Git LFS which doesn't work well with Swift Package Manager
# Initialize Git LFS and track the large files
git lfs install
git lfs track "*.a"

git add .
git commit -m "Release ${{ needs.pre-release-checks.outputs.new_version }}"
git commit -m "Release $NEW_VERSION"

# Tag the release
git tag ${{ needs.pre-release-checks.outputs.new_version }}
git tag $NEW_VERSION
git push
git push origin ${{ needs.pre-release-checks.outputs.new_version }}
git push origin $NEW_VERSION

prepare-kotlin:
name: Prepare Kotlin
Expand Down
26 changes: 0 additions & 26 deletions Package.swift

This file was deleted.

95 changes: 95 additions & 0 deletions archive_swift.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash
set -e

# Creates the dynamic Package.swift file for release.
# Usage: ./archive_swift.sh --asset-url <URL> --checksum <CHECKSUM> --release-version <VERSION>

# Initialize variables
ASSET_URL=""
CHECKSUM=""
RELEASE_VERSION=""

# Function to show usage
show_usage() {
echo "❌ Error: Missing required arguments"
echo "Usage: $0 --asset-url <URL> --checksum <CHECKSUM> --release-version <VERSION>"
echo ""
echo "Example:"
echo " $0 --asset-url 'https://github.com/user/repo/releases/download/v1.0.0/WalletKit.xcframework.zip' --checksum 'abc123def456...' --release-version '1.0.0'"
exit 1
}

# Parse command line arguments
while [[ $# -gt 0 ]]; do
case $1 in
--asset-url)
ASSET_URL="$2"
shift 2
;;
--checksum)
CHECKSUM="$2"
shift 2
;;
--release-version)
RELEASE_VERSION="$2"
shift 2
;;
-h|--help)
show_usage
;;
*)
echo "❌ Unknown argument: $1"
show_usage
;;
esac
done

# Check if all required arguments are provided
if [ -z "$ASSET_URL" ] || [ -z "$CHECKSUM" ] || [ -z "$RELEASE_VERSION" ]; then
echo "❌ Error: All arguments are required"
show_usage
fi

echo "🔧 Creating Package.swift with:"
echo " Asset URL: $ASSET_URL"
echo " Checksum: $CHECKSUM"
echo " Release Version: $RELEASE_VERSION"
echo ""

cat > Package.swift << EOF
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.

// Release version: $RELEASE_VERSION

import PackageDescription

let package = Package(
name: "WalletKit",
platforms: [
.iOS(.v13)
Comment thread
sideround marked this conversation as resolved.
],
products: [
.library(
name: "WalletKit",
targets: ["WalletKit"]),
],
targets: [
.target(
name: "WalletKit",
dependencies: ["walletkit_FFI"],
path: "Sources/WalletKit"
),
.binaryTarget(
name: "walletkit_FFI",
url: "$ASSET_URL",
checksum: "$CHECKSUM"
)
]
)
EOF

swiftlint lint --autocorrect Package.swift
Comment thread
sideround marked this conversation as resolved.

echo ""
echo "✅ Package.swift built successfully for version $RELEASE_VERSION!"
Loading