-
Notifications
You must be signed in to change notification settings - Fork 52
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
Release helper script #1006
Merged
Merged
Release helper script #1006
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4bac786
Script to cut a release PR
soapy1 f6b99f8
Extract hatch verfiy steps to a function
soapy1 f97aa9b
Add steps to build and check packages
soapy1 af2f370
Update instructions for cutting a release
soapy1 9119935
[pre-commit.ci] Apply automatic pre-commit fixes
pre-commit-ci[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
#!/bin/bash | ||
|
||
# Requirements | ||
# - packages | ||
# - github-activity https://github.com/choldgraf/github-activity | ||
# - jq | ||
# - GITHUB_ACCESS_TOKEN env var set | ||
# - `conda-store-server-dev` conda env is activated | ||
|
||
function usage { | ||
echo -e "Usage: ./cut-release-pr.sh -r release_version -c conda_store_ui_version\n" | ||
exit 1 | ||
} | ||
|
||
function build_and_check () { | ||
# Runs a hatch build, twine check, and checks the version of the package | ||
# Assumes that you are in the directory for the package | ||
# | ||
# args: | ||
# CHECK_TARGET: the name of the package to check | ||
CHECK_TARGET=$1 | ||
|
||
echo "${CHECK_TARGET}: Checking hatch versions..." | ||
HV=$(hatch version) | ||
if [[ "$HV" == "$RELEASE_VERSION" ]]; then | ||
echo "${CHECK_TARGET}: hatch version matches ${RELEASE_VERSION}" | ||
else | ||
echo "${CHECK_TARGET}: hatch version does not match the requested release version. Something has gone wrong, exiting!" | ||
exit 1 | ||
fi | ||
|
||
echo "${CHECK_TARGET}: Running build and checking package..." | ||
hatch build | ||
rc=$(twine check dist/*) | ||
if [[ $rc =~ "FAILED" ]]; then | ||
echo "${CHECK_TARGET}: package is not in a good state, exiting!" | ||
exit 1 | ||
else | ||
echo "${CHECK_TARGET}: package is in a good state" | ||
fi | ||
|
||
echo "${CHECK_TARGET}: cleaning up..." | ||
hatch clean | ||
} | ||
|
||
while [[ $# -gt 0 ]] | ||
do | ||
key="$1" | ||
|
||
case $key in | ||
-h|--help) | ||
usage | ||
exit 0 | ||
shift | ||
shift | ||
;; | ||
-r|--release_version) | ||
RELEASE_VERSION="$2" | ||
shift | ||
shift | ||
;; | ||
-c|--conda_store_ui_version) | ||
CONDA_STORE_UI_VERSION="$2" | ||
shift | ||
shift | ||
;; | ||
*) | ||
usage | ||
exit 0 | ||
shift | ||
;; | ||
esac | ||
done | ||
|
||
CURRENT_DATE=$(date '+%Y-%m-%d') | ||
|
||
echo "Today is ${CURRENT_DATE} | ||
Building a release for | ||
* conda-store version ${RELEASE_VERSION} | ||
with | ||
* conda-store-ui version ${CONDA_STORE_UI_VERSION} | ||
" | ||
|
||
# prepare repo | ||
git checkout -b release-"$RELEASE_VERSION" | ||
git clean -fxdq | ||
|
||
# bump versions | ||
sed -E -r -i "s/__version__ = .+/__version__ = \"$RELEASE_VERSION\"/g" conda-store-server/conda_store_server/__init__.py | ||
sed -E -r -i "s/__version__ = .+/__version__ = \"$RELEASE_VERSION\"/g" conda-store/conda_store/__init__.py | ||
sed -E -r -i "s/CONDA_STORE_UI_VERSION = .+/CONDA_STORE_UI_VERSION = \"$CONDA_STORE_UI_VERSION\"/g" conda-store-server/hatch_build.py | ||
|
||
# create changelog | ||
LATEST_TAG=$(curl https://api.github.com/repos/conda-incubator/conda-store/releases | jq -r '.[0].tag_name') | ||
PYTHONWARNINGS="ignore" github-activity conda-incubator/conda-store --since $LATEST_TAG --heading-level=2 > tmp_changes.txt | ||
# remove first line of changes - it's always a message about which GH token is used | ||
sed -n -i '1!p' tmp_changes.txt | ||
# replace the header for the changes with the appropriate title | ||
sed -n -i '1!p' tmp_changes.txt | ||
sed -i "1s/^/## [$RELEASE_VERSION] - $CURRENT_DATE\n/" tmp_changes.txt | ||
# insert changes into changelog | ||
sed -i "/---/r tmp_changes.txt" CHANGELOG.md | ||
# clean up temp file | ||
rm tmp_changes.txt | ||
|
||
cd conda-store-server | ||
build_and_check conda-store-server | ||
cd .. | ||
|
||
cd conda-store | ||
build_and_check conda-store | ||
cd .. | ||
|
||
|
||
# add files to git | ||
git add conda-store conda-store-server CHANGELOG.md | ||
git commit -m "REL - $RELEASE_VERSION" | ||
|
||
echo " | ||
Finished preparing the release! | ||
|
||
Next steps: | ||
* Validate that the changes made are correct | ||
* Follow any testing/validation steps | ||
* Push them changes up to github | ||
|
||
git push origin release-"$RELEASE_VERSION" | ||
" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having this as a bash script is pretty clunky. It would be nice if this was a github action workflow. I think that would take a bit more work. Can iterate on it if this is a direction we want to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please! If it's totally automated, we should be able to run this in github-actions.