From cd4af5696d0db81caae903b33e4bbddfb5aff9ff Mon Sep 17 00:00:00 2001 From: Sudarsan Reddy Date: Fri, 30 Jul 2021 12:29:51 +0100 Subject: [PATCH] TUN-4772: Release built executables with packages --- build-packages.sh | 19 +++++++++-- cfsetup.yaml | 83 ++--------------------------------------------- github_release.py | 21 ------------ 3 files changed, 18 insertions(+), 105 deletions(-) diff --git a/build-packages.sh b/build-packages.sh index 14a87cfa..52fbd11c 100755 --- a/build-packages.sh +++ b/build-packages.sh @@ -1,3 +1,5 @@ +VERSION=$(git describe --tags --always --dirty="-dev" --match "[0-9][0-9][0-9][0-9].*.*") +echo $VERSION export CGO_ENABLED=0 # This controls the directory the built artifacts go into export ARTIFACT_DIR=built_artifacts/ @@ -7,9 +9,10 @@ export TARGET_OS=windows for arch in ${windowsArchs[@]}; do export TARGET_ARCH=$arch make cloudflared-msi + mv ./cloudflared.exe $ARTIFACT_DIR/cloudflared-windows-$arch.exe + mv cloudflared-$VERSION-$arch.msi $ARTIFACT_DIR/cloudflared-windows-$arch.msi done -mv *.msi $ARTIFACT_DIR export FIPS=true linuxArchs=("amd64" "386" "arm") @@ -17,8 +20,18 @@ export TARGET_OS=linux for arch in ${linuxArchs[@]}; do export TARGET_ARCH=$arch make cloudflared-deb + mv cloudflared\_$VERSION\_$arch.deb $ARTIFACT_DIR/cloudflared-linux-$arch.deb + + # rpm packages invert the - and _ and use x86_64 instead of amd64. + RPMVERSION=$(echo $VERSION|sed -r 's/-/_/g') + RPMARCH=$arch + if [ $arch == "amd64" ];then + RPMARCH="x86_64" + fi make cloudflared-rpm + mv cloudflared-$RPMVERSION-1.$RPMARCH.rpm $ARTIFACT_DIR/cloudflared-linux-$RPMARCH.rpm + + # finally move the linux binary as well. + mv ./cloudflared $ARTIFACT_DIR/cloudflared-linux-$arch done -mv *.deb $ARTIFACT_DIR -mv *.rpm $ARTIFACT_DIR diff --git a/cfsetup.yaml b/cfsetup.yaml index 680d8027..347880f2 100644 --- a/cfsetup.yaml +++ b/cfsetup.yaml @@ -108,20 +108,6 @@ stretch: &stretch - export GOARCH=amd64 - export FIPS=true - make release - github-release-linux-amd64: - build_dir: *build_dir - builddeps: - - *pinned_go_fips - - build-essential - - python3-setuptools - - python3-pip - pre-cache: &install_pygithub - - pip3 install pygithub - post-cache: - - export GOOS=linux - - export GOARCH=amd64 - - export FIPS=true - - make github-release release-linux-armv6: build_dir: *build_dir builddeps: @@ -133,20 +119,6 @@ stretch: &stretch - export GOARCH=arm - export CC=arm-linux-gnueabihf-gcc - make release - github-release-linux-armv6: - build_dir: *build_dir - builddeps: - - *pinned_go - - crossbuild-essential-armhf - - gcc-arm-linux-gnueabihf - - python3-setuptools - - python3-pip - pre-cache: *install_pygithub - post-cache: - - export GOOS=linux - - export GOARCH=arm - - export CC=arm-linux-gnueabihf-gcc - - make github-release release-linux-386: build_dir: *build_dir builddeps: @@ -156,18 +128,6 @@ stretch: &stretch - export GOOS=linux - export GOARCH=386 - make release - github-release-linux-386: - build_dir: *build_dir - builddeps: - - *pinned_go - - gcc-multilib - - python3-setuptools - - python3-pip - pre-cache: *install_pygithub - post-cache: - - export GOOS=linux - - export GOARCH=386 - - make github-release release-windows-amd64: build_dir: *build_dir builddeps: @@ -178,19 +138,6 @@ stretch: &stretch - export GOARCH=amd64 - export CC=x86_64-w64-mingw32-gcc - make release - github-release-windows-amd64: - build_dir: *build_dir - builddeps: - - *pinned_go - - gcc-mingw-w64 - - python3-setuptools - - python3-pip - pre-cache: *install_pygithub - post-cache: - - export GOOS=windows - - export GOARCH=amd64 - - export CC=x86_64-w64-mingw32-gcc - - make github-release release-windows-386: build_dir: *build_dir builddeps: @@ -201,40 +148,14 @@ stretch: &stretch - export GOARCH=386 - export CC=i686-w64-mingw32-gcc-win32 - make release - github-release-windows-386: - build_dir: *build_dir - builddeps: - - *pinned_go - - gcc-mingw-w64 - - python3-setuptools - - python3-pip - pre-cache: *install_pygithub - post-cache: - - export GOOS=windows - - export GOARCH=386 - - export CC=i686-w64-mingw32-gcc-win32 - - make github-release - github-release-linux-arm64: - build_dir: *build_dir - builddeps: - - *pinned_go - - crossbuild-essential-armhf - - g++-aarch64-linux-gnu - - python3-setuptools - - python3-pip - pre-cache: *install_pygithub - post-cache: - - export GOOS=linux - - export GOARCH=arm64 - - export CC=aarch64-linux-gnu-gcc - - make github-release github-release-macos-amd64: build_dir: *build_dir builddeps: - *pinned_go - python3-setuptools - python3-pip - pre-cache: *install_pygithub + pre-cache: &install_pygithub + - pip3 install pygithub post-cache: - make github-mac-upload test: diff --git a/github_release.py b/github_release.py index 96aa8b71..532d0eae 100755 --- a/github_release.py +++ b/github_release.py @@ -197,25 +197,6 @@ def upload_asset(release, filepath, filename, release_version, kv_account_id, na except shutil.SameFileError: pass # the macOS release copy fails with being the same file (already in the artifacts directory) -def compile_regex() : - # The capture groups are: - # 1: the text cloudflared - # 2: compiled architecture - # 3: possible extensions - capture_string = r'(cloudflared).+(amd64|x86_64|386|arm)(\.msi|\.deb|\.rpm|\.exe)?' - return re.compile(capture_string) - -def extract_filename(regex, filename): - match_groups = regex.match(filename) - os = "linux" - name = match_groups.group(1) - arch = match_groups.group(2) - ext = match_groups.group(3) - if ext in ['.msi', '.exe']: - os = "windows" - return "{}-{}-{}{}".format(name, os, arch, ext if ext is not None else "") - - def main(): """ Attempts to upload Asset to Github Release. Creates Release if it doesnt exist """ try: @@ -229,11 +210,9 @@ def main(): return if os.path.isdir(args.path): - regexp = compile_regex() onlyfiles = [f for f in listdir(args.path) if isfile(join(args.path, f))] for filename in onlyfiles: binary_path = os.path.join(args.path, filename) - filename = extract_filename(regexp, filename) upload_asset(release, binary_path, filename, args.release_version, args.kv_account_id, args.namespace_id, args.kv_api_token) else: