From 017f8f733ee7140af87d99119680f66b45cf5406 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 11 Dec 2021 11:07:39 -0800 Subject: [PATCH] Add and update Carthage binary json distribution file on release (#2036) --- .github/workflows/create-draft-release.yml | 2 +- Carthage-dev.json | 1 + Configurations/link-tools.sh | 7 +++++++ Configurations/make-release-package.sh | 10 ++++++++-- Configurations/release-move-tag.sh | 10 +++++----- Configurations/update-carthage.py | 20 ++++++++++++++++++++ README.markdown | 2 +- 7 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 Carthage-dev.json create mode 100755 Configurations/update-carthage.py diff --git a/.github/workflows/create-draft-release.yml b/.github/workflows/create-draft-release.yml index 7bb02c30..44b67342 100644 --- a/.github/workflows/create-draft-release.yml +++ b/.github/workflows/create-draft-release.yml @@ -80,7 +80,7 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }} - - name: "Push the updated Swift package description" + - name: "Push the updated package description" env: GITHUB_TOKEN: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }} run: git push diff --git a/Carthage-dev.json b/Carthage-dev.json new file mode 100644 index 00000000..bfb7f948 --- /dev/null +++ b/Carthage-dev.json @@ -0,0 +1 @@ +{"1.27.1": "https://github.com/sparkle-project/Sparkle/releases/download/1.27.1/Sparkle-1.27.1.tar.xz", "2.0.0-beta.6": "https://github.com/sparkle-project/Sparkle/releases/download/2.0.0-beta.6/Sparkle-2.0.0-beta.6.tar.xz"} \ No newline at end of file diff --git a/Configurations/link-tools.sh b/Configurations/link-tools.sh index c1346277..b352a373 100755 --- a/Configurations/link-tools.sh +++ b/Configurations/link-tools.sh @@ -1,5 +1,12 @@ #!/bin/sh +# If Carthage is trying to build us, it won't preserve code signing information from our bundled tools properly +# Building Sparkle from source with Carthage is thus not supported +if [ "$CARTHAGE" = "YES" ]; then + echo "Error: Building Sparkle from source using Carthage is not supported. Please visit https://sparkle-project.org/documentation/ for proper Carthage integration." + exit 1 +fi + # Create symlinks to our helper tools in Sparkle framework bundle # so URLForAuxiliaryExecutable: will pick up the tools. Doing this is supported in the Code Signing in Depth guide. diff --git a/Configurations/make-release-package.sh b/Configurations/make-release-package.sh index 9930392e..9dd2c833 100755 --- a/Configurations/make-release-package.sh +++ b/Configurations/make-release-package.sh @@ -134,10 +134,12 @@ if [ "$ACTION" = "" ] ; then exit 1 fi - # Generate new Package manifest and podspec + # Generate new Package manifest, podspec, and carthage files cd "$CONFIGURATION_BUILD_DIR" cp "$SRCROOT/Package.swift" "$CONFIGURATION_BUILD_DIR" cp "$SRCROOT/Sparkle.podspec" "$CONFIGURATION_BUILD_DIR" + cp "$SRCROOT/Carthage-dev.json" "$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") @@ -150,8 +152,12 @@ if [ "$ACTION" = "" ] ; then echo "Checksum: $spm_checksum" sed -E -i '' -e "/s\.version.+=/ s/\".+\"/\"$MARKETING_VERSION\"/" "Sparkle.podspec" + + "$SRCROOT/Configurations/update-carthage.py" "Carthage-dev.json" "$MARKETING_VERSION" cp "Sparkle.podspec" "$SRCROOT" - echo "Sparkle.podspec updated with following values:" + # Note the Carthage-dev.json file will finally be copied to the website repo in Carthage/Sparkle.json in the end + cp "Carthage-dev.json" "$SRCROOT" + echo "Sparkle.podspec and Carthage-dev.json 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." diff --git a/Configurations/release-move-tag.sh b/Configurations/release-move-tag.sh index 12d336ae..73716e73 100755 --- a/Configurations/release-move-tag.sh +++ b/Configurations/release-move-tag.sh @@ -9,8 +9,8 @@ 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 add Package.swift Sparkle.podspec Carthage-dev.json + git commit -m "Update Package management files 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." } @@ -18,16 +18,16 @@ function move_tag() { 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." + echo "Package management files have 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 Sparkle.podspec, and force move tag '$latest_git_tag'? (required for official release) [Y/n]" -n 1 -r + read -p "Do you want to commit changes to Package.swift, Sparkle.podspec, Carthage-dev.json 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 - echo "Package.swift and Sparkle.podspec have not been committed and tag has not been moved." + echo "Package.swift, Sparkle.podspec, and Carthage-dev.json have not been committed and tag has not been moved." fi fi diff --git a/Configurations/update-carthage.py b/Configurations/update-carthage.py new file mode 100755 index 00000000..bb8944f8 --- /dev/null +++ b/Configurations/update-carthage.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +import os, sys, json + +if len(sys.argv) < 3: + print("Usage: path-to-carthage-file release-tag") + sys.exit(1) + +carthage_file = sys.argv[1] +release_tag = sys.argv[2] + +with open(carthage_file, "r") as json_file: + data = json.load(json_file) + if release_tag in data: + sys.exit(0) + +with open(carthage_file, "w") as json_file: + data[release_tag] = "https://github.com/sparkle-project/Sparkle/releases/download/" + release_tag + "/Sparkle-" + release_tag + ".tar.xz" + + json.dump(data, json_file) diff --git a/README.markdown b/README.markdown index 1750d247..7cf2d059 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,4 @@ -# Sparkle 2 (Beta) ![Build Status](https://github.com/sparkle-project/Sparkle/workflows/Build%20%26%20Tests/badge.svg?branch=2.x) [![CocoaPods](https://img.shields.io/cocoapods/v/Sparkle.svg?cacheSeconds=86400)]() +# Sparkle 2 (Beta) ![Build Status](https://github.com/sparkle-project/Sparkle/workflows/Build%20%26%20Tests/badge.svg?branch=2.x) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods](https://img.shields.io/cocoapods/v/Sparkle.svg?cacheSeconds=86400)]() Secure and reliable software update framework for macOS.