cloudflare/cloudflared
Publicmirrored from https://github.com/cloudflare/cloudflaredAvailable
.ci/scripts/linux/build-packages.sh
60lines · modecode
| 1 | #!/bin/bash |
| 2 | set -e -u -o pipefail |
| 3 | |
| 4 | # Check if architecture argument is provided |
| 5 | if [ $# -eq 0 ]; then |
| 6 | echo "Error: Architecture argument is required" |
| 7 | echo "Usage: $0 <architecture>" |
| 8 | exit 1 |
| 9 | fi |
| 10 | |
| 11 | # Parameters |
| 12 | arch=$1 |
| 13 | |
| 14 | # Get Version |
| 15 | VERSION=$(git describe --tags --always --match "[0-9][0-9][0-9][0-9].*.*") |
| 16 | echo $VERSION |
| 17 | |
| 18 | # Disable FIPS module in go-boring |
| 19 | export GOEXPERIMENT=noboringcrypto |
| 20 | export CGO_ENABLED=0 |
| 21 | |
| 22 | # This controls the directory the built artifacts go into |
| 23 | export ARTIFACT_DIR=artifacts/ |
| 24 | mkdir -p $ARTIFACT_DIR |
| 25 | |
| 26 | export TARGET_OS=linux |
| 27 | |
| 28 | unset TARGET_ARM |
| 29 | export TARGET_ARCH=$arch |
| 30 | |
| 31 | ## Support for arm platforms without hardware FPU enabled |
| 32 | if [[ $arch == arm ]] ; then |
| 33 | export TARGET_ARCH=arm |
| 34 | export TARGET_ARM=5 |
| 35 | fi |
| 36 | |
| 37 | ## Support for armhf builds |
| 38 | if [[ $arch == armhf ]] ; then |
| 39 | export TARGET_ARCH=arm |
| 40 | export TARGET_ARM=7 |
| 41 | fi |
| 42 | |
| 43 | make cloudflared-deb |
| 44 | mv cloudflared\_$VERSION\_$arch.deb $ARTIFACT_DIR/cloudflared-linux-$arch.deb |
| 45 | |
| 46 | # rpm packages invert the - and _ and use x86_64 instead of amd64. |
| 47 | RPMVERSION=$(echo $VERSION|sed -r 's/-/_/g') |
| 48 | RPMARCH=$arch |
| 49 | if [ $arch == "amd64" ];then |
| 50 | RPMARCH="x86_64" |
| 51 | fi |
| 52 | if [ $arch == "arm64" ]; then |
| 53 | RPMARCH="aarch64" |
| 54 | fi |
| 55 | make cloudflared-rpm |
| 56 | mv cloudflared-$RPMVERSION-1.$RPMARCH.rpm $ARTIFACT_DIR/cloudflared-linux-$RPMARCH.rpm |
| 57 | |
| 58 | # finally move the linux binary as well. |
| 59 | mv ./cloudflared $ARTIFACT_DIR/cloudflared-linux-$arch |
| 60 | |
| 61 | |