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

Add a workflow that builds and publishes a release via GitHub Actions #1908

Merged
merged 47 commits into from
Aug 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
444d6c1
Add a workflow that builds and publishes a release via GitHub Actions
tonyarnold Jul 26, 2021
3176c81
Add an override to release tag moving script for CI
tonyarnold Jul 26, 2021
1131e17
Use the makefile, and push the moved tag to GitHub as necessary
tonyarnold Jul 26, 2021
9a5e5cb
Only push the moved tag back to GitHub
tonyarnold Jul 26, 2021
c8c207b
Make the workflow draft a release
tonyarnold Jul 27, 2021
2008109
Rename workflow to more closely match the intent
tonyarnold Jul 27, 2021
fe45429
Lock to using Xcode 12.5.1 to build & draft releases
tonyarnold Jul 27, 2021
c1a3b37
Use ditto rather than zip to compress the Swift Package binary artefacts
tonyarnold Jul 28, 2021
41f1f74
Restore original logic in release-move-tag
tonyarnold Jul 28, 2021
3607504
Add a version suffix build setting SPARKLE_VERSION_SUFFIX to SPARKLE_…
tonyarnold Aug 5, 2021
5b10c2d
Use the recommended MARKETING_VERSION build setting for CFBundleShort…
tonyarnold Aug 5, 2021
3994836
Set DYLIB_CURRENT_VERSION to SPARKLE_VERSION
tonyarnold Aug 5, 2021
387376e
Derive the DYLIB_COMPATIBILITY_VERSION from SPARKLE_VERSION_MAJOR
tonyarnold Aug 5, 2021
0a02bee
Extract the marketing version from the Xcode project, and use it to p…
tonyarnold Aug 5, 2021
5ec3e43
Use everything after the last "-" when extracting the git commit hash
tonyarnold Aug 5, 2021
346e051
Automatically determine if the current release is a prerelease
tonyarnold Aug 5, 2021
908c82a
Update GitHub Actions steps to use the new environment files format
tonyarnold Aug 11, 2021
12bee66
Revert "Derive the DYLIB_COMPATIBILITY_VERSION from SPARKLE_VERSION_M…
tonyarnold Aug 11, 2021
b1247d2
Revert "Set DYLIB_CURRENT_VERSION to SPARKLE_VERSION"
tonyarnold Aug 11, 2021
331c419
Hardcode the CURRENT_PROJECT_VERSION to 2000
tonyarnold Aug 11, 2021
5b4f6f5
Remove the unnecessary SPARKLE_VERSION build setting
tonyarnold Aug 11, 2021
f9ab695
Use MARKETING_VERSION in the release package script
tonyarnold Aug 11, 2021
41cd3a9
Use MARKETING_VERSION in the set git version info script
tonyarnold Aug 11, 2021
111c10a
Use a version format consistent with the usual contents of MARKETING_…
tonyarnold Aug 11, 2021
98824c8
Capture everything past the second dash when determining the git vers…
tonyarnold Aug 11, 2021
146081f
Ensure that we skip the confirmation when moving the release tag info…
tonyarnold Aug 11, 2021
3a077df
Replace cut command with sed for more resilient extraction of the Xco…
tonyarnold Aug 11, 2021
eeeb5ac
Don't skip over checking the git tag when making the release package
tonyarnold Aug 11, 2021
6b834ba
Move the code signature verification code into a bash function for reuse
tonyarnold Aug 16, 2021
24398e0
Also verify the Swift package manager binary artifact binary
tonyarnold Aug 16, 2021
76c6668
Remove the Xcode archive when we've finished with it
tonyarnold Aug 16, 2021
451bb18
Use MARKETING_VERSION in Sparkle's user agent string
tonyarnold Aug 16, 2021
488b0da
Add comments to the Xcode configuration version information
tonyarnold Aug 16, 2021
48d1db9
Fix check for SPARKLE_VERSION_SUFFIX in the draft workdlow
tonyarnold Aug 16, 2021
5388352
Create a temporary Git tag to use during the draft release workflow
tonyarnold Aug 16, 2021
d042455
Use sed when extracting SPARKLE_VERSION_SUFFIX from the Xcode project
tonyarnold Aug 16, 2021
92afe95
Add a comment about not using MARKETING_VERSION in any other build se…
tonyarnold Aug 16, 2021
ee45e4d
Move the tagging step prior to the build step
tonyarnold Aug 17, 2021
a31f588
Move the tagging back to after the version information extraction
tonyarnold Aug 23, 2021
86a45f4
Remove the staged SPM build directory after the signature has been ve…
tonyarnold Aug 23, 2021
5d24611
Use grep to more safely extract Xcode build variables
tonyarnold Aug 23, 2021
ac8a73b
Update to suggested implementation for SPUXPCValidateServiceIfBundleE…
tonyarnold Aug 23, 2021
6d9cd6f
Scan lightweight tags when generating Swift Package manifest
tonyarnold Aug 23, 2021
dc7fbbd
Apply patch to regenerate the podspec when updating the Swift package
tonyarnold Aug 23, 2021
90d0cd8
Extract the SPM archive and verify that instead of the newly compiled…
tonyarnold Aug 23, 2021
c99a592
Don't remove the Xcode archive when making a release package
tonyarnold Aug 23, 2021
45b97c5
Fix ditto usage in release package script
tonyarnold Aug 23, 2021
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
65 changes: 65 additions & 0 deletions .github/workflows/create-draft-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: "Create Draft Release"

env:
BUILDDIR: "build"
DEVELOPER_DIR: "/Applications/Xcode_12.5.1.app/Contents/Developer"

on:
workflow_dispatch

concurrency:
group: publish-release-${{ github.ref }}
cancel-in-progress: true

jobs:
release:
name: "Publish binaries for release"
runs-on: macos-11

steps:
- name: "Checkout sources"
uses: actions/checkout@v2
with:
submodules: true
fetch-depth: 0

- name: "Extract version information from project"
run: |
MARKETING_VERSION=$(xcrun xcodebuild -showBuildSettings -project Sparkle.xcodeproj | grep MARKETING_VERSION | grep -m 1 '^[[:space:]]*MARKETING_VERSION')
echo "MARKETING_VERSION=${MARKETING_VERSION}" >> $GITHUB_ENV~

- name: "Determine if this is a pre-release version"
run: |
SPARKLE_VERSION_SUFFIX=$(xcrun xcodebuild -showBuildSettings -project Sparkle.xcodeproj | grep SPARKLE_VERSION_SUFFIX | grep -m 1 '^[[:space:]]*SPARKLE_VERSION_SUFFIX')
if [[ ! -z "$SPARKLE_VERSION_SUFFIX" ]]; then
echo "PRERELEASE_VERSION=true" >> $GITHUB_ENV
else
echo "PRERELEASE_VERSION=false" >> $GITHUB_ENV
fi

- name: "Create a temporary Git tag"
run: git tag "$MARKETING_VERSION"

- name: "Build release distribution"
run: make release
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
MARKETING_VERSION: ${{ env.MARKETING_VERSION }}
SPARKLE_VERSION_SUFFIX: ${{ env.SPARKLE_VERSION_SUFFIX }}

- name: "Push the updated Swift package description"
run: git push

- name: "Draft a release"
uses: softprops/action-gh-release@v1
with:
draft: true
prerelease: ${{ env.PRERELEASE_VERSION }}
name: "Sparkle ${{ env.MARKETING_VERSION }}"
tag_name: ${{ env.MARKETING_VERSION }}
fail_on_unmatched_files: true
files: |
build/Build/Products/Release/Sparkle-*.tar.xz
build/Build/Products/Release/Sparkle-for-Swift-Package-Manager.zip
13 changes: 10 additions & 3 deletions Configurations/ConfigCommon.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,19 @@ SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0

SPARKLE_ICON_NAME = AppIcon

// If you change any of these version details, you must increase CURRENT_PROJECT_VERSION
SPARKLE_VERSION_MAJOR = 2
SPARKLE_VERSION_MINOR = 0
SPARKLE_VERSION_PATCH = 0
SPARKLE_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)

CURRENT_PROJECT_VERSION = $(SPARKLE_VERSION)
// This should be in SemVer format or empty, ie. "-beta.1"
SPARKLE_VERSION_SUFFIX =

CURRENT_PROJECT_VERSION = 2000

// Please be careful not to use MARKETING_VERSION as part of any other build settings.
// We extract this value during builds, and they would be exported at the same time.
MARKETING_VERSION = $(SPARKLE_VERSION_MAJOR).$(SPARKLE_VERSION_MINOR).$(SPARKLE_VERSION_PATCH)$(SPARKLE_VERSION_SUFFIX)
ALWAYS_SEARCH_USER_PATHS = NO
ENABLE_STRICT_OBJC_MSGSEND = YES
GCC_SYMBOLS_PRIVATE_EXTERN = YES
Expand All @@ -38,7 +45,7 @@ INSTALLER_STATUS_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerStatus
INSTALLER_LAUNCHER_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.InstallerLauncher
DOWNLOADER_BUNDLE_ID = ${XPC_SERVICE_BUNDLE_ID_PREFIX}.Downloader

GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_BUILD_UI_BITS=$(SPARKLE_BUILD_UI_BITS) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" DOWNLOADER_BUNDLE_ID=\"${DOWNLOADER_BUNDLE_ID}\"
GCC_PREPROCESSOR_DEFINITIONS_COMMON = SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME=$(SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME) SPARKLE_BUILD_UI_BITS=$(SPARKLE_BUILD_UI_BITS) SPARKLE_BUNDLE_IDENTIFIER=\"$(SPARKLE_BUNDLE_IDENTIFIER)\" CURRENT_PROJECT_VERSION=\"$(CURRENT_PROJECT_VERSION)\" MARKETING_VERSION=\"$(MARKETING_VERSION)\" SPARKLE_RELAUNCH_TOOL_NAME=\"$(SPARKLE_RELAUNCH_TOOL_NAME)\" SPARKLE_INSTALLER_PROGRESS_TOOL_NAME=\"$(SPARKLE_INSTALLER_PROGRESS_TOOL_NAME)\" SPARKLE_ICON_NAME=\"$(SPARKLE_ICON_NAME)\" INSTALLER_LAUNCHER_BUNDLE_ID=\"${INSTALLER_LAUNCHER_BUNDLE_ID}\" INSTALLER_CONNECTION_BUNDLE_ID=\"${INSTALLER_CONNECTION_BUNDLE_ID}\" INSTALLER_STATUS_BUNDLE_ID=\"${INSTALLER_STATUS_BUNDLE_ID}\" DOWNLOADER_BUNDLE_ID=\"${DOWNLOADER_BUNDLE_ID}\"

CODE_SIGN_IDENTITY = -
SDKROOT = macosx
Expand Down
107 changes: 62 additions & 45 deletions Configurations/make-release-package.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
#!/bin/bash
set -e

if [ "$ACTION" = "" ] ; then
# If using cocoapods, sanity check that the Podspec version matches the Sparkle version
if [ -x "$(command -v pod)" ]; then
spec_version=$(printf "require 'cocoapods'\nspec = %s\nprint spec.version" "$(cat "$SRCROOT/Sparkle.podspec")" | LANG=en_US.UTF-8 ruby)
if [ "$spec_version" != "$CURRENT_PROJECT_VERSION" ] ; then
echo "podspec version '$spec_version' does not match the current project version '$CURRENT_PROJECT_VERSION'" >&2
exit 1
fi
# Tests the code signing validity of the extracted products within the provided path.
# This guards against our archives being corrupt / created incorrectly.
function verify_code_signatures() {
verification_directory="$1"

if [[ -z "$verification_directory" ]]; then
echo "Provided verification directory does not exist" >&2
exit 1
fi

# Search the current directory for all instances of the framework to verify them (XCFrameworks can have multiple copies of a framework for different platforms).
find "${verification_directory}" -name "Sparkle.framework" -type d -exec codesign --verify -vvv --deep {} \;
codesign --verify -vvv --deep "${verification_directory}/XPCServices/org.sparkle-project.Downloader.xpc"
codesign --verify -vvv --deep "${verification_directory}/XPCServices/org.sparkle-project.InstallerConnection.xpc"
codesign --verify -vvv --deep "${verification_directory}/XPCServices/org.sparkle-project.InstallerLauncher.xpc"
codesign --verify -vvv --deep "${verification_directory}/XPCServices/org.sparkle-project.InstallerStatus.xpc"
codesign --verify -vvv --deep "${verification_directory}/sparkle.app"
codesign --verify -vvv --deep "${verification_directory}/Sparkle Test App.app"
codesign --verify -vvv --deep "${verification_directory}/bin/BinaryDelta"
codesign --verify -vvv --deep "${verification_directory}/bin/generate_appcast"
codesign --verify -vvv --deep "${verification_directory}/bin/sign_update"
codesign --verify -vvv --deep "${verification_directory}/bin/generate_keys"
}

if [ "$ACTION" = "" ] ; then
rm -rf "$CONFIGURATION_BUILD_DIR/staging"
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.xz"
rm -f "Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2"
rm -f "Sparkle-$MARKETING_VERSION.tar.xz"
rm -f "Sparkle-$MARKETING_VERSION.tar.bz2"
rm -f "Sparkle-for-Swift-Package-Manager.zip"

mkdir -p "$CONFIGURATION_BUILD_DIR/staging"
Expand Down Expand Up @@ -80,72 +95,74 @@ if [ "$ACTION" = "" ] ; then

# Sorted file list groups similar files together, which improves tar compression
if [ "$XZ_EXISTS" -eq 1 ] ; then
find . \! -type d | rev | sort | rev | tar cv --files-from=- | xz -9 > "../Sparkle-$CURRENT_PROJECT_VERSION.tar.xz"
find . \! -type d | rev | sort | rev | tar cv --files-from=- | xz -9 > "../Sparkle-$MARKETING_VERSION.tar.xz"

# Copy archived distribution for CI
cp -f "../Sparkle-$CURRENT_PROJECT_VERSION.tar.xz" "../sparkle-dist.tar.xz"
cp -f "../Sparkle-$MARKETING_VERSION.tar.xz" "../sparkle-dist.tar.xz"

# Extract archive for testing binary validity
tar -xf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.xz" -C "/tmp/sparkle-extract"
tar -xf "../Sparkle-$MARKETING_VERSION.tar.xz" -C "/tmp/sparkle-extract"
else
# Fallback to bz2 compression if xz utility is not available
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2" --files-from=-
find . \! -type d | rev | sort | rev | tar cjvf "../Sparkle-$MARKETING_VERSION.tar.bz2" --files-from=-

# Extract archive for testing binary validity
tar -xf "../Sparkle-$CURRENT_PROJECT_VERSION.tar.bz2" -C "/tmp/sparkle-extract"
tar -xf "../Sparkle-$MARKETING_VERSION.tar.bz2" -C "/tmp/sparkle-extract"
fi

# Test code signing validity of the extracted products
# This guards against our archives being corrupt / created incorrectly
codesign --verify -vvv --deep "/tmp/sparkle-extract/Sparkle.framework"
codesign --verify -vvv --deep "/tmp/sparkle-extract/XPCServices/org.sparkle-project.Downloader.xpc"
codesign --verify -vvv --deep "/tmp/sparkle-extract/XPCServices/org.sparkle-project.InstallerConnection.xpc"
codesign --verify -vvv --deep "/tmp/sparkle-extract/XPCServices/org.sparkle-project.InstallerLauncher.xpc"
codesign --verify -vvv --deep "/tmp/sparkle-extract/XPCServices/org.sparkle-project.InstallerStatus.xpc"
codesign --verify -vvv --deep "/tmp/sparkle-extract/sparkle.app"
codesign --verify -vvv --deep "/tmp/sparkle-extract/Sparkle Test App.app"
codesign --verify -vvv --deep "/tmp/sparkle-extract/bin/BinaryDelta"
codesign --verify -vvv --deep "/tmp/sparkle-extract/bin/generate_appcast"
codesign --verify -vvv --deep "/tmp/sparkle-extract/bin/sign_update"
codesign --verify -vvv --deep "/tmp/sparkle-extract/bin/generate_keys"
verify_code_signatures "/tmp/sparkle-extract"

rm -rf "/tmp/sparkle-extract"
rm -rf "$CONFIGURATION_BUILD_DIR/staging"

# Generate zip containing the xcframework for SPM
rm -rf "/tmp/sparkle-spm-extract"
mkdir -p "/tmp/sparkle-spm-extract"
cd "$CONFIGURATION_BUILD_DIR/staging-spm"
#rm -rf "$CONFIGURATION_BUILD_DIR/Sparkle.xcarchive"
zip -rqyX -9 "../Sparkle-for-Swift-Package-Manager.zip" *
# rm -rf "$CONFIGURATION_BUILD_DIR/Sparkle.xcarchive"
ditto -c -k --zlibCompressionLevel 9 --rsrc . "../Sparkle-for-Swift-Package-Manager.zip"

# Test code signing validity of the extracted Swift package
# This guards against our archives being corrupt / created incorrectly
ditto -x -k "../Sparkle-for-Swift-Package-Manager.zip" "/tmp/sparkle-spm-extract"
verify_code_signatures "/tmp/sparkle-spm-extract"

# GitHub actions set the CI environment variable to true
if [ "$CI" != true ]; then
# Get latest git tag
cd "$SRCROOT"
latest_git_tag=$(git describe --tags --abbrev=0)
# Check semantic versioning
if [[ $latest_git_tag =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
echo "Tag $latest_git_tag follows semantic versioning"
else
echo "ERROR: Tag $latest_git_tag does not follow semantic versioning! SPM will not be able to resolve the repository" >&2
exit 1
fi
rm -rf "/tmp/sparkle-spm-extract"
rm -rf "$CONFIGURATION_BUILD_DIR/staging-spm"

# Get latest git tag
cd "$SRCROOT"
latest_git_tag=$(git describe --tags --abbrev=0)

# Check semantic versioning
if [[ $latest_git_tag =~ ^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)(-((0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9][0-9]*|[0-9]*[a-zA-Z-][0-9a-zA-Z-]*))*))?(\\+([0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*))?$ ]]; then
echo "Tag $latest_git_tag follows semantic versioning"
else
# Dummy placeholder for CI test builds as we don't really need to update Package.swift for building and testing purposes
latest_git_tag="CI_BUILD"
echo "ERROR: Tag $latest_git_tag does not follow semantic versioning! SPM will not be able to resolve the repository" >&2
exit 1
fi
# Generate new Package manifest

# Generate new Package manifest and podspec
cd "$CONFIGURATION_BUILD_DIR"
cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR"
cp "$SRCROOT/Sparkle.podspec" "$CONFIGURATION_BUILD_DIR"
if [ "$XCODE_VERSION_MAJOR" -ge "1200" ]; then
# is equivalent to shasum -a 256 FILE
spm_checksum=$(swift package compute-checksum "Sparkle-for-Swift-Package-Manager.zip")
rm -rf ".build"
sed -E -i '' -e "/let tag/ s/\".+\"/\"$latest_git_tag\"/" -e "/let version/ s/\".+\"/\"$CURRENT_PROJECT_VERSION\"/" -e "/let checksum/ s/[[:xdigit:]]{64}/$spm_checksum/" "Package.swift"
sed -E -i '' -e "/let tag/ s/\".+\"/\"$latest_git_tag\"/" -e "/let version/ s/\".+\"/\"$MARKETING_VERSION\"/" -e "/let checksum/ s/[[:xdigit:]]{64}/$spm_checksum/" "Package.swift"
cp "Package.swift" "$SRCROOT"
echo "Package.swift updated with the following values:"
echo "Version: $CURRENT_PROJECT_VERSION"
echo "Version: $MARKETING_VERSION"
echo "Tag: $latest_git_tag"
echo "Checksum: $spm_checksum"

sed -E -i '' -e "/s\.version.+=/ s/\".+\"/\"$MARKETING_VERSION\"/" "Sparkle.podspec"
cp "Sparkle.podspec" "$SRCROOT"
echo "Sparkle.podspec updated with following values:"
echo "Version: $MARKETING_VERSION"
else
echo "warning: Xcode version $XCODE_VERSION_ACTUAL does not support computing checksums for Swift Packages. Please update the Package manifest manually."
fi
Expand Down
33 changes: 20 additions & 13 deletions Configurations/release-move-tag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,32 @@
set -e

# Convenience script to automatically commit Package.swift after updating the checksum and move the latest tag
latest_git_tag=$(git describe --abbrev=0) # gets the latest tag name
latest_git_tag=$(git describe --tags --abbrev=0) # gets the latest tag name
commits_since_tag=$(git rev-list ${latest_git_tag}.. --count)

function move_tag() {
long_message=$(git tag -n99 -l $latest_git_tag) # gets corresponding message
long_message=${long_message/$latest_git_tag} # trims tag name
long_message="$(echo -e "${long_message}" | sed -e 's/^[[:space:]]*//')" # trim leading whitespace
git add Package.swift Sparkle.podspec
git commit -m "Update Package.swift and Sparkle.podspec for version ${latest_git_tag}"
git tag -fa $latest_git_tag -m "${long_message}"
echo "Package.swift and Sparkle.podspec committed and tag '$latest_git_tag' moved."
}

if [ "$commits_since_tag" -gt 0 ]; then
# If there have been commits since the latest tag, it's highly likely that we did not intend to do a full release
echo "WARNING: $commits_since_tag commit(s) since tag '$latest_git_tag'. Did you tag a new version?"
echo "Package.swift has not been committed and tag has not been moved."
elif [ "$CI" == true ]; then
move_tag
else
# TODO: add sanity check to see if version is actually being updated or not?
read -p "Do you want to commit changes to Package.swift and force move tag '$latest_git_tag'? (required for SPM release) [Y/n]" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Nn]$ ]]; then
echo "Package.swift has not been committed and tag has not been moved."
# TODO: add sanity check to see if version is actually being updated or not?
read -p "Do you want to commit changes to Package.swift and Sparkle.podspec, and force move tag '$latest_git_tag'? (required for official release) [Y/n]" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
move_tag
else
long_message=$(git tag -n99 -l $latest_git_tag) # gets corresponding message
long_message=${long_message/$latest_git_tag} # trims tag name
long_message="$(echo -e "${long_message}" | sed -e 's/^[[:space:]]*//')" # trim leading whitespace
git add Package.swift
git commit -m "Update Package.swift"
git tag -fa $latest_git_tag -m "${long_message}"
echo "Package.swift committed and tag '$latest_git_tag' moved."
echo "Package.swift and Sparkle.podspec have not been committed and tag has not been moved."
fi
fi
10 changes: 5 additions & 5 deletions Configurations/set-git-version-info.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ fi
if [ -z "$SRCROOT" ] || \
[ -z "$BUILT_PRODUCTS_DIR" ] || \
[ -z "$INFOPLIST_PATH" ] || \
[ -z "$CURRENT_PROJECT_VERSION" ]; then
[ -z "$MARKETING_VERSION" ]; then
echo "$0: Must be run from Xcode!" 1>&2
exit 1
fi

version="$CURRENT_PROJECT_VERSION"
version="$MARKETING_VERSION"

# Get version in format 1.x.x-commits-hash
gitversion=$( cd "$SRCROOT"; git describe --tags --match '[12].*' || true )
Expand All @@ -22,10 +22,10 @@ if [ -z "$gitversion" ] ; then
exit 0
fi

# remove everything before the first "-" to keep the hash part only
versionsuffix=${gitversion#*-};
# remove everything before the second last "-" to keep the hash part only
versionsuffix=$( echo "${gitversion}" | sed -E 's/.+((-[^.]+){2})$/\1/' )
if [ "$versionsuffix" != "$gitversion" ]; then
version="$version $versionsuffix"
version="$version$versionsuffix"
fi

# and use it to set the CFBundleShortVersionString value
Expand Down
2 changes: 1 addition & 1 deletion Downloader/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion InstallerConnection/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion InstallerLauncher/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion InstallerStatus/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion Sparkle/InstallerProgress/InstallerProgress-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>${CURRENT_PROJECT_VERSION}</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
3 changes: 1 addition & 2 deletions Sparkle/SPUUpdater.m
Original file line number Diff line number Diff line change
Expand Up @@ -770,8 +770,7 @@ - (NSString *)userAgentString
return customUserAgentString;
}

NSString *version = [self.sparkleBundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey];
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [self.host name], [self.host displayVersion], version ? version : @"?"];
NSString *userAgent = [NSString stringWithFormat:@"%@/%@ Sparkle/%@", [self.host name], [self.host displayVersion], @""MARKETING_VERSION];
NSData *cleanedAgent = [userAgent dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *result = @"";
Expand Down
Loading