From 4a00b97592b0267eb9a48fb812644e893edf95a5 Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 30 Oct 2021 22:55:50 -0700 Subject: [PATCH] Add project version inputs to create-draft-release workflow (1.x) (#1999) --- .github/workflows/create-draft-release.yml | 45 +++++++++++++++++----- Configurations/ConfigCommon.xcconfig | 2 + 2 files changed, 37 insertions(+), 10 deletions(-) diff --git a/.github/workflows/create-draft-release.yml b/.github/workflows/create-draft-release.yml index 1fa8f6e7..0d7ac1cb 100644 --- a/.github/workflows/create-draft-release.yml +++ b/.github/workflows/create-draft-release.yml @@ -5,7 +5,22 @@ env: DEVELOPER_DIR: "/Applications/Xcode_13.1.app/Contents/Developer" on: - workflow_dispatch + workflow_dispatch: + inputs: + marketingVersion: + description: "Marketing Version" + required: true + default: "" + + prereleaseSuffix: + description: "Pre-release Suffix" + required: false + default: "" + + buildVersion: + description: "Product Build" + required: true + default: "" concurrency: group: publish-release-${{ github.ref }} @@ -27,16 +42,26 @@ jobs: - name: "Extract latest changes from CHANGELOG" run: | ./Configurations/generate_latest_changes.py > latest-changes.txt - - - name: "Extract version information from project" + + - name: "Overwrite project versions in project" run: | - MARKETING_VERSION=$(xcrun xcodebuild -showBuildSettings -project Sparkle.xcodeproj | grep -m 1 '^[[:space:]]*MARKETING_VERSION' | sed -E 's/.+=[[:space:]]+(.*)$/\1/') - echo "MARKETING_VERSION=${MARKETING_VERSION}" >> $GITHUB_ENV + IFS='.' read major minor patch <<< "${{ github.event.inputs.marketingVersion }}" + sed -E -i '' "s/SPARKLE_VERSION_MAJOR =.+/SPARKLE_VERSION_MAJOR = $major/g" ./Configurations/ConfigCommon.xcconfig + sed -E -i '' "s/SPARKLE_VERSION_MINOR =.+/SPARKLE_VERSION_MINOR = $minor/g" ./Configurations/ConfigCommon.xcconfig + sed -E -i '' "s/SPARKLE_VERSION_PATCH =.+/SPARKLE_VERSION_PATCH = $patch/g" ./Configurations/ConfigCommon.xcconfig + + if [[ ! -z "${{ github.event.inputs.prereleaseSuffix }}" ]]; then + sed -E -i '' "s/SPARKLE_VERSION_SUFFIX =.*/SPARKLE_VERSION_SUFFIX = ${{ github.event.inputs.prereleaseSuffix }}/g" ./Configurations/ConfigCommon.xcconfig + else + sed -E -i '' "s/SPARKLE_VERSION_SUFFIX =.*/SPARKLE_VERSION_SUFFIX =/g" ./Configurations/ConfigCommon.xcconfig + fi + + sed -E -i '' "s/CURRENT_PROJECT_VERSION =.+/CURRENT_PROJECT_VERSION = ${{ github.event.inputs.buildVersion }}/g" ./Configurations/ConfigCommon.xcconfig + git add ./Configurations/ConfigCommon.xcconfig - name: "Determine if this is a pre-release version" run: | - SPARKLE_VERSION_SUFFIX=$(xcrun xcodebuild -showBuildSettings -project Sparkle.xcodeproj | grep -m 1 '^[[:space:]]*SPARKLE_VERSION_SUFFIX' | sed -E 's/.+=[[:space:]]+(.*)$/\1/') - if [[ ! -z "$SPARKLE_VERSION_SUFFIX" ]]; then + if [[ ! -z "${{ github.event.inputs.prereleaseSuffix }}" ]]; then echo "PRERELEASE_VERSION=true" >> $GITHUB_ENV else echo "PRERELEASE_VERSION=false" >> $GITHUB_ENV @@ -46,7 +71,7 @@ jobs: run: | git config user.name Sparkle-Bot git config user.email sparkle.project.bot@gmail.com - git tag "${{ env.MARKETING_VERSION }}" + git tag "${{ github.event.inputs.marketingVersion }}" - name: "Build release distribution" run: make release @@ -65,8 +90,8 @@ jobs: with: draft: true prerelease: ${{ env.PRERELEASE_VERSION }} - name: "Sparkle ${{ env.MARKETING_VERSION }}" - tag_name: ${{ env.MARKETING_VERSION }} + name: "Sparkle ${{ github.event.inputs.marketingVersion }}" + tag_name: ${{ github.event.inputs.marketingVersion }} fail_on_unmatched_files: true token: ${{ secrets.BOT_PERSONAL_ACCESS_TOKEN }} body_path: latest-changes.txt diff --git a/Configurations/ConfigCommon.xcconfig b/Configurations/ConfigCommon.xcconfig index a77e2b34..209cfd21 100644 --- a/Configurations/ConfigCommon.xcconfig +++ b/Configurations/ConfigCommon.xcconfig @@ -16,11 +16,13 @@ SPARKLE_AUTOMATED_DOWNGRADES = 0 SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME = 0 // If you change any of these version details, you must increase CURRENT_PROJECT_VERSION +// These variables must have a space after the '=' too SPARKLE_VERSION_MAJOR = 1 SPARKLE_VERSION_MINOR = 27 SPARKLE_VERSION_PATCH = 1 // This should be in SemVer format or empty, ie. "-rc.1" +// These variables must have a space after the '=' too SPARKLE_VERSION_SUFFIX = -rc.1 // This is now a monotonically increasing ID number, even across prereleases, but let's keep this below 2.0 CURRENT_PROJECT_VERSION = 1.103