Skip to content

Commit

Permalink
feat: Change CLI versioning
Browse files Browse the repository at this point in the history
Semver is great for libraries - it provides info about kind of change.
But for user tools most important is to know how old is this version.
Calver suits here better.

Different schemes also minimizes mistakes during project maintenance.
  • Loading branch information
macie committed Nov 7, 2023
1 parent 0b208b9 commit 3b0507b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ build: check test
@CURRENT_VER_TAG="$$(git tag --points-at HEAD | grep "^cli" | sed 's/^cli\/v//' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1)"; \
PREV_VER_TAG="$$(git tag | grep "^cli" | sed 's/^cli\/v//' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1)"; \
CURRENT_COMMIT_TAG="$$(TZ=UTC git --no-pager show --quiet --abbrev=12 --date='format-local:%Y%m%d%H%M%S' --format='%cd-%h')"; \
PSEUDOVERSION="$${PREV_VER_TAG:-0.0.0}-$$CURRENT_COMMIT_TAG"; \
PSEUDOVERSION="$${PREV_VER_TAG:-0001.01}-$$CURRENT_COMMIT_TAG"; \
VERSION="$${CURRENT_VER_TAG:-$$PSEUDOVERSION}"; \
go build -C $(CLI_DIR) -ldflags="-s -w -X main.AppVersion=$$VERSION" -o '../../dist/sortof'; \

Expand All @@ -41,7 +41,7 @@ dist: check test
@CURRENT_VER_TAG="$$(git tag --points-at HEAD | grep "^cli" | sed 's/^cli\/v//' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1)"; \
PREV_VER_TAG="$$(git tag | grep "^cli" | sed 's/^cli\/v//' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1)"; \
CURRENT_COMMIT_TAG="$$(TZ=UTC git --no-pager show --quiet --abbrev=12 --date='format-local:%Y%m%d%H%M%S' --format='%cd-%h')"; \
PSEUDOVERSION="$${PREV_VER_TAG:-0.0.0}-$$CURRENT_COMMIT_TAG"; \
PSEUDOVERSION="$${PREV_VER_TAG:-0001.01}-$$CURRENT_COMMIT_TAG"; \
VERSION="$${CURRENT_VER_TAG:-$$PSEUDOVERSION}"; \
GOOS=openbsd GOARCH=amd64 go build -C $(CLI_DIR) -ldflags="-s -w -X main.AppVersion=$$VERSION" -o '../../dist/sortof-openbsd_amd64'; \
GOOS=linux GOARCH=amd64 go build -C $(CLI_DIR) -ldflags="-s -w -X main.AppVersion=$$VERSION" -o '../../dist/sortof-linux_amd64'; \
Expand All @@ -59,7 +59,7 @@ cli-release:
@git pull --rebase
@echo '# Create new CLI release tag' >&2
@PREV_VER_TAG=$$(git tag | grep "^cli" | sed 's/^cli\/v//' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1); \
printf 'Choose new version number for CLI (>%s): ' "$${PREV_VER_TAG:-0.0.0}"
printf 'Choose new version number for CLI (calver; >%s): ' "$${PREV_VER_TAG:-2023.10}"
@read -r VERSION; \
git tag "cli/v$$VERSION"; \
git push --tags
Expand All @@ -69,7 +69,7 @@ module-release:
@git pull --rebase
@echo '# Create new Go module release tag' >&2
@PREV_VER_TAG=$$(git tag | grep "^v" | sed 's/^v//' | sort -t. -k 1,1n -k 2,2n -k 3,3n | tail -1); \
printf 'Choose new version number for module (>%s): ' "$${PREV_VER_TAG:-0.0.0}"
printf 'Choose new version number for module (semver; >%s): ' "$${PREV_VER_TAG:-0.0.0}"
@read -r VERSION; \
git tag "v$$VERSION"; \
git push --tags
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ Use `make` (GNU or BSD):
### Versioning

The repo contains CLI and Go module which can be developed with different pace.
Commits with versions are tagged using [semantic versioning](https://semver.org/):
- `vX.X.X` - versions of Go module
- `cli/vX.X.X` - versions of command-line utility.
Commits with versions are tagged with:
- `vX.X.X` (_[semantic versioning](https://semver.org/)_) - versions of Go module
- `cli/vYYYY.0M.MICRO` (_[calendar versioning](https://calver.org/)_) - versions of command-line utility.

## License

Expand Down

0 comments on commit 3b0507b

Please sign in to comment.