-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add scripts for release preparation #17
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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,81 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
# Default values | ||
DEV_MODE=${DEV_MODE:-false} | ||
MAIN_BRANCH=${MAIN_BRANCH:-main} | ||
NEXT_VERSION="" | ||
|
||
Help() | ||
{ | ||
# Display Help | ||
echo "This tool prepares the project to the next development cycle." | ||
lampajr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo "" | ||
echo "Syntax: ${0} [OPTIONS]" | ||
echo "options:" | ||
echo "-h Display this guide." | ||
echo "" | ||
} | ||
|
||
while getopts "h" option; do | ||
case $option in | ||
h) Help | ||
exit;; | ||
*) echo "Unrecognized option: ${OPTARG}" | ||
Help | ||
exit 1;; | ||
esac | ||
done | ||
|
||
if [ "$DEV_MODE" != "false" ]; then | ||
echo "WARNING: Dev mode enabled..." | ||
fi | ||
|
||
if [ -n "$(git status --porcelain)" ]; then | ||
echo "ERROR: You have uncommitted changes, exiting ..." | ||
exit 1 | ||
fi | ||
|
||
echo "Preparing for next development cycle" | ||
|
||
# Compute release version if not provided | ||
if [ -z "$NEXT_VERSION" ]; then | ||
NEXT_VERSION=$(poetry version patch -s --dry-run) | ||
fi | ||
|
||
# Compute stable branch from next version | ||
STABLE_BRANCH=$(sed -E -e 's/([^.]+\.[^.]+).*/\1.x/' <<< "$NEXT_VERSION") | ||
|
||
echo "Next version will be: $NEXT_VERSION" | ||
|
||
echo "Creating stable branch $STABLE_BRANCH ..." | ||
# Check if stable branch exists and create if necessary | ||
if ! git rev-parse --verify "$STABLE_BRANCH" >/dev/null 2>&1; then | ||
git branch "$STABLE_BRANCH" "$MAIN_BRANCH" | ||
echo "Stable branch $STABLE_BRANCH created" | ||
else | ||
echo "Stable branch $STABLE_BRANCH already existing" | ||
fi | ||
|
||
echo "Updating $MAIN_BRANCH to the next development cycle ..." | ||
git checkout "$MAIN_BRANCH" | ||
|
||
# Update to the next patch to remove the .dev | ||
./scripts/update-version.sh -n "patch" >/dev/null 2>&1 | ||
# And then do minor release with dev | ||
NEXT_DEV_VERSION=$(./scripts/update-version.sh -n "minor" -d | tail -n1) | ||
NEXT_RELEASE_VERSION=$(poetry version patch -s --dry-run) | ||
|
||
echo "Next release will be $NEXT_RELEASE_VERSION" | ||
echo "Set next development version to $NEXT_DEV_VERSION" | ||
|
||
# Update backport.yaml | ||
sed -i "s/target-branch:.*/target-branch: $STABLE_BRANCH/" .github/workflows/backport.yaml | ||
|
||
# Update ci.yaml | ||
yq e -i ".on.push.branches += [\"$STABLE_BRANCH\"]" .github/workflows/ci.yaml | ||
|
||
if [ "$DEV_MODE" != "true" ]; then | ||
git commit -am "Next is $NEXT_RELEASE_VERSION" | ||
fi |
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,85 @@ | ||
#!/bin/bash | ||
|
||
set -eo pipefail | ||
|
||
DEV_MODE=${DEV_MODE:-false} | ||
|
||
Help() | ||
{ | ||
# Display Help | ||
echo "Update the project version." | ||
echo "" | ||
echo "Syntax: ${0} [OPTIONS]" | ||
echo "" | ||
echo "options:" | ||
echo "-h Display this guide." | ||
echo "" | ||
echo "-n NEW_VERSION Update the project to this version." | ||
echo " The new version should ideally be a valid semver string or a valid bump rule:" | ||
echo " patch, minor, major, prepatch, preminor, premajor, prerelease." | ||
echo " Run 'poetry version --help' for more details." | ||
echo "" | ||
echo "-d The next version will be a development one." | ||
echo " It will append '-dev' to the version." | ||
echo "" | ||
echo "-t Do git tag with the new version." | ||
echo "" | ||
echo "-u Update the HORREUM_BRANCH in the Makefile." | ||
} | ||
|
||
IS_DEVEL_VERSION=false | ||
DO_TAG=false | ||
DEVEL_VERSION_SUFFIX=".dev" | ||
UPDATE_HORREUM_BRANCH=false | ||
NEW_VERSION=${NEW_VERSION:-"patch"} | ||
|
||
while getopts "hn:dtu" option; do | ||
case $option in | ||
h) Help | ||
exit;; | ||
n) NEW_VERSION=${OPTARG} | ||
;; | ||
d) IS_DEVEL_VERSION=true | ||
;; | ||
t) DO_TAG=true | ||
;; | ||
u) UPDATE_HORREUM_BRANCH=true | ||
;; | ||
*) echo "Unrecognized option: ${OPTARG}" | ||
Help | ||
exit 1;; | ||
esac | ||
done | ||
|
||
NEW_VERSION=$(poetry version "$NEW_VERSION" -s --dry-run) | ||
|
||
if [ "$IS_DEVEL_VERSION" = "true" ]; then | ||
NEW_VERSION="$NEW_VERSION$DEVEL_VERSION_SUFFIX" | ||
fi | ||
|
||
# Compute stable branch from next version | ||
STABLE_BRANCH=$(sed -E -e 's/([^.]+\.[^.]+).*/\1.x/' <<< "$NEW_VERSION") | ||
|
||
# Update HORREUM_BRANCH on Makefile | ||
if [ "$UPDATE_HORREUM_BRANCH" = "true" ]; then | ||
sed -i "s/HORREUM_BRANCH ?= \".*\"/HORREUM_BRANCH ?= \"$STABLE_BRANCH\"/" Makefile | ||
fi | ||
|
||
echo "Updating project version to $NEW_VERSION ..." | ||
poetry version "$NEW_VERSION" -v | ||
|
||
# Generate raw client | ||
make generate | ||
|
||
if [ "$DO_TAG" = "true" ] && [ "$IS_DEVEL_VERSION" = "false" ]; then | ||
echo "Tagging version v$NEW_VERSION" | ||
if [ "$DEV_MODE" != "true" ]; then | ||
git commit -am "Tagging version $NEW_VERSION" | ||
git tag "v$NEW_VERSION" | ||
fi | ||
else | ||
echo "Skipping tag because disabled or this is a development version" | ||
fi | ||
|
||
# Print the new version | ||
echo "$NEW_VERSION" |
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.
This command should fail, because the
origin
repo'smain
branch should be protected against directpush
es -- modifyingmain
(and stable branches) really should require a PR.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.
That's totally right, I am proceeding step-by-step and at the moment the main is not protected yet as this is still in development mode. Planning to follow your approach in the near future.
The only difference is that this
git push origin main
will be replaced by creating a new branch and then "create a pull request with those changes"