Skip to content

Commit c95959e

Browse files
committed
TUN-8520: add macos arm64 build
- refactor build script for macos to include arm64 build - refactor Makefile to upload all the artifacts instead of issuing one by one - update cfsetup due to 2. - place build files in specific folders - cleanup build directory before/after creating build artifacts
1 parent 75752b6 commit c95959e

File tree

2 files changed

+53
-45
lines changed

2 files changed

+53
-45
lines changed

.teamcity/mac/build.sh

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ export GO111MODULE=on
1212

1313
# build 'cloudflared-darwin-amd64.tgz'
1414
mkdir -p artifacts
15-
FILENAME="$(pwd)/artifacts/cloudflared-darwin-amd64.tgz"
16-
PKGNAME="$(pwd)/artifacts/cloudflared-amd64.pkg"
1715
TARGET_DIRECTORY=".build"
1816
BINARY_NAME="cloudflared"
1917
VERSION=$(git describe --tags --always --dirty="-dev")
@@ -28,7 +26,6 @@ export PATH="$PATH:/usr/local/bin"
2826
mkdir -p ../src/github.com/cloudflare/
2927
cp -r . ../src/github.com/cloudflare/cloudflared
3028
cd ../src/github.com/cloudflare/cloudflared
31-
GOCACHE="$PWD/../../../../" GOPATH="$PWD/../../../../" CGO_ENABLED=1 make cloudflared
3229

3330
# Add code signing private key to the key chain
3431
if [[ ! -z "$CFD_CODE_SIGN_KEY" ]]; then
@@ -138,47 +135,59 @@ else
138135
fi
139136
fi
140137

141-
# sign the cloudflared binary
142-
if [[ ! -z "$CODE_SIGN_NAME" ]]; then
143-
codesign -s "${CODE_SIGN_NAME}" -f -v --timestamp --options runtime ${BINARY_NAME}
138+
# cleanup the build directory because the previous execution might have failed without cleaning up.
139+
rm -rf "${TARGET_DIRECTORY}"
140+
archs=("amd64" "arm64")
141+
export TARGET_OS=darwin
142+
for arch in ${archs[@]}; do
144143

145-
# notarize the binary
146-
# TODO: TUN-5789
147-
fi
144+
FILENAME="$(pwd)/artifacts/cloudflared-darwin-$arch.tgz"
145+
PKGNAME="$(pwd)/artifacts/cloudflared-$arch.pkg"
146+
TARGET_ARCH=$arch GOCACHE="$PWD/../../../../" GOPATH="$PWD/../../../../" CGO_ENABLED=1 make cloudflared
147+
148+
# sign the cloudflared binary
149+
if [[ ! -z "$CODE_SIGN_NAME" ]]; then
150+
codesign -s "${CODE_SIGN_NAME}" -f -v --timestamp --options runtime ${BINARY_NAME}
151+
152+
# notarize the binary
153+
# TODO: TUN-5789
154+
fi
148155

149-
# creating build directory
150-
rm -rf $TARGET_DIRECTORY
151-
mkdir "${TARGET_DIRECTORY}"
152-
mkdir "${TARGET_DIRECTORY}/contents"
153-
cp -r ".mac_resources/scripts" "${TARGET_DIRECTORY}/scripts"
154-
155-
# copy cloudflared into the build directory
156-
cp ${BINARY_NAME} "${TARGET_DIRECTORY}/contents/${PRODUCT}"
157-
158-
# compress cloudflared into a tar and gzipped file
159-
tar czf "$FILENAME" "${BINARY_NAME}"
160-
161-
# build the installer package
162-
if [[ ! -z "$PKG_SIGN_NAME" ]]; then
163-
pkgbuild --identifier com.cloudflare.${PRODUCT} \
164-
--version ${VERSION} \
165-
--scripts ${TARGET_DIRECTORY}/scripts \
166-
--root ${TARGET_DIRECTORY}/contents \
167-
--install-location /usr/local/bin \
168-
--sign "${PKG_SIGN_NAME}" \
169-
${PKGNAME}
170-
171-
# notarize the package
172-
# TODO: TUN-5789
173-
else
174-
pkgbuild --identifier com.cloudflare.${PRODUCT} \
175-
--version ${VERSION} \
176-
--scripts ${TARGET_DIRECTORY}/scripts \
177-
--root ${TARGET_DIRECTORY}/contents \
178-
--install-location /usr/local/bin \
179-
${PKGNAME}
180-
fi
156+
ARCH_TARGET_DIRECTORY="${TARGET_DIRECTORY}/${arch}-build"
157+
# creating build directory
158+
rm -rf $ARCH_TARGET_DIRECTORY
159+
mkdir "${ARCH_TARGET_DIRECTORY}"
160+
mkdir "${ARCH_TARGET_DIRECTORY}/contents"
161+
cp -r ".mac_resources/scripts" "${ARCH_TARGET_DIRECTORY}/scripts"
181162

163+
# copy cloudflared into the build directory
164+
cp ${BINARY_NAME} "${ARCH_TARGET_DIRECTORY}/contents/${PRODUCT}"
165+
166+
# compress cloudflared into a tar and gzipped file
167+
tar czf "$FILENAME" "${BINARY_NAME}"
168+
169+
# build the installer package
170+
if [[ ! -z "$PKG_SIGN_NAME" ]]; then
171+
pkgbuild --identifier com.cloudflare.${PRODUCT} \
172+
--version ${VERSION} \
173+
--scripts ${ARCH_TARGET_DIRECTORY}/scripts \
174+
--root ${ARCH_TARGET_DIRECTORY}/contents \
175+
--install-location /usr/local/bin \
176+
--sign "${PKG_SIGN_NAME}" \
177+
${PKGNAME}
178+
179+
# notarize the package
180+
# TODO: TUN-5789
181+
else
182+
pkgbuild --identifier com.cloudflare.${PRODUCT} \
183+
--version ${VERSION} \
184+
--scripts ${ARCH_TARGET_DIRECTORY}/scripts \
185+
--root ${ARCH_TARGET_DIRECTORY}/contents \
186+
--install-location /usr/local/bin \
187+
${PKGNAME}
188+
fi
189+
done
182190

183-
# cleaning up the build directory
184-
rm -rf $TARGET_DIRECTORY
191+
# cleanup build the build directory because this script is not ran within containers,
192+
# which might lead to future issues in subsequent runs.
193+
rm -rf "${TARGET_DIRECTORY}"

Makefile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,7 @@ github-message:
241241

242242
.PHONY: github-mac-upload
243243
github-mac-upload:
244-
python3 github_release.py --path artifacts/cloudflared-darwin-amd64.tgz --release-version $(VERSION) --name cloudflared-darwin-amd64.tgz
245-
python3 github_release.py --path artifacts/cloudflared-amd64.pkg --release-version $(VERSION) --name cloudflared-amd64.pkg
244+
python3 github_release.py --path artifacts --release-version $(VERSION)
246245

247246
.PHONY: github-windows-upload
248247
github-windows-upload:

0 commit comments

Comments
 (0)