Skip to content

Commit 63a0112

Browse files
committed
Refactor release script
1 parent 7ba969f commit 63a0112

File tree

5 files changed

+22
-36
lines changed

5 files changed

+22
-36
lines changed

Support/Scripts/CI/build_xcframework

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ source "${BUILD_XCFRAMEWORK_SOURCE_DIR}/../Config/config.sh"
3131
XCBEAUTIFY=$(command -v xcbeautify || command -v cat)
3232

3333
XCFRAMEWORK_VERSION="$1"
34-
NEW_XCFRAMEWORK_NAME="$XCFRAMEWORK_NAME-$XCFRAMEWORK_VERSION.$XCFRAMEWORK_EXTENSION"
34+
NEW_XCFRAMEWORK_ARCHIVE="$XCFRAMEWORK_NAME-$XCFRAMEWORK_VERSION"
35+
NEW_XCFRAMEWORK_PATH="$NEW_XCFRAMEWORK_ARCHIVE/$XCFRAMEWORK_NAME.$XCFRAMEWORK_EXTENSION"
3536

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

51-
echo "ℹ️ Removing deprecated XCFramework..."
52-
executeCommand "find . -type d -name \"$XCFRAMEWORK_NAME-*.$XCFRAMEWORK_EXTENSION\" -exec rm -rf {} +"
53-
echo "👍 Removed deprecated XCFramework"
54-
5552
echo "ℹ️ Setting up $TMP_DIR folder"
5653
rm -fr "$TMP_DIR"
5754
mkdir -p "$TMP_DIR"
@@ -92,24 +89,19 @@ echo "👍 Framework for macOS built for x86_64 and arm64 architectures"
9289

9390
# XCFramework
9491
echo "🏗 Building XCFramework..."
95-
xcodebuild -create-xcframework -output "$NEW_XCFRAMEWORK_NAME" \
92+
xcodebuild -create-xcframework -output "$NEW_XCFRAMEWORK_PATH" \
9693
-framework "$TMP_DIR"/iphoneos/"$XCPRODUCT_NAME".xcarchive/Products/Library/Frameworks/"$XCPRODUCT_NAME".framework \
9794
-framework "$TMP_DIR"/iphonesimulator/"$XCPRODUCT_NAME".xcarchive/Products/Library/Frameworks/"$XCPRODUCT_NAME".framework \
9895
-framework "$TMP_DIR"/macos/"$XCPRODUCT_NAME".xcarchive/Products/Library/Frameworks/"$XCPRODUCT_NAME".framework
9996

10097
# Zip it up
101-
zip -r -X -q "$NEW_XCFRAMEWORK_NAME".zip "$NEW_XCFRAMEWORK_NAME"
98+
zip -r "$NEW_XCFRAMEWORK_ARCHIVE".zip "$NEW_XCFRAMEWORK_ARCHIVE"
10299

103100
# Calculate checksum
104-
swift package compute-checksum "$NEW_XCFRAMEWORK_NAME".zip > "$NEW_XCFRAMEWORK_NAME.zip.checksum"
105-
106-
# Print out for DEBUG purposes
107-
echo "🔍 XCFramework information..."
108-
executeCommand "ls -la $NEW_XCFRAMEWORK_NAME.zip"
109-
executeCommand "tail $NEW_XCFRAMEWORK_NAME.zip.checksum"
101+
swift package compute-checksum "$NEW_XCFRAMEWORK_ARCHIVE".zip > "$NEW_XCFRAMEWORK_ARCHIVE.zip.checksum"
110102

111103
# Cleanup
112104
echo "ℹ️ Removing $TMP_DIR folder..."
113105
rm -fr "$TMP_DIR"
114106

115-
echo -e "🧳 XCFramework $GREEN$NEW_XCFRAMEWORK_NAME$NOCOLOR built!"
107+
echo -e "🧳 XCFramework $GREEN$NEW_XCFRAMEWORK_ARCHIVE$NOCOLOR built!"

Support/Scripts/Config/config.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ REMOTE_REPO_BASE="[email protected]:$REPO_OWNER" # The SSH URI to the project owner
3131

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

34-
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
34+
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

Support/Scripts/release

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,15 @@ function show_help {
4949
exit 0
5050
}
5151

52-
5352
RELEASE_SOURCE_DIR="${BASH_SOURCE[0]%/*}"
5453

55-
if [ $# -lt 2 ]; then
56-
show_help
57-
fi
58-
5954
# "import"
6055
source "$RELEASE_SOURCE_DIR/utils.sh"
6156
source "$RELEASE_SOURCE_DIR/CI/version_numbers.sh"
6257
source "$RELEASE_SOURCE_DIR/Config/config.sh"
6358

64-
SHOULD_BUILD_RUST_BIN=${SHOULD_BUILD_RUST_BIN:-true}
65-
6659
DRY_RUN=false
67-
60+
SHOULD_BUILD_RUST_BIN=${SHOULD_BUILD_RUST_BIN:-true}
6861
CURRENT_BRANCH=$(git branch --show-current)
6962
RELEASE_VERSION_PART=""
7063
RELEASE_DESCRIPTION=""
@@ -163,7 +156,7 @@ function git_commit_changelog_to_xcframework_submodule {
163156

164157
# Commit new changelog
165158
execute_cmd "git add \"$changelog_file\" \"$package_file\""
166-
execute_cmd "git commit -S -m \"Release: $version_tag\""
159+
execute_cmd "git commit -m \"Release: $version_tag\" -S"
167160

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

184177
execute_cmd "git add \"$SUBMODULE_XCFRAMEWORK\""
185-
execute_cmd "git commit -S -m \"Update submodule reference - $version_tag\""
178+
execute_cmd "git commit -m \"Update submodule reference - $version_tag\" -S"
186179
execute_cmd "git push --set-upstream origin \"$version_branch\""
187180
}
188181

@@ -195,15 +188,16 @@ function github_create_release_for {
195188

196189
local release_tag="$1"
197190
local release_options="${2:-}"
191+
local release_repo="$REPO_OWNER/$RELEASE_REPO_NAME"
198192

199193
# shellcheck disable=SC2153
200-
local command="gh release create \"$release_tag\" --title \"$release_tag\" --notes-file $TAG_MESSAGE_FILE $release_options"
194+
local command="gh release create \"$release_tag\" --title \"$release_tag\" --notes-file $TAG_MESSAGE_FILE $release_options --repo $release_repo"
201195
execute_cmd "$command"
202196

203-
# Give gh a second to catch up
204-
sleep 1
197+
# Give it a second to create the release
198+
execute_cmd "sleep 1"
205199

206-
local upload_assets="gh release upload \"$release_tag\" $VERSIONED_XCFRAMEWORK_NAME.zip $VERSIONED_XCFRAMEWORK_CHECKSUM --clobber --repo $REPO_OWNER/$RELEASE_REPO_NAME"
200+
local upload_assets="gh release upload \"$release_tag\" $VERSIONED_XCFRAMEWORK_NAME.zip $VERSIONED_XCFRAMEWORK_CHECKSUM --clobber --repo $release_repo"
207201
execute_cmd "$upload_assets"
208202
}
209203

@@ -342,8 +336,8 @@ VERSION_TAG=$(generate_version_number "$RELEASE_VERSION_PART" "$RELEASE_DESCRIPT
342336
VERSION_BRANCH="rc/${VERSION_TAG// /_}"
343337
MARKETING_VERSION=${VERSION_TAG#v}
344338
MARKETING_VERSION=${MARKETING_VERSION%% -*}
345-
VERSIONED_XCFRAMEWORK_NAME="$XCFRAMEWORK_NAME-$VERSION_TAG.$XCFRAMEWORK_EXTENSION"
346-
VERSIONED_XCFRAMEWORK_CHECKSUM="$XCFRAMEWORK_NAME-$VERSION_TAG.$XCFRAMEWORK_EXTENSION.$XCFRAMEWORK_CHECKSUM_EXTENSION"
339+
VERSIONED_XCFRAMEWORK_NAME="$XCFRAMEWORK_NAME-$VERSION_TAG"
340+
VERSIONED_XCFRAMEWORK_CHECKSUM="$XCFRAMEWORK_NAME-$VERSION_TAG.$XCFRAMEWORK_CHECKSUM_EXTENSION"
347341
NEW_VERSION_CHECKSUM=""
348342

349343
################################

XCFramework

pact-reference

Submodule pact-reference updated 116 files

0 commit comments

Comments
 (0)