Skip to content
Merged
Changes from all commits
Commits
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
34 changes: 32 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,18 @@ 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}
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=()
Expand Down Expand Up @@ -227,12 +232,37 @@ 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

# Check to see if the current version has been published.
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.
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
Expand Down