From b03ea055b0bb42d21941fe9c7ef8b367de86db47 Mon Sep 17 00:00:00 2001 From: lneto Date: Thu, 1 Aug 2024 16:26:45 +0100 Subject: [PATCH] TUN-8581: create dry run for github release --- Makefile | 4 ++++ cfsetup.yaml | 16 +++++++++++++++- github_release.py | 12 ++++++++++-- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 1d044ac9..46fee2a9 100644 --- a/Makefile +++ b/Makefile @@ -218,6 +218,10 @@ cloudflared-pkg: cloudflared cloudflared.1 cloudflared-msi: wixl --define Version=$(VERSION) --define Path=$(EXECUTABLE_PATH) --output cloudflared-$(VERSION)-$(TARGET_ARCH).msi cloudflared.wxs +.PHONY: github-release-dryrun +github-release-dryrun: + python3 github_release.py --path $(PWD)/built_artifacts --release-version $(VERSION) --dry-run + .PHONY: github-release github-release: python3 github_release.py --path $(PWD)/built_artifacts --release-version $(VERSION) diff --git a/cfsetup.yaml b/cfsetup.yaml index 613cb0f8..62e8de5d 100644 --- a/cfsetup.yaml +++ b/cfsetup.yaml @@ -195,9 +195,23 @@ buster: &buster - component-tests/requirements.txt pre-cache: *component_test_pre_cache post-cache: *component_test_post_cache + github-release-dryrun: + build_dir: *build_dir + builddeps: + - *pinned_go + - build-essential + - python3-dev + - libffi-dev + - python3-setuptools + - python3-pip + pre-cache: + - pip3 install pynacl==1.4.0 + - pip3 install pygithub==1.55 + post-cache: + - make github-release-dryrun github-release: build_dir: *build_dir - builddeps: + builddeps: - *pinned_go - build-essential - python3-dev diff --git a/github_release.py b/github_release.py index e28a89cc..db612086 100755 --- a/github_release.py +++ b/github_release.py @@ -17,7 +17,7 @@ import re from github import Github, GithubException, UnknownObjectException FORMAT = "%(levelname)s - %(asctime)s: %(message)s" -logging.basicConfig(format=FORMAT) +logging.basicConfig(format=FORMAT, level=logging.INFO) CLOUDFLARED_REPO = os.environ.get("GITHUB_REPO", "cloudflare/cloudflared") GITHUB_CONFLICT_CODE = "already_exists" @@ -219,7 +219,15 @@ def main(): release = get_or_create_release(repo, args.release_version, args.dry_run) if args.dry_run: - logging.info("Skipping asset upload because of dry-run") + if os.path.isdir(args.path): + 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) + logging.info("binary: " + binary_path) + elif os.path.isfile(args.path): + logging.info("binary: " + binary_path) + else: + logging.error("dryrun failed") return if os.path.isdir(args.path):