From 1659c27f05f42f83f7dc41335d063b3d19d62354 Mon Sep 17 00:00:00 2001 From: Jason Morley Date: Fri, 7 Aug 2026 12:02:45 -1000 Subject: [PATCH 1/2] =?UTF-8?q?ci:=20Don=E2=80=99t=20upload=20to=20TestFli?= =?UTF-8?q?ght=20if=20the=20current=20version=20has=20already=20been=20pub?= =?UTF-8?q?lished?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/build.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/scripts/build.sh b/scripts/build.sh index c11bd55..5a14173 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -40,13 +40,17 @@ RELEASE_NOTES_TEMPLATE_PATH="$SCRIPTS_DIRECTORY/sparkle-release-notes.html" RELEASE_SCRIPT_PATH="$SCRIPTS_DIRECTORY/release.sh" +APP_STORE_APP_ID="6469060331" + IOS_XCODE_PATH=${IOS_XCODE_PATH:-/Applications/Xcode.app} MACOS_XCODE_PATH=${MACOS_XCODE_PATH:-/Applications/Xcode.app} source "$SCRIPTS_DIRECTORY/environment.sh" -# Check that the GitHub command is available on the path. +# Check the system-wide commands are available. which gh || (echo "GitHub cli (gh) not available on the path." && exit 1) +which asc || (echo "App Store Connect cli (asc) not available on the path." && exit 1) +which jq || (echo "jq not available on the path." && exit 1) # Process the command line arguments. POSITIONAL=() @@ -227,6 +231,31 @@ pushd "$BUILD_DIRECTORY" zip -r "$ZIP_BASENAME" . popd +# Check if we can upload to TestFlight +# App Store Connect doesn't accept submissions for published releases so we don't bother if we know it'll fail. This +# catches the scenario where we're performing builds without new features that would bump the version number. +if $UPLOAD_TO_TESTFLIGHT ; then + + export ASC_KEY_ID="$APPLE_API_KEY_ID" + export ASC_ISSUER_ID="$APPLE_API_KEY_ISSUER_ID" + export ASC_PRIVATE_KEY_PATH="$API_KEY_PATH" + export ASC_BYPASS_KEYCHAIN=1 + + PUBLISHED_VERSION=`asc versions list \ + --app "$APP_STORE_APP_ID" \ + --platform "MAC_OS" \ + --version "$VERSION_NUMBER" \ + --state "PENDING_APPLE_RELEASE,PENDING_DEVELOPER_RELEASE,PROCESSING_FOR_DISTRIBUTION,READY_FOR_DISTRIBUTION,REPLACED_WITH_NEW_VERSION" \ + --output json \ + | jq -r 'first(.data[].attributes.versionString) // ""'` + + if [ -n "$PUBLISHED_VERSION" ] ; then + echo "Version $VERSION_NUMBER has already been published to the App Store; skipping TestFlight upload." + UPLOAD_TO_TESTFLIGHT=false + fi + +fi + if $UPLOAD_TO_TESTFLIGHT ; then # Upload the macOS build. From ffce4b2f4ad67e33e4c770ebe6925e7489e1eb4d Mon Sep 17 00:00:00 2001 From: Jason Morley Date: Fri, 7 Aug 2026 12:12:51 -1000 Subject: [PATCH 2/2] Hoist the bundle identifier for consistency --- scripts/build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/build.sh b/scripts/build.sh index 5a14173..0185c8f 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -40,6 +40,7 @@ RELEASE_NOTES_TEMPLATE_PATH="$SCRIPTS_DIRECTORY/sparkle-release-notes.html" RELEASE_SCRIPT_PATH="$SCRIPTS_DIRECTORY/release.sh" +BUNDLE_IDENTIFIER="uk.co.jbmorley.apps.overview" APP_STORE_APP_ID="6469060331" IOS_XCODE_PATH=${IOS_XCODE_PATH:-/Applications/Xcode.app} @@ -241,6 +242,7 @@ if $UPLOAD_TO_TESTFLIGHT ; then export ASC_PRIVATE_KEY_PATH="$API_KEY_PATH" export ASC_BYPASS_KEYCHAIN=1 + # Check to see if the current version has been published. PUBLISHED_VERSION=`asc versions list \ --app "$APP_STORE_APP_ID" \ --platform "MAC_OS" \ @@ -248,7 +250,6 @@ if $UPLOAD_TO_TESTFLIGHT ; then --state "PENDING_APPLE_RELEASE,PENDING_DEVELOPER_RELEASE,PROCESSING_FOR_DISTRIBUTION,READY_FOR_DISTRIBUTION,REPLACED_WITH_NEW_VERSION" \ --output json \ | jq -r 'first(.data[].attributes.versionString) // ""'` - if [ -n "$PUBLISHED_VERSION" ] ; then echo "Version $VERSION_NUMBER has already been published to the App Store; skipping TestFlight upload." UPLOAD_TO_TESTFLIGHT=false @@ -261,7 +262,7 @@ if $UPLOAD_TO_TESTFLIGHT ; then # Upload the macOS build. xcrun altool --upload-app \ -f "$PKG_PATH" \ - --primary-bundle-id "uk.co.jbmorley.apps.overview" \ + --primary-bundle-id "$BUNDLE_IDENTIFIER" \ --apiKey "$APPLE_API_KEY_ID" \ --apiIssuer "$APPLE_API_KEY_ISSUER_ID" \ --type macos