Skip to content

Commit db080f4

Browse files
authored
release: Automate version updates on all branches (#499)
Adds the `versionbump` binary and github action workflows: Updates `branch-out` to bump the patch version and commit it to the relevant branch. `bump-main-version` checks out the `master` branch and updates the minor version. Since Major version updates are rare enough where they can be done manually (still leveraging `make major`). Signed-off-by: Marc Lopez Rubio <marc5.12@outlook.com>
1 parent f12e34a commit db080f4

File tree

4 files changed

+69
-0
lines changed

4 files changed

+69
-0
lines changed

.github/workflows/branch.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,55 @@ jobs:
2525
fi
2626
echo ::set-output name=BRANCH::$(echo ${BRANCH} | cut -d '.' -f1-2 | tr -d 'v')
2727
28+
- name: Set up Go
29+
uses: actions/setup-go@v2
30+
with:
31+
go-version: 1.17
32+
id: go
33+
34+
- name: Bump main version
35+
run: make patch
36+
2837
- name: Create a github branch
2938
uses: peterjgrainger/action-create-branch@v2.0.1
3039
env:
3140
GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GH_TOKEN }}
3241
with:
3342
branch: ${{ steps.get_branch.outputs.BRANCH }}
43+
44+
- name: Commit changes to the minor branch
45+
uses: EndBug/add-and-commit@v7
46+
with:
47+
default_author: user_info
48+
message: 'Update patch version'
49+
branch: ${{ steps.get_branch.outputs.BRANCH }}
50+
author_name: elasticcloudclients
51+
author_email: elasticcloudclients@elastic.co
52+
53+
bump-minor-version:
54+
name: Bump main version
55+
runs-on: ubuntu-latest
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v2
59+
with:
60+
ref: master
61+
token: ${{ secrets.GH_TOKEN }}
62+
63+
- name: Set up Go
64+
uses: actions/setup-go@v2
65+
with:
66+
go-version: 1.17
67+
id: go
68+
69+
- name: Bump main version
70+
run: make minor; git diff
71+
72+
- name: Commit changes to main
73+
uses: EndBug/add-and-commit@v7
74+
with:
75+
default_author: user_info
76+
message: 'Update minor version'
77+
branch: master
78+
author_name: elasticcloudclients
79+
author_email: elasticcloudclients@elastic.co

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ include scripts/Makefile.help
1010
include build/Makefile.build
1111
include build/Makefile.dev
1212
include build/Makefile.deps
13+
include build/Makefile.version

build/Makefile.deps

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ VERSION_GOLICENSER:=v0.3.0
99
VERSION_GOLANGCILINT:=v1.38.0
1010
VERSION_GOBINDATA:=v0.0.0-20190711162640-ee3c2418e368
1111
VERSION_GORELEASER:=v0.156.1
12+
VERSION_VERSIONBUMP:=v1.1.0
1213

1314
deps: $(GOBIN)/golint $(GOBIN)/go-licenser $(GOBIN)/golangci-lint $(GOBIN)/go-bindata $(GOBIN)/goreleaser
1415

@@ -57,3 +58,11 @@ $(VERSION_DIR)/.version-goreleaser-$(VERSION_GORELEASER): | $(VERSION_DIR)
5758
$(GOBIN)/goreleaser: $(VERSION_DIR)/.version-goreleaser-$(VERSION_GORELEASER) | $(GOBIN)
5859
@ echo "-> Installing goreleaser..."
5960
@ curl -sfL https://install.goreleaser.com/github.com/goreleaser/goreleaser.sh| sh -s -- -b $(GOBIN) $(VERSION_GORELEASER)
61+
62+
$(VERSION_DIR)/.version-versionbump-$(VERSION_VERSIONBUMP):
63+
@ rm -f $(VERSION_DIR)/.version-versionbump-*
64+
@ echo $(VERSION_VERSIONBUMP) > $(VERSION_DIR)/.version-versionbump-$(VERSION_VERSIONBUMP)
65+
66+
$(GOBIN)/versionbump: $(VERSION_DIR)/.version-versionbump-$(VERSION_VERSIONBUMP) | $(GOBIN)
67+
@ echo "-> Installing versionbump..."
68+
@ go install github.com/crosseyed/versionbump/cmd/versionbump@$(VERSION_VERSIONBUMP)

build/Makefile.version

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
### Manage repository versions
2+
3+
## Bump the major version for ecctl.
4+
major: $(GOBIN)/versionbump
5+
@ $(GOBIN)/versionbump -c major Makefile
6+
7+
## Bump the minor o feature version for ecctl.
8+
minor: $(GOBIN)/versionbump
9+
@ $(GOBIN)/versionbump -c minor Makefile
10+
11+
## Bump the patch o bugfix version for ecctl.
12+
patch: $(GOBIN)/versionbump
13+
@ $(GOBIN)/versionbump -c patch Makefile

0 commit comments

Comments
 (0)