Skip to content

Commit c5a3283

Browse files
authored
[feat] Implementing new release process (#32)
Streamlining the release process for mattermost-plugins by integrating release and signing pipelines under the delivery platform. This update automates signing and releasing by simply pushing a semver tag(e.g: v0.0.1) or by using the newly introduced Makefile targets. ``` make patch make minor make major ``` For Release Candidades(RC): ``` make patch-rc make minor-rc make major-rc ```
1 parent 2ec3fc5 commit c5a3283

File tree

3 files changed

+134
-18
lines changed

3 files changed

+134
-18
lines changed

.github/workflows/cd.yml

-18
This file was deleted.

Makefile

+93
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,99 @@ ifneq ($(wildcard build/custom.mk),)
2222
include build/custom.mk
2323
endif
2424

25+
# ====================================================================================
26+
# Used for semver bumping
27+
PROTECTED_BRANCH := master
28+
APP_NAME := $(shell basename -s .git `git config --get remote.origin.url`)
29+
CURRENT_VERSION := $(shell git describe --abbrev=0 --tags)
30+
VERSION_PARTS := $(subst ., ,$(subst v,,$(subst -rc, ,$(CURRENT_VERSION))))
31+
MAJOR := $(word 1,$(VERSION_PARTS))
32+
MINOR := $(word 2,$(VERSION_PARTS))
33+
PATCH := $(word 3,$(VERSION_PARTS))
34+
RC := $(shell echo $(CURRENT_VERSION) | grep -oE 'rc[0-9]+' | sed 's/rc//')
35+
# Check if current branch is protected
36+
define check_protected_branch
37+
@current_branch=$$(git rev-parse --abbrev-ref HEAD); \
38+
if ! echo "$(PROTECTED_BRANCH)" | grep -wq "$$current_branch"; then \
39+
echo "Error: Tagging is only allowed from $(PROTECTED_BRANCH) branch. You are on $$current_branch branch."; \
40+
exit 1; \
41+
fi
42+
endef
43+
# Check if there are pending pulls
44+
define check_pending_pulls
45+
@git fetch; \
46+
current_branch=$$(git rev-parse --abbrev-ref HEAD); \
47+
if [ "$$(git rev-parse HEAD)" != "$$(git rev-parse origin/$$current_branch)" ]; then \
48+
echo "Error: Your branch is not up to date with upstream. Please pull the latest changes before performing a release"; \
49+
exit 1; \
50+
fi
51+
endef
52+
# ====================================================================================
53+
54+
.PHONY: patch minor major patch-rc minor-rc major-rc
55+
56+
patch: ## to bump patch version (semver)
57+
$(call check_protected_branch)
58+
$(call check_pending_pulls)
59+
@$(eval PATCH := $(shell echo $$(($(PATCH)+1))))
60+
@echo Bumping $(APP_NAME) to Patch version $(MAJOR).$(MINOR).$(PATCH)
61+
git tag -s -a v$(MAJOR).$(MINOR).$(PATCH) -m "Bumping $(APP_NAME) to Patch version $(MAJOR).$(MINOR).$(PATCH)"
62+
git push origin v$(MAJOR).$(MINOR).$(PATCH)
63+
@echo Bumped $(APP_NAME) to Patch version $(MAJOR).$(MINOR).$(PATCH)
64+
65+
minor: ## to bump minor version (semver)
66+
$(call check_protected_branch)
67+
$(call check_pending_pulls)
68+
@$(eval MINOR := $(shell echo $$(($(MINOR)+1))))
69+
@$(eval PATCH := 0)
70+
@echo Bumping $(APP_NAME) to Minor version $(MAJOR).$(MINOR).$(PATCH)
71+
git tag -s -a v$(MAJOR).$(MINOR).$(PATCH) -m "Bumping $(APP_NAME) to Minor version $(MAJOR).$(MINOR).$(PATCH)"
72+
git push origin v$(MAJOR).$(MINOR).$(PATCH)
73+
@echo Bumped $(APP_NAME) to Minor version $(MAJOR).$(MINOR).$(PATCH)
74+
75+
major: ## to bump major version (semver)
76+
$(call check_protected_branch)
77+
$(call check_pending_pulls)
78+
$(eval MAJOR := $(shell echo $$(($(MAJOR)+1))))
79+
$(eval MINOR := 0)
80+
$(eval PATCH := 0)
81+
@echo Bumping $(APP_NAME) to Major version $(MAJOR).$(MINOR).$(PATCH)
82+
git tag -s -a v$(MAJOR).$(MINOR).$(PATCH) -m "Bumping $(APP_NAME) to Major version $(MAJOR).$(MINOR).$(PATCH)"
83+
git push origin v$(MAJOR).$(MINOR).$(PATCH)
84+
@echo Bumped $(APP_NAME) to Major version $(MAJOR).$(MINOR).$(PATCH)
85+
86+
patch-rc: ## to bump patch release candidate version (semver)
87+
$(call check_protected_branch)
88+
$(call check_pending_pulls)
89+
@$(eval RC := $(shell echo $$(($(RC)+1))))
90+
@echo Bumping $(APP_NAME) to Patch RC version $(MAJOR).$(MINOR).$(PATCH)-rc$(RC)
91+
git tag -s -a v$(MAJOR).$(MINOR).$(PATCH)-rc$(RC) -m "Bumping $(APP_NAME) to Patch RC version $(MAJOR).$(MINOR).$(PATCH)-rc$(RC)"
92+
git push origin v$(MAJOR).$(MINOR).$(PATCH)-rc$(RC)
93+
@echo Bumped $(APP_NAME) to Patch RC version $(MAJOR).$(MINOR).$(PATCH)-rc$(RC)
94+
95+
minor-rc: ## to bump minor release candidate version (semver)
96+
$(call check_protected_branch)
97+
$(call check_pending_pulls)
98+
@$(eval MINOR := $(shell echo $$(($(MINOR)+1))))
99+
@$(eval PATCH := 0)
100+
@$(eval RC := 1)
101+
@echo Bumping $(APP_NAME) to Minor RC version $(MAJOR).$(MINOR).$(PATCH)-rc$(RC)
102+
git tag -s -a v$(MAJOR).$(MINOR).$(PATCH)-rc$(RC) -m "Bumping $(APP_NAME) to Minor RC version $(MAJOR).$(MINOR).$(PATCH)-rc$(RC)"
103+
git push origin v$(MAJOR).$(MINOR).$(PATCH)-rc$(RC)
104+
@echo Bumped $(APP_NAME) to Minor RC version $(MAJOR).$(MINOR).$(PATCH)-rc$(RC)
105+
106+
major-rc: ## to bump major release candidate version (semver)
107+
$(call check_protected_branch)
108+
$(call check_pending_pulls)
109+
@$(eval MAJOR := $(shell echo $$(($(MAJOR)+1))))
110+
@$(eval MINOR := 0)
111+
@$(eval PATCH := 0)
112+
@$(eval RC := 1)
113+
@echo Bumping $(APP_NAME) to Major RC version $(MAJOR).$(MINOR).$(PATCH)-rc$(RC)
114+
git tag -s -a v$(MAJOR).$(MINOR).$(PATCH)-rc$(RC) -m "Bumping $(APP_NAME) to Major RC version $(MAJOR).$(MINOR).$(PATCH)-rc$(RC)"
115+
git push origin v$(MAJOR).$(MINOR).$(PATCH)-rc$(RC)
116+
@echo Bumped $(APP_NAME) to Major RC version $(MAJOR).$(MINOR).$(PATCH)-rc$(RC)
117+
25118
## Checks the code style, tests, builds and bundles the plugin.
26119
all: check-style test dist
27120

README.md

+41
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,44 @@ This plugin allows users to fetch contributor data from GitHub via a slash comma
1616
![Fetching data](images/fetching.png)
1717
![Mattermost contributors](images/mattermost_all.png)
1818
![Hugo contributors](images/gohugo_hugo.png)
19+
20+
## How to Release
21+
22+
To trigger a release, follow these steps:
23+
24+
1. **For Patch Release:** Run the following command:
25+
```
26+
make patch
27+
```
28+
This will release a patch change.
29+
30+
2. **For Minor Release:** Run the following command:
31+
```
32+
make minor
33+
```
34+
This will release a minor change.
35+
36+
3. **For Major Release:** Run the following command:
37+
```
38+
make major
39+
```
40+
This will release a major change.
41+
42+
4. **For Patch Release Candidate (RC):** Run the following command:
43+
```
44+
make patch-rc
45+
```
46+
This will release a patch release candidate.
47+
48+
5. **For Minor Release Candidate (RC):** Run the following command:
49+
```
50+
make minor-rc
51+
```
52+
This will release a minor release candidate.
53+
54+
6. **For Major Release Candidate (RC):** Run the following command:
55+
```
56+
make major-rc
57+
```
58+
This will release a major release candidate.
59+

0 commit comments

Comments
 (0)