diff options
| author | Emīls <emils@mullvad.net> | 2023-03-08 10:02:47 +0100 |
|---|---|---|
| committer | Emīls <emils@mullvad.net> | 2023-03-08 10:02:47 +0100 |
| commit | 8be326a45b53dae1e16bd62a57ac257ed1e9cf93 (patch) | |
| tree | 0e57f60abe6b74e0b45f7b96d832f710746effcf | |
| parent | 94d6c46ee738637f7ff8a9385bb7b476481f89d3 (diff) | |
| parent | b390041652b4aa9544d3dfc1972d3c9a0d8ab478 (diff) | |
| download | mullvadvpn-8be326a45b53dae1e16bd62a57ac257ed1e9cf93.tar.xz mullvadvpn-8be326a45b53dae1e16bd62a57ac257ed1e9cf93.zip | |
Merge branch 'build-ios-automagically'
| -rw-r--r-- | ci/buildserver-build-ios.sh | 96 | ||||
| -rwxr-xr-x | ios/build.sh | 2 |
2 files changed, 97 insertions, 1 deletions
diff --git a/ci/buildserver-build-ios.sh b/ci/buildserver-build-ios.sh new file mode 100644 index 0000000000..cf6aa54c34 --- /dev/null +++ b/ci/buildserver-build-ios.sh @@ -0,0 +1,96 @@ +#!/usr/bin/env bash +set -eu +shopt -s nullglob + +TAG_PATTERN_TO_BUILD=("^ios/") +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +BUILD_DIR="$SCRIPT_DIR/mullvadvpn-app/ios" +LAST_BUILT_DIR="$SCRIPT_DIR/last-built" +mkdir -p "$LAST_BUILT_DIR" + + +function build_ref() { + local tag=$1; + local current_hash=""; + if ! current_hash=$(git rev-parse "$tag^{commit}"); then + echo "!!!" + echo "[#] Failed to get commit for $tag" + echo "!!!" + return + fi + + if [ -f "$LAST_BUILT_DIR/commit-$current_hash" ]; then + # This commit has already been built + return 0 + fi + + local app_build_version=""; + if ! app_build_version=$(read_app_version); then + echo "!!!" + echo "[#] Failed to read app build version for tag $tag ($current_hash)" + echo "!!!" + return 0 + fi + + + if [ -f "$LAST_BUILT_DIR/build-$app_build_version" ]; then + echo "!!!" + echo "[#] App version already built in commit $(cat "${LAST_BUILT_DIR}/build-${app_build_version}")" + echo "[#] The build version in Configuration/Version.xcconfig should be bumped." + echo "!!!" + sleep 60 + return 0 + fi + + echo "" + echo "[#] $tag: $app_build_version $current_hash, building new packages." + + if ! git verify-tag "$tag"; then + echo "!!!" + echo "[#] $tag failed GPG verification!" + echo "!!!" + sleep 60 + return 0 + fi + + git reset --hard + git checkout $tag + git submodule update + git clean -df + + if "$BUILD_DIR"/build.sh; then + touch "$LAST_BUILT_DIR"/"commit-$current_hash" + echo "$current_hash" > "$LAST_BUILT_DIR"/"build-${app_build_version}" + echo "Successfully built ${app_build_version} ${tag} with hash ${current_hash}" + fi +} + +function read_app_version() { + project_version=$(sed -n "s/CURRENT_PROJECT_VERSION = \([[:digit:]]\)/\1/p" Configurations/Version.xcconfig) + marketing_version=$(sed -n "s/MARKETING_VERSION = \([[:digit:]]\)/\1/p" Configurations/Version.xcconfig) + echo "${marketing_version}-${project_version}" + if [ -z "$project_version" ] || [ -z "$marketing_version" ]; then + exit 1; + fi +} + + + +function run_build_loop() { + cd "$BUILD_DIR" + while true; do + # Delete all tags. So when fetching we only get the ones existing on the remote + git tag | xargs git tag -d > /dev/null + + git fetch --prune --tags 2> /dev/null || continue + local tags=( $(git tag | grep "$TAG_PATTERN_TO_BUILD") ) + + for tag in "${tags[@]}"; do + build_ref "refs/tags/$tag" + done + + sleep 240 + done +} + +run_build_loop diff --git a/ios/build.sh b/ios/build.sh index 52f0fa00ca..14f8fa59d7 100755 --- a/ios/build.sh +++ b/ios/build.sh @@ -12,7 +12,7 @@ SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" if [[ -z ${IOS_APPLE_ID-} ]]; then echo "The variable IOS_APPLE_ID is not set." - exit + exit 1 fi if [[ -z ${IOS_APPLE_ID_PASSWORD-} ]]; then |
