Skip to content

Commit 9209ceb

Browse files
committed
Add make release target
1 parent 1690970 commit 9209ceb

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

Makefile

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# test: run all unit tests
66
# lint: run linting checks (golangci-lint)
77
# install-lint-deps: install linting dependencies
8+
# release: create a new release by updating version numbers and committing changes
89
# help: print this help message
910
# .PHONY: mark targets as phony
1011
# .DEFAULT_GOAL: set the default goal to all
@@ -14,7 +15,7 @@
1415
PROJECT_NAME := "gh-token"
1516

1617
# Mark targets as phony
17-
.PHONY: all clean build test lint install-lint-deps
18+
.PHONY: all clean build test lint install-lint-deps release
1819

1920
# Build the project
2021
all: clean build
@@ -41,3 +42,34 @@ lint:
4142
install-lint-deps:
4243
@mkdir -p .bin
4344
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/HEAD/install.sh | sh -s -- -b .bin v2.4.0
45+
46+
# Create a new release
47+
release:
48+
@echo "Current version in main.go: $$(grep 'Version:' main.go | sed 's/.*Version: *"\(.*\)".*/\1/')"
49+
@echo "Current version in SECURITY.md: $$(grep -A2 '| Version' SECURITY.md | tail -1 | sed 's/| *\([0-9]*\.[0-9]*\.[0-9]*\).*/\1/')"
50+
@echo ""
51+
@read -p "Enter the new semver version (e.g., 2.1.0): " VERSION; \
52+
if [ -z "$$VERSION" ]; then \
53+
echo "Error: Version cannot be empty"; \
54+
exit 1; \
55+
fi; \
56+
if ! echo "$$VERSION" | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$$' > /dev/null; then \
57+
echo "Error: Version must be in semver format (e.g., 2.1.0)"; \
58+
exit 1; \
59+
fi; \
60+
MAJOR_MINOR=$$(echo "$$VERSION" | sed 's/\([0-9]*\.[0-9]*\)\.[0-9]*/\1/'); \
61+
echo "Updating version to $$VERSION..."; \
62+
sed -i.bak 's/Version: *"[^"]*"/Version: "'"$$VERSION"'"/' main.go && rm main.go.bak; \
63+
sed -i.bak 's/| [0-9]*\.[0-9]*\.[0-9]* *|/| '"$$MAJOR_MINOR"'.x |/' SECURITY.md && rm SECURITY.md.bak; \
64+
echo "Files updated successfully."; \
65+
echo ""; \
66+
echo "Staging and committing changes..."; \
67+
git add main.go SECURITY.md; \
68+
git commit -m "Update version to $$VERSION"; \
69+
echo ""; \
70+
echo "Changes committed successfully!"; \
71+
echo ""; \
72+
echo "Next steps:"; \
73+
echo "- Go to https://github.com/Link-/gh-token/releases/new to create a new release"; \
74+
echo "- Create a tag with the same version as the release ($$VERSION)"; \
75+
echo "- The binaries will automatically be uploaded as assets once the release has been created"

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Only the versions in the table below will receive security updates.
66

77
| Version | Supported |
88
| ------- | ------------------ |
9-
| 2.x.x | :white_check_mark: |
9+
| 2.0.6 | :white_check_mark: |
1010

1111
## Reporting a Vulnerability
1212

0 commit comments

Comments
 (0)