Skip to content

Commit f64e88c

Browse files
committed
build: update Makefile
1 parent d017ee6 commit f64e88c

File tree

17 files changed

+201
-162
lines changed

17 files changed

+201
-162
lines changed

.chglog/CHANGELOG.tpl.md

Lines changed: 0 additions & 48 deletions
This file was deleted.

.chglog/config.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,6 @@ space_redirects = false
3636
keep_padding = false
3737
# --func-next-line
3838
function_next_line = false
39+
40+
[{Makefile,*.mk}]
41+
indent_style = tab

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,6 @@ Temporary Items
4646
.apdisk
4747

4848
# End of https://www.gitignore.io/api/vim,osx
49+
50+
/makefile-utils/*
51+
!/makefile-utils/*.mk

Makefile

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
include ./makefile-utils/*.mk
2+
.DEFAULT_GOAL := help
3+
14
.PHONY: check-links
25
check-links:
36
# https://github.com/tcort/markdown-link-check
@@ -11,20 +14,31 @@ check-style:
1114
test:
1215
./test
1316

14-
.PHONY: bump-major bump-minor bump-patch
15-
bump-major:
16-
./tools/release major
17-
18-
bump-minor:
19-
./tools/release minor
20-
21-
bump-patch:
22-
./tools/release patch
23-
2417
.PHONY: build
2518
build:
2619
./build -y ./dist/lobash.bash
2720

2821
.PHONY: gen
2922
gen:
3023
./tools/gen
24+
25+
# @target bump-major bump major version (x)
26+
# @target bump-minor bump minor version (y)
27+
# @target bump-patch bump patch version (z)
28+
BUMP_TARGETS := $(addprefix bump-,major minor patch)
29+
.PHONY: $(BUMP_TARGETS)
30+
$(BUMP_TARGETS):
31+
@$(MAKE) $(subst bump-,semver-,$@) > VERSION
32+
33+
.PHONY: changelog
34+
# @desc Generate and update the CHANGELOG file
35+
changelog:
36+
$(MAKE) CHANGELOG NEXT_VERSION=$(shell cat VERSION)
37+
38+
# @target release-major release major version (x)
39+
# @target release-minor release minor version (y)
40+
# @target release-patch release patch version (z)
41+
RELEASE_TARGETS := $(addprefix release-,major minor patch)
42+
.PHONY: $(RELEASE_TARGETS)
43+
$(RELEASE_TARGETS):
44+
./tools/release $(subst release-,,$@)

version renamed to VERSION

File renamed without changes.

build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ init() {
234234

235235
VERBOSE_1 "_LOBASH_OS=$_LOBASH_OS"
236236

237-
VERSION=$(cat "$SCRIPT_DIR/version")
237+
VERSION=$(cat "$SCRIPT_DIR/VERSION")
238238
VERBOSE_1 "VERSION=$VERSION"
239239
# LOBASH_POUCH_TIME must never change
240240
LOBASH_POUCH_TIME=1561389473

docs/publish.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
1. Run `./tools/gen`. Commit and push to github.
44
2. Run the CI. Check the results. If failed, fix it.
55
3. Run `./tools/bump <major|minor|patch>`. Edit changelog. Commit and push to github.
6-
4. `git tag v$(cat ./version)` and `git push --tags`.
6+
4. `git tag v$(cat ./VERSION)` and `git push --tags`.

docs/with-lower-version-bash.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,20 @@ Completely supported.
4545

4646
- Empty `$@` and `$*` will throw error "unbound variable" with `set -u` in v4.0. It is a bug of Bash. See https://unix.stackexchange.com/a/16565
4747

48+
#### Not test with Bash 4.0 in Ubuntu
49+
50+
**Lobash not test with Bash 4.0 in MacOS. It seems a bug of Bash 4.0 in MacOS. Please contact me if you solved this problem.**
51+
52+
To reproduce the problem,
53+
54+
```sh
55+
> BASHVER=4.0 ./tools/test
56+
57+
malloc: hashlib.c:306: assertion botched
58+
free: called with unallocated block argument
59+
```
60+
61+
4862
#### Not test with Bash 4.0 in MacOS
4963

5064
**Lobash not test with Bash 4.0 in MacOS. It seems a bug of Bash 4.0 in MacOS. Please contact me if you solved this problem.**

makefile-utils/changelog.mk

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Source Code: https://github.com/adoyle-h/makefile-utils
2+
# vi: ft=make
3+
4+
# @hide
5+
makefile-utils/chglog:
6+
@mkdir -p '$@'
7+
8+
makefile-utils/chglog/CHANGELOG.tpl.md: CHGLOG_TPL ?= https://gist.githubusercontent.com/adoyle-h/9d466c80bf419ceba278316198eb5690/raw/ffc2de47fb9774bfef232c7a57948af6f1cbe524/CHANGELOG.tpl.md
9+
# @hide
10+
makefile-utils/chglog/CHANGELOG.tpl.md:
11+
curl -#Lo '$@' '$(CHGLOG_TPL)'
12+
13+
makefile-utils/chglog/config.yml: CHGLOG_CONFIG ?= https://gist.githubusercontent.com/adoyle-h/9d466c80bf419ceba278316198eb5690/raw/ffc2de47fb9774bfef232c7a57948af6f1cbe524/config.yml
14+
# @hide
15+
makefile-utils/chglog/config.yml:
16+
ifeq (,$(shell git config --get remote.origin.url | sed -E 's|.+github.com:(.+).git|\1|'))
17+
$(error "Not found remote repo from git")
18+
endif
19+
curl -#Lo '$@' '$(CHGLOG_CONFIG)'
20+
@repo=$$(git config --get remote.origin.url | sed -E 's|.+github.com:(.+).git|\1|');\
21+
sed -i.bak "s|adoyle-h/makefile-utils|$${repo}|" '$@';\
22+
rm '$@'.bak
23+
24+
.PHONY: git-chglog
25+
# @hide
26+
git-chglog:
27+
ifeq (, $(shell which git-chglog))
28+
$(error "Not found git-chglog in PATH. Please install it by yourself. See https://github.com/git-chglog/git-chglog")
29+
endif
30+
@:
31+
32+
.PHONY: CHANGELOG
33+
CHANGELOG: OUTPUT ?= CHANGELOG.md
34+
CHANGELOG: TEMPLATE ?= https://gist.githubusercontent.com/adoyle-h/9d466c80bf419ceba278316198eb5690/raw/ffc2de47fb9774bfef232c7a57948af6f1cbe524/CHANGELOG.md
35+
36+
# @desc Generate and update the CHANGELOG file ("make CHANGELOG NEXT_VERSION=0.1.0")
37+
CHANGELOG: git-chglog makefile-utils/chglog makefile-utils/chglog/CHANGELOG.tpl.md makefile-utils/chglog/config.yml
38+
ifeq (, $(NEXT_VERSION))
39+
$(error "The parameter NEXT_VERSION is required.")
40+
endif
41+
42+
@if [ -f "$(OUTPUT)" ]; then \
43+
line_num=$$(grep -nE '^## \[Unreleased\]' "$(OUTPUT)" | sed -E 's/^([0-9]+):.+/\1/');\
44+
sed -i.bak "$${line_num},$$((line_num+2)) d" "$(OUTPUT)";\
45+
git-chglog --config makefile-utils/chglog/config.yml --template makefile-utils/chglog/CHANGELOG.tpl.md \
46+
--next-tag "v$(NEXT_VERSION)" "v$(NEXT_VERSION)" | sed -i.bak "$$((line_num-1)) r /dev/stdin" "$(OUTPUT)";\
47+
echo "Updated the ChangeLog: $(OUTPUT)";\
48+
rm "$(OUTPUT).bak";\
49+
else \
50+
echo "curl -sSLo '$(OUTPUT)' '$(TEMPLATE)'";\
51+
curl -sSLo '$(OUTPUT)' '$(TEMPLATE)';\
52+
line_num=$$(grep -nE '^## \[Unreleased\]' "$(OUTPUT)" | sed -E 's/^([0-9]+):.+/\1/');\
53+
sed -i.bak "$${line_num},$$((line_num+2)) d" "$(OUTPUT)";\
54+
git-chglog --config makefile-utils/chglog/config.yml --template makefile-utils/chglog/CHANGELOG.tpl.md \
55+
--next-tag "v$(NEXT_VERSION)" | sed -i.bak "$$((line_num-1)) r /dev/stdin" "$(OUTPUT)";\
56+
echo "Created the ChangeLog: $(OUTPUT)";\
57+
rm "$(OUTPUT).bak";\
58+
fi

0 commit comments

Comments
 (0)