Skip to content

Commit

Permalink
Refactor release script
Browse files Browse the repository at this point in the history
  • Loading branch information
surpher committed Dec 19, 2024
1 parent 7ba969f commit 63a0112
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 36 deletions.
26 changes: 9 additions & 17 deletions Support/Scripts/CI/build_xcframework
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ source "${BUILD_XCFRAMEWORK_SOURCE_DIR}/../Config/config.sh"
XCBEAUTIFY=$(command -v xcbeautify || command -v cat)

XCFRAMEWORK_VERSION="$1"
NEW_XCFRAMEWORK_NAME="$XCFRAMEWORK_NAME-$XCFRAMEWORK_VERSION.$XCFRAMEWORK_EXTENSION"
NEW_XCFRAMEWORK_ARCHIVE="$XCFRAMEWORK_NAME-$XCFRAMEWORK_VERSION"
NEW_XCFRAMEWORK_PATH="$NEW_XCFRAMEWORK_ARCHIVE/$XCFRAMEWORK_NAME.$XCFRAMEWORK_EXTENSION"

########################
# Pre-build checks #
Expand All @@ -43,15 +44,11 @@ check_xcode
# Setup
echo "ℹ️ Looking for $XCPRODUCT_NAME.xcodeproj"
if [ ! -d "$XCPRODUCT_NAME.xcodeproj" ]; then
echo "🚨 Run this in the same folder as \"$XCPRODUCT_NAME.xcodeproj\"!"
echo "Your current location is: $(pwd)"
exit 1
die "🚨 Run this in the same folder as \"$XCPRODUCT_NAME.xcodeproj\"!"
else
echo -e "👍 Found $YELLOW$XCPRODUCT_NAME.xcodeproj$NOCOLOR..."
fi

echo "ℹ️ Removing deprecated XCFramework..."
executeCommand "find . -type d -name \"$XCFRAMEWORK_NAME-*.$XCFRAMEWORK_EXTENSION\" -exec rm -rf {} +"
echo "👍 Removed deprecated XCFramework"

echo "ℹ️ Setting up $TMP_DIR folder"
rm -fr "$TMP_DIR"
mkdir -p "$TMP_DIR"
Expand Down Expand Up @@ -92,24 +89,19 @@ echo "👍 Framework for macOS built for x86_64 and arm64 architectures"

# XCFramework
echo "🏗 Building XCFramework..."
xcodebuild -create-xcframework -output "$NEW_XCFRAMEWORK_NAME" \
xcodebuild -create-xcframework -output "$NEW_XCFRAMEWORK_PATH" \
-framework "$TMP_DIR"/iphoneos/"$XCPRODUCT_NAME".xcarchive/Products/Library/Frameworks/"$XCPRODUCT_NAME".framework \
-framework "$TMP_DIR"/iphonesimulator/"$XCPRODUCT_NAME".xcarchive/Products/Library/Frameworks/"$XCPRODUCT_NAME".framework \
-framework "$TMP_DIR"/macos/"$XCPRODUCT_NAME".xcarchive/Products/Library/Frameworks/"$XCPRODUCT_NAME".framework

# Zip it up
zip -r -X -q "$NEW_XCFRAMEWORK_NAME".zip "$NEW_XCFRAMEWORK_NAME"
zip -r "$NEW_XCFRAMEWORK_ARCHIVE".zip "$NEW_XCFRAMEWORK_ARCHIVE"

# Calculate checksum
swift package compute-checksum "$NEW_XCFRAMEWORK_NAME".zip > "$NEW_XCFRAMEWORK_NAME.zip.checksum"

# Print out for DEBUG purposes
echo "🔍 XCFramework information..."
executeCommand "ls -la $NEW_XCFRAMEWORK_NAME.zip"
executeCommand "tail $NEW_XCFRAMEWORK_NAME.zip.checksum"
swift package compute-checksum "$NEW_XCFRAMEWORK_ARCHIVE".zip > "$NEW_XCFRAMEWORK_ARCHIVE.zip.checksum"

# Cleanup
echo "ℹ️ Removing $TMP_DIR folder..."
rm -fr "$TMP_DIR"

echo -e "🧳 XCFramework $GREEN$NEW_XCFRAMEWORK_NAME$NOCOLOR built!"
echo -e "🧳 XCFramework $GREEN$NEW_XCFRAMEWORK_ARCHIVE$NOCOLOR built!"
2 changes: 1 addition & 1 deletion Support/Scripts/Config/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ REMOTE_REPO_BASE="[email protected]:$REPO_OWNER" # The SSH URI to the project owner

PR_HEAD_BRANCH="main" # The branch to which the changes are pushed

XCFRAMEWORK_URL_TEMPLATE="https://github.com/${REPO_OWNER}/${RELEASE_REPO_NAME}/releases/download/___VERSION_TAG___/PactSwiftMockServer-___VERSION_TAG___.xcframework.zip" # The template for the URL to the XCFramework
XCFRAMEWORK_URL_TEMPLATE="https://github.com/${REPO_OWNER}/${RELEASE_REPO_NAME}/releases/download/___VERSION_TAG___/PactSwiftMockServer-___VERSION_TAG___.zip" # The template for the URL to the XCFramework
26 changes: 10 additions & 16 deletions Support/Scripts/release
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,15 @@ function show_help {
exit 0
}


RELEASE_SOURCE_DIR="${BASH_SOURCE[0]%/*}"

if [ $# -lt 2 ]; then
show_help
fi

# "import"
source "$RELEASE_SOURCE_DIR/utils.sh"
source "$RELEASE_SOURCE_DIR/CI/version_numbers.sh"
source "$RELEASE_SOURCE_DIR/Config/config.sh"

SHOULD_BUILD_RUST_BIN=${SHOULD_BUILD_RUST_BIN:-true}

DRY_RUN=false

SHOULD_BUILD_RUST_BIN=${SHOULD_BUILD_RUST_BIN:-true}
CURRENT_BRANCH=$(git branch --show-current)
RELEASE_VERSION_PART=""
RELEASE_DESCRIPTION=""
Expand Down Expand Up @@ -163,7 +156,7 @@ function git_commit_changelog_to_xcframework_submodule {

# Commit new changelog
execute_cmd "git add \"$changelog_file\" \"$package_file\""
execute_cmd "git commit -S -m \"Release: $version_tag\""
execute_cmd "git commit -m \"Release: $version_tag\" -S"

while IFS= read -r package_swift; do
echo "$package_swift"
Expand All @@ -182,7 +175,7 @@ function git_update_main_repo_with_submodule_reference {
local version_branch="$2"

execute_cmd "git add \"$SUBMODULE_XCFRAMEWORK\""
execute_cmd "git commit -S -m \"Update submodule reference - $version_tag\""
execute_cmd "git commit -m \"Update submodule reference - $version_tag\" -S"
execute_cmd "git push --set-upstream origin \"$version_branch\""
}

Expand All @@ -195,15 +188,16 @@ function github_create_release_for {

local release_tag="$1"
local release_options="${2:-}"
local release_repo="$REPO_OWNER/$RELEASE_REPO_NAME"

# shellcheck disable=SC2153
local command="gh release create \"$release_tag\" --title \"$release_tag\" --notes-file $TAG_MESSAGE_FILE $release_options"
local command="gh release create \"$release_tag\" --title \"$release_tag\" --notes-file $TAG_MESSAGE_FILE $release_options --repo $release_repo"
execute_cmd "$command"

# Give gh a second to catch up
sleep 1
# Give it a second to create the release
execute_cmd "sleep 1"

local upload_assets="gh release upload \"$release_tag\" $VERSIONED_XCFRAMEWORK_NAME.zip $VERSIONED_XCFRAMEWORK_CHECKSUM --clobber --repo $REPO_OWNER/$RELEASE_REPO_NAME"
local upload_assets="gh release upload \"$release_tag\" $VERSIONED_XCFRAMEWORK_NAME.zip $VERSIONED_XCFRAMEWORK_CHECKSUM --clobber --repo $release_repo"
execute_cmd "$upload_assets"
}

Expand Down Expand Up @@ -342,8 +336,8 @@ VERSION_TAG=$(generate_version_number "$RELEASE_VERSION_PART" "$RELEASE_DESCRIPT
VERSION_BRANCH="rc/${VERSION_TAG// /_}"
MARKETING_VERSION=${VERSION_TAG#v}
MARKETING_VERSION=${MARKETING_VERSION%% -*}
VERSIONED_XCFRAMEWORK_NAME="$XCFRAMEWORK_NAME-$VERSION_TAG.$XCFRAMEWORK_EXTENSION"
VERSIONED_XCFRAMEWORK_CHECKSUM="$XCFRAMEWORK_NAME-$VERSION_TAG.$XCFRAMEWORK_EXTENSION.$XCFRAMEWORK_CHECKSUM_EXTENSION"
VERSIONED_XCFRAMEWORK_NAME="$XCFRAMEWORK_NAME-$VERSION_TAG"
VERSIONED_XCFRAMEWORK_CHECKSUM="$XCFRAMEWORK_NAME-$VERSION_TAG.$XCFRAMEWORK_CHECKSUM_EXTENSION"
NEW_VERSION_CHECKSUM=""

################################
Expand Down
2 changes: 1 addition & 1 deletion XCFramework
Submodule XCFramework updated 2 files
+4 −2 CHANGELOG.md
+6 −2 Package.swift
2 changes: 1 addition & 1 deletion pact-reference
Submodule pact-reference updated 116 files

0 comments on commit 63a0112

Please sign in to comment.