Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore/Add release script and update gha to pull the latest release vs tag #62

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/create-update-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting latest to false so that the latest semver release is known to be the latest

fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 46 additions & 0 deletions scripts/release
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#!/usr/bin/env python3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when/how does this script get run

Copy link
Contributor Author

@jimid27 jimid27 Dec 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

locally similar to what we do for cloud releases

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()
Loading