From 6fe68c107799e31c6e21a003fcc40771772c0397 Mon Sep 17 00:00:00 2001 From: jimid27 Date: Thu, 5 Dec 2024 13:13:29 -0500 Subject: [PATCH 1/3] Add release script and update gha to pull the latest release vs tag --- .github/workflows/create-update-release.yaml | 2 +- scripts/release | 46 ++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100755 scripts/release diff --git a/.github/workflows/create-update-release.yaml b/.github/workflows/create-update-release.yaml index d60265d..5090ec8 100644 --- a/.github/workflows/create-update-release.yaml +++ b/.github/workflows/create-update-release.yaml @@ -26,7 +26,7 @@ jobs: else echo "Tag ${MAJOR_VERSION} does not exist. Creating a new tag and release." export RELEASE_SHA=$(git rev-parse HEAD) - gh release create "${MAJOR_VERSION}" --title "${MAJOR_VERSION}" --generate-notes --target "${RELEASE_SHA}" --latest + gh release create "${MAJOR_VERSION}" --title "${MAJOR_VERSION}" --generate-notes --target "${RELEASE_SHA}" --latest=false fi env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/scripts/release b/scripts/release new file mode 100755 index 0000000..749a4db --- /dev/null +++ b/scripts/release @@ -0,0 +1,46 @@ +#!/usr/bin/env python3 +import subprocess +import tempfile + +CLONE_URL = "https://github.com/PrefectHQ/actions-prefect-deploy" + +release_type = input("Is this a major, minor, or patch release? ") +# Clone the repo and get the latest version on the default branch +# Then determine the new version based on latest tag and release type +with tempfile.TemporaryDirectory() as temporary: + subprocess.check_call(["git", "clone", "--bare", CLONE_URL, temporary]) + print() + result = subprocess.check_output(["git", "rev-parse", "HEAD"], cwd=temporary) + new_revision = result.decode().strip() + # Need to get the latest release as the tag for the major version tends to be the latest tagged version. + latest_version = subprocess.check_output(["gh", "release", "list", "--json", "name,isLatest", "--jq", ".[] | select(.isLatest) | .name"]).decode("utf-8") + print(f"The current version of Actions Prefect Deploy is {latest_version}") + if release_type == "major": + version = f"v{int(latest_version.split('.')[0].split('v')[1]) + 1}.0.0" + elif release_type == "minor": + version = f"{latest_version.split('.')[0]}.{int(latest_version.split('.')[1]) + 1}.0" + else: + version = f"{latest_version.split('.')[0]}.{latest_version.split('.')[1]}.{int(latest_version.split('.')[2]) + 1}" + +print() +print(f"Actions Prefect Deploy's next version will be {version}") +print() + +print() +print("The new release is ready at:") +print() +subprocess.check_call( + [ + "gh", + "release", + "create", + "--title", + version, + "--generate-notes", + "--target", + new_revision, + version, + "--latest" + ], +) +print() From fb6dd954607af5331cf4db5ae2b94949c28a7c42 Mon Sep 17 00:00:00 2001 From: jimid27 Date: Thu, 5 Dec 2024 15:24:26 -0500 Subject: [PATCH 2/3] Update to elif for inputs --- scripts/release | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/release b/scripts/release index 749a4db..94b684b 100755 --- a/scripts/release +++ b/scripts/release @@ -19,7 +19,7 @@ with tempfile.TemporaryDirectory() as temporary: version = f"v{int(latest_version.split('.')[0].split('v')[1]) + 1}.0.0" elif release_type == "minor": version = f"{latest_version.split('.')[0]}.{int(latest_version.split('.')[1]) + 1}.0" - else: + elif release_type == "patch": version = f"{latest_version.split('.')[0]}.{latest_version.split('.')[1]}.{int(latest_version.split('.')[2]) + 1}" print() From 1533b5908f98d11b0f3cb9396700c73bda7ae082 Mon Sep 17 00:00:00 2001 From: jimid27 Date: Thu, 5 Dec 2024 15:24:40 -0500 Subject: [PATCH 3/3] Update to elif for inputs --- scripts/release | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/release b/scripts/release index 94b684b..93c6b9e 100755 --- a/scripts/release +++ b/scripts/release @@ -21,6 +21,8 @@ with tempfile.TemporaryDirectory() as temporary: version = f"{latest_version.split('.')[0]}.{int(latest_version.split('.')[1]) + 1}.0" elif release_type == "patch": version = f"{latest_version.split('.')[0]}.{latest_version.split('.')[1]}.{int(latest_version.split('.')[2]) + 1}" + else: + raise ValueError(f"Invalid release type: {release_type}") print() print(f"Actions Prefect Deploy's next version will be {version}")