-
Notifications
You must be signed in to change notification settings - Fork 227
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
Autobuild: Combine and simplify Mac build scripts #2514
Merged
ann0see
merged 1 commit into
jamulussoftware:master
from
hoffie:autobuild-merge-mac-scripts
Mar 16, 2022
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
QT_DIR=/usr/local/opt/qt | ||
AQTINSTALL_VERSION=2.0.6 | ||
|
||
if [[ ! ${QT_VERSION:-} =~ [0-9]+\.[0-9]+\..* ]]; then | ||
echo "Environment variable QT_VERSION must be set to a valid Qt version" | ||
exit 1 | ||
fi | ||
if [[ ! ${jamulus_buildversionstring:-} =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then | ||
echo "Environment variable jamulus_buildversionstring has to be set to a valid version string" | ||
exit 1 | ||
fi | ||
|
||
setup() { | ||
if [[ -d "${QT_DIR}" ]]; then | ||
echo "Using Qt installation from previous run (actions/cache)" | ||
else | ||
echo "Install dependencies..." | ||
python3 -m pip install "aqtinstall==${AQTINSTALL_VERSION}" | ||
python3 -m aqt install-qt --outputdir "${QT_DIR}" mac desktop "${QT_VERSION}" --archives qtbase qttools qttranslations qtmacextras | ||
fi | ||
|
||
# Add the qt binaries to the PATH. | ||
# The clang_64 entry can be dropped when Qt <6.2 compatibility is no longer needed. | ||
export PATH="${QT_DIR}/${QT_VERSION}/macos/bin:${QT_DIR}/${QT_VERSION}/clang_64/bin:${PATH}" | ||
echo "::set-env name=PATH::${PATH}" | ||
} | ||
|
||
prepare_signing() { | ||
[[ "${SIGN_IF_POSSIBLE:-0}" == "1" ]] || return 1 | ||
|
||
# Signing was requested, now check all prerequisites: | ||
[[ -n "${MACOS_CERTIFICATE:-}" ]] || return 1 | ||
[[ -n "${MACOS_CERTIFICATE_ID:-}" ]] || return 1 | ||
[[ -n "${MACOS_CERTIFICATE_PWD:-}" ]] || return 1 | ||
[[ -n "${NOTARIZATION_PASSWORD:-}" ]] || return 1 | ||
[[ -n "${KEYCHAIN_PASSWORD:-}" ]] || return 1 | ||
|
||
echo "Signing was requested and all dependencies are satisfied" | ||
|
||
# Put the cert to a file | ||
echo "${MACOS_CERTIFICATE}" | base64 --decode > certificate.p12 | ||
|
||
# Set up a keychain for the build: | ||
security create-keychain -p "${KEYCHAIN_PASSWORD}" build.keychain | ||
security default-keychain -s build.keychain | ||
security unlock-keychain -p "${KEYCHAIN_PASSWORD}" build.keychain | ||
security import certificate.p12 -k build.keychain -P "${MACOS_CERTIFICATE_PWD}" -T /usr/bin/codesign | ||
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k "${KEYCHAIN_PASSWORD}" build.keychain | ||
|
||
# Tell Github Workflow that we need notarization & stapling: | ||
echo "::set-output name=macos_signed::true" | ||
return 0 | ||
} | ||
|
||
build_app_as_dmg_installer() { | ||
# Mac's bash version considers BUILD_ARGS unset without at least one entry: | ||
BUILD_ARGS=("") | ||
if prepare_signing; then | ||
BUILD_ARGS=("-s" "${MACOS_CERTIFICATE_ID}") | ||
fi | ||
./mac/deploy_mac.sh "${BUILD_ARGS[@]}" | ||
} | ||
|
||
pass_artifact_to_job() { | ||
artifact_deploy_filename="jamulus_${jamulus_buildversionstring}_mac${ARTIFACT_SUFFIX:-}.dmg" | ||
echo "Moving build artifact to deploy/${artifact_deploy_filename}" | ||
mv ./deploy/Jamulus-*installer-mac.dmg "./deploy/${artifact_deploy_filename}" | ||
echo "::set-output name=artifact_1::${artifact_deploy_filename}" | ||
} | ||
|
||
case "${1:-}" in | ||
setup) | ||
setup | ||
;; | ||
build) | ||
build_app_as_dmg_installer | ||
;; | ||
get-artifacts) | ||
pass_artifact_to_job | ||
;; | ||
*) | ||
echo "Unknown stage '${1:-}'" | ||
exit 1 | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to go with inline environment variables here.
For context:
So, the possibilities for Mac would be:
getopts
to (closely) match PowerShell (longer)Among those, the most-readable and yet simplest implementation is the usage of inline environment variables.
I also thought about converting Windows/PowerShell to environment variables, but it seems that setting this inline is not as nice as on *nix.