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: make sure versioned files are up to date, omit the -next suffix #103

Merged
merged 3 commits into from
Sep 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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 README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ We originally wrote a prototype of this tool in Rust (https://github.com/metlos/

```
$ ./configbump --help
config-bump 7.74.0-next
config-bump 7.75.0-next
Usage: configbump --dir DIR --labels LABELS [--namespace NAMESPACE]

Options:
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7.74.0-next
7.75.0
2 changes: 1 addition & 1 deletion cmd/configbump/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type opts struct {

// Version returns the version of the program
func (opts) Version() string {
return "config-bump 7.74.0-next"
return "config-bump 7.75.0-next"
}

const controllerName = "config-bump"
Expand Down
29 changes: 24 additions & 5 deletions make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ while [[ "$#" -gt 0 ]]; do
shift 1
done

sed_in_place() {
SHORT_UNAME=$(uname -s)
if [ "$(uname)" == "Darwin" ]; then
sed -i '' "$@"
elif [ "${SHORT_UNAME:0:5}" == "Linux" ]; then
sed -i "$@"
fi
}

# search for occurrences of the old version in VERSION file and update to the new version
function update_versioned_files() {
local VER=$1
OLD_VER=$(cat VERSION); OLD_VER=${OLD_VER%-*}
for file in README.md cmd/configbump/main.go; do
sed_in_place -r -e "s@${OLD_VER}@${VER}@g" $file
done
echo "${VER}" > VERSION
}

bump_version () {
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)

Expand All @@ -37,10 +56,10 @@ bump_version () {
git checkout "${BUMP_BRANCH}"

echo "Updating project version to ${NEXT_VERSION}"
update_pkgs_versions $NEXT_VERSION
update_versioned_files $NEXT_VERSION

if [[ ${NOCOMMIT} -eq 0 ]]; then
COMMIT_MSG="chore: Bump to ${NEXT_VERSION} in ${BUMP_BRANCH}"
COMMIT_MSG="chore: release: bump to ${NEXT_VERSION} in ${BUMP_BRANCH}"
git commit -asm "${COMMIT_MSG}"
git pull origin "${BUMP_BRANCH}"

Expand All @@ -65,7 +84,7 @@ bump_version () {
usage ()
{
echo "Usage: $0 --version [VERSION TO RELEASE] [--tag-release]"
echo "Example: $0 --version 7.74.0 --tag-release"; echo
echo "Example: $0 --version 7.75.0 --tag-release"; echo
}

if [[ ! ${VERSION} ]]; then
Expand Down Expand Up @@ -124,10 +143,10 @@ git checkout "${BASEBRANCH}"
if [[ "${BASEBRANCH}" != "${BRANCH}" ]]; then
# bump the y digit, if it is a major release
[[ $BRANCH =~ ^([0-9]+)\.([0-9]+)\.x ]] && BASE=${BASH_REMATCH[1]}; NEXT=${BASH_REMATCH[2]}; (( NEXT=NEXT+1 )) # for BRANCH=7.10.x, get BASE=7, NEXT=11
NEXT_VERSION_Y="${BASE}.${NEXT}.0-next"
NEXT_VERSION_Y="${BASE}.${NEXT}.0"
bump_version "${NEXT_VERSION_Y}" "${BASEBRANCH}"
fi
# bump the z digit
[[ $VERSION =~ ^([0-9]+)\.([0-9]+)\.([0-9]+) ]] && BASE="${BASH_REMATCH[1]}.${BASH_REMATCH[2]}"; NEXT="${BASH_REMATCH[3]}"; (( NEXT=NEXT+1 )) # for VERSION=7.7.1, get BASE=7.7, NEXT=2
NEXT_VERSION_Z="${BASE}.${NEXT}-next"
NEXT_VERSION_Z="${BASE}.${NEXT}"
bump_version "${NEXT_VERSION_Z}" "${BRANCH}"