Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert the iOS build script into github workflow steps #267

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
85 changes: 79 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: CD iOS
on:
workflow_dispatch:
push:
branches:
- main
# branches:
# - main

permissions:
id-token: write
Expand Down Expand Up @@ -45,9 +45,82 @@ jobs:
components: ${{ env.RUST_COMPONENTS }}
target: aarch64-apple-ios-sim

- name: Run iOS build script
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Compute release tag
id: tags
run: |
set -euo pipefail

LAST_TAG=`git tag --sort=creatordate | tail -1`
NEXT_TAG=$(echo ${LAST_TAG} | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{$NF=sprintf("%0*d", length($NF), ($NF+1)); print}')

echo "NEXT_TAG=$NEXT_TAG" >> "$GITHUB_OUTPUT"
echo "LAST_TAG=$LAST_TAG" >> "$GITHUB_OUTPUT"

- name: Build artifacts
id: build
run: |
set -euo pipefail

rustup target add aarch64-apple-darwin aarch64-apple-ios aarch64-apple-ios-sim
sh ./scripts/ios/release.sh

echo "🚢 Switch 'useLocalFramework' to 'false' in Package.swift for release"
sed -i '' 's/let useLocalFramework = true/let useLocalFramework = false/' Package.swift

# output is: "<CHKSUM>;<$XCFRAME_ZIP_PATH>"
OUTPUT_OF_BUILD=$(bash scripts/ios/build-sargon.sh --release-tag "$NEXT_TAG" | tail -n 1) || exit $?
muzuke marked this conversation as resolved.
Show resolved Hide resolved
if [[ "$OUTPUT_OF_BUILD" == "BUILT_WITHOUT_RELEASE" ]]; then
echo "Error, failed to build, did you forget to pass '--release' to build script? Otherwise check if build-sargon.sh has recently been changed (to something incorrect...)"
exit 1;
fi
CHECKSUM=`echo "$OUTPUT_OF_BUILD" | cut -d ";" -f 1` || exit $?
XCFRAME_ZIP_PATH=`echo "$OUTPUT_OF_BUILD" | cut -d ";" -f 2` || exit $?

echo "🚢 CHECKSUM: $CHECKSUM"
echo "🚢 XCFRAME_ZIP_PATH: $XCFRAME_ZIP_PATH"

echo "🚢 Ensuring Sargon build for release - that it will work for e.g. iOS wallet to archive."
sed -i '' 's/let useLocalFramework = false/let useLocalFramework = true/' Package.swift
swift build -c release || exit $?
echo "🚢 Swift Sargon builds for release ✅"

echo "XCFRAME_ZIP_PATH=$XCFRAME_ZIP_PATH" >> "$GITHUB_OUTPUT"
env:
NEXT_TAG: ${{ steps.tags.outputs.NEXT_TAG }}
CyonAlexRDX marked this conversation as resolved.
Show resolved Hide resolved

- name: Push release tag
run: |
set -euo pipefail

# We have .gitigored Sargon.swift because we dont need it in git history, but we
# need it for this release, so we must FORCE add it (since it is ignored).
echo "🚢 Staging changed files"
git add --force Package.swift apple/Sources/UniFFI/Sargon.swift
CyonAlexRDX marked this conversation as resolved.
Show resolved Hide resolved

git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'

echo "🚢 Git commiting changes"
git status
git commit -m "Release of '$NEXT_TAG'" \
-m "Updated Package.swift with new checksum and path to zip on Github, and maybe apple/Sources/UniFFI/Sargon.swift." \
-m "This commit is not merged into main branch (and need not be)." \
--no-verify

echo "🚢 🏷️ 📡 Pushing tag: $NEXT_TAG, but only tag, not commit."
# git push origin $NEXT_TAG
env:
NEXT_TAG: ${{ steps.tags.outputs.NEXT_TAG }}
CyonAlexRDX marked this conversation as resolved.
Show resolved Hide resolved
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# - name: Create release
# run: |
# # This MUST match whatever you we have declared in Package.swift
# SWIFT_SARGON_BINARY_ASSET_NAME="libsargon-rs.xcframework.zip"

# GH_RELEASE_TITLE="v$NEXT_TAG"
# gh release create $NEXT_TAG '$XCFRAME_ZIP_PATH#$SWIFT_SARGON_BINARY_ASSET_NAME' --generate-notes --notes-start-tag $LAST_TAG --title '$GH_RELEASE_TITLE'
# env:
# LAST_TAG: ${{ steps.tags.outputs.LAST_TAG }}
# NEXT_TAG: ${{ steps.tags.outputs.NEXT_TAG }}
# XCFRAME_ZIP_PATH: ${{ steps.build.outputs.XCFRAME_ZIP_PATH }}
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading