From c2183bd814c13740f29ea09576176789a4103949 Mon Sep 17 00:00:00 2001 From: lneto Date: Wed, 17 Jul 2024 15:39:51 +0100 Subject: [PATCH 1/4] TUN-8546: rework MacOS build script The rework consists in building and packaging the cloudflared binary based on the OS & ARCH of the system. read TARGET_ARCH from export and exit if TARGET_ARCH is not set --- .teamcity/mac/build.sh | 90 +++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/.teamcity/mac/build.sh b/.teamcity/mac/build.sh index 588ef42f..d303144b 100755 --- a/.teamcity/mac/build.sh +++ b/.teamcity/mac/build.sh @@ -7,6 +7,12 @@ if [[ "$(uname)" != "Darwin" ]] ; then exit 1 fi +if [[ "amd64" != "${TARGET_ARCH}" && "arm64" != "${TARGET_ARCH}" ]] +then + echo "TARGET_ARCH must be amd64 or arm64" + exit 1 +fi + go version export GO111MODULE=on @@ -137,56 +143,52 @@ fi # cleanup the build directory because the previous execution might have failed without cleaning up. rm -rf "${TARGET_DIRECTORY}" -archs=("amd64" "arm64") -export TARGET_OS=darwin -for arch in ${archs[@]}; do - - FILENAME="$(pwd)/artifacts/cloudflared-darwin-$arch.tgz" - PKGNAME="$(pwd)/artifacts/cloudflared-$arch.pkg" - TARGET_ARCH=$arch GOCACHE="$PWD/../../../../" GOPATH="$PWD/../../../../" CGO_ENABLED=1 make cloudflared +export TARGET_OS="darwin" +FILENAME="$(pwd)/artifacts/cloudflared-darwin-$TARGET_ARCH.tgz" +PKGNAME="$(pwd)/artifacts/cloudflared-$TARGET_ARCH.pkg" +GOCACHE="$PWD/../../../../" GOPATH="$PWD/../../../../" CGO_ENABLED=1 make cloudflared - # sign the cloudflared binary - if [[ ! -z "$CODE_SIGN_NAME" ]]; then - codesign -s "${CODE_SIGN_NAME}" -f -v --timestamp --options runtime ${BINARY_NAME} - - # notarize the binary - # TODO: TUN-5789 - fi +# sign the cloudflared binary +if [[ ! -z "$CODE_SIGN_NAME" ]]; then + codesign -s "${CODE_SIGN_NAME}" -f -v --timestamp --options runtime ${BINARY_NAME} - ARCH_TARGET_DIRECTORY="${TARGET_DIRECTORY}/${arch}-build" - # creating build directory - rm -rf $ARCH_TARGET_DIRECTORY - mkdir -p "${ARCH_TARGET_DIRECTORY}" - mkdir -p "${ARCH_TARGET_DIRECTORY}/contents" - cp -r ".mac_resources/scripts" "${ARCH_TARGET_DIRECTORY}/scripts" + # notarize the binary + # TODO: TUN-5789 +fi - # copy cloudflared into the build directory - cp ${BINARY_NAME} "${ARCH_TARGET_DIRECTORY}/contents/${PRODUCT}" +ARCH_TARGET_DIRECTORY="${TARGET_DIRECTORY}/${arch}-build" +# creating build directory +rm -rf $ARCH_TARGET_DIRECTORY +mkdir -p "${ARCH_TARGET_DIRECTORY}" +mkdir -p "${ARCH_TARGET_DIRECTORY}/contents" +cp -r ".mac_resources/scripts" "${ARCH_TARGET_DIRECTORY}/scripts" - # compress cloudflared into a tar and gzipped file - tar czf "$FILENAME" "${BINARY_NAME}" +# copy cloudflared into the build directory +cp ${BINARY_NAME} "${ARCH_TARGET_DIRECTORY}/contents/${PRODUCT}" - # build the installer package - if [[ ! -z "$PKG_SIGN_NAME" ]]; then +# compress cloudflared into a tar and gzipped file +tar czf "$FILENAME" "${BINARY_NAME}" + +# build the installer package +if [[ ! -z "$PKG_SIGN_NAME" ]]; then + pkgbuild --identifier com.cloudflare.${PRODUCT} \ + --version ${VERSION} \ + --scripts ${ARCH_TARGET_DIRECTORY}/scripts \ + --root ${ARCH_TARGET_DIRECTORY}/contents \ + --install-location /usr/local/bin \ + --sign "${PKG_SIGN_NAME}" \ + ${PKGNAME} + + # notarize the package + # TODO: TUN-5789 +else pkgbuild --identifier com.cloudflare.${PRODUCT} \ - --version ${VERSION} \ - --scripts ${ARCH_TARGET_DIRECTORY}/scripts \ - --root ${ARCH_TARGET_DIRECTORY}/contents \ - --install-location /usr/local/bin \ - --sign "${PKG_SIGN_NAME}" \ - ${PKGNAME} - - # notarize the package - # TODO: TUN-5789 - else - pkgbuild --identifier com.cloudflare.${PRODUCT} \ - --version ${VERSION} \ - --scripts ${ARCH_TARGET_DIRECTORY}/scripts \ - --root ${ARCH_TARGET_DIRECTORY}/contents \ - --install-location /usr/local/bin \ - ${PKGNAME} - fi -done + --version ${VERSION} \ + --scripts ${ARCH_TARGET_DIRECTORY}/scripts \ + --root ${ARCH_TARGET_DIRECTORY}/contents \ + --install-location /usr/local/bin \ + ${PKGNAME} +fi # cleanup build directory because this script is not ran within containers, # which might lead to future issues in subsequent runs. From 3bb3d71093c932297d2fed87780b37edd0dc07e3 Mon Sep 17 00:00:00 2001 From: lneto Date: Wed, 31 Jul 2024 11:18:57 +0100 Subject: [PATCH 2/4] Release 2024.7.2 --- RELEASE_NOTES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 36972ceb..6bce201d 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,3 +1,6 @@ +2024.7.2 +- 2024-07-17 TUN-8546: rework MacOS build script + 2024.7.1 - 2024-07-16 TUN-8543: use -p flag to create intermediate directories From c7cd4e02b867db54cbc3605f409299383f71b7b1 Mon Sep 17 00:00:00 2001 From: lneto Date: Wed, 31 Jul 2024 15:51:02 +0100 Subject: [PATCH 3/4] TUN-8546: Fix final artifacts paths - The build artifacts must be placed in the checkout directory so that they can be picked up from cfsetup --- .teamcity/mac/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.teamcity/mac/build.sh b/.teamcity/mac/build.sh index d303144b..413f1133 100755 --- a/.teamcity/mac/build.sh +++ b/.teamcity/mac/build.sh @@ -29,6 +29,8 @@ INSTALLER_CERT="installer.cer" BUNDLE_ID="com.cloudflare.cloudflared" SEC_DUP_MSG="security: SecKeychainItemImport: The specified item already exists in the keychain." export PATH="$PATH:/usr/local/bin" +FILENAME="$(pwd)/artifacts/cloudflared-darwin-$TARGET_ARCH.tgz" +PKGNAME="$(pwd)/artifacts/cloudflared-$TARGET_ARCH.pkg" mkdir -p ../src/github.com/cloudflare/ cp -r . ../src/github.com/cloudflare/cloudflared cd ../src/github.com/cloudflare/cloudflared @@ -144,8 +146,6 @@ fi # cleanup the build directory because the previous execution might have failed without cleaning up. rm -rf "${TARGET_DIRECTORY}" export TARGET_OS="darwin" -FILENAME="$(pwd)/artifacts/cloudflared-darwin-$TARGET_ARCH.tgz" -PKGNAME="$(pwd)/artifacts/cloudflared-$TARGET_ARCH.pkg" GOCACHE="$PWD/../../../../" GOPATH="$PWD/../../../../" CGO_ENABLED=1 make cloudflared # sign the cloudflared binary @@ -156,7 +156,7 @@ if [[ ! -z "$CODE_SIGN_NAME" ]]; then # TODO: TUN-5789 fi -ARCH_TARGET_DIRECTORY="${TARGET_DIRECTORY}/${arch}-build" +ARCH_TARGET_DIRECTORY="${TARGET_DIRECTORY}/${TARGET_ARCH}-build" # creating build directory rm -rf $ARCH_TARGET_DIRECTORY mkdir -p "${ARCH_TARGET_DIRECTORY}" From c7f0f90bede391ff7897e28a862e710bde4432ec Mon Sep 17 00:00:00 2001 From: lneto Date: Wed, 31 Jul 2024 16:29:18 +0100 Subject: [PATCH 4/4] Release 2024.7.3 --- RELEASE_NOTES | 3 +++ 1 file changed, 3 insertions(+) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index 6bce201d..200a04bd 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -1,3 +1,6 @@ +2024.7.3 +- 2024-07-31 TUN-8546: Fix final artifacts paths + 2024.7.2 - 2024-07-17 TUN-8546: rework MacOS build script