Skip to content

Commit

Permalink
add tag-release target
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemrm committed Dec 8, 2024
1 parent 75d9a5a commit 3601837
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
16 changes: 12 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: helm-docs version-increment bump-major bump-minor bump-patch prepare-branch
.PHONY: helm-docs version-increment bump-major bump-minor bump-patch prepare-branch tag-release

help: Makefile ## Prints this help message.
@grep -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/:.*##/#/' | column -c 2 -t -s#
Expand All @@ -9,15 +9,15 @@ helm-docs: ## Regenerates helm docs
version-increment:
@if [ -z "$(CHART)" ]; then echo 'CHART=$$NAME must be specified'; exit 1; fi

@current_version="$$(yq -r '.version' "$(CHART)/Chart.yaml")"; \
@current_version="$$(yq -r '.version' "$(CHART)/Chart.yaml")" && \
export next_version="$$(yq -r '.version | capture("v?(?P<major>[0-9]+)\\.(?P<minor>[0-9]+)\\.(?P<patch>[0-9]+).*") \
| ."$(NEXT)" |= (tonumber + 1 | tostring) \
| .major |= ("$(MAJOR_VERSION)" | select(. != "") // .major) \
| .minor |= ("$(MINOR_VERSION)" | select(. != "") // .minor) \
| .patch |= ("$(PATCH_VERSION)" | select(. != "") // .patch) \
| "v" + ([.major, .minor, .patch] | join(".")) \
' "$(CHART)/Chart.yaml")"; \
echo "Updating version: $$current_version -> $$next_version"; \
' "$(CHART)/Chart.yaml")" && \
echo "Updating version: $$current_version -> $$next_version" && \
yq -i '.version = env(next_version)' "$(CHART)/Chart.yaml"

bump-major: NEXT=major
Expand Down Expand Up @@ -46,3 +46,11 @@ prepare-branch: ## Prepares CHART release branch. Use bump-* to bump the version
fi; \
echo ""; \
echo "Branch prepared! Run: git push origin releases/$(CHART)/$$current_version"

tag-release: ## Creates a CHART tag.
@if [ -z "$(CHART)" ]; then echo 'CHART=$$NAME must be specified'; exit 1; fi

@current_version="$$(yq -r '.version' "$(CHART)/Chart.yaml")"; \
git tag -a -m "$$current_version" "$(CHART)/$$current_version" && \
echo "Tag $(CHART)/$$current_version is ready to be pushed." && \
echo "Use git push origin --tags $(CHART)/$$current_version"
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ This will create a new branch named `releases/CHART/VERSION`.

You may also combine both of these steps with `make CHART=CHART_NAME bump-patch prepare-branch`.

Once prepared push the branch.
Once merged a new tag can be cut.
First make sure you have the most recent changes:

```shell
git checkout main
git pull origin main
git fetch origin
```

Then tag the release with `make CHART=CHART_NAME tag-release`.
Once tagged, push the new tag with `git push origin --tags $TAG`

Example output:

~~~shell
Expand Down Expand Up @@ -80,4 +93,16 @@ Changes to be committed:
2 files changed, 3 insertions(+), 3 deletions(-)
Branch prepared! Run: git push origin releases/voyager/v0.2.3
$ make CHART=voyager tag-release
Tag voyager/v0.1.3 is ready to be pushed.
Use git push origin --tags voyager/v0.1.3
$ git push origin --tags voyager/v0.1.3
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 161 bytes | 161.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
To github.com:mikemrm/charts.git
* [new tag] voyager/v0.1.3 -> voyager/v0.1.3
~~~

0 comments on commit 3601837

Please sign in to comment.