summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIsmael Luceno2021-09-08 21:52:07 +0200
committerIsmael Luceno2021-09-08 21:55:44 +0200
commitc60a4b6e1138d2bc8833ee50dc135aa5c4b67773 (patch)
tree6c51f05b7be92ad267cc0fecd6fdd3770657686c
parent91ffd11cd6587442817de56fdfb45e1d561f9955 (diff)
Makefile: Unify version-bump targets
Just detect from the output of git-describe if it's at a version tag and update accordingly. Use the new target on devinst.
-rw-r--r--ChangeLog3
-rw-r--r--Makefile22
-rw-r--r--bump.awk20
3 files changed, 31 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 1955b994..b739d6f0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2021-09-08 Ismael Luceno <ismael@sourcemage.org>
+ * Makefile: unified version bump target + make devinst dep on it
+
2021-02-26 Thomas Orgis <sobukus@sourcemage.org>
* Makefile: added devinst target to mark installs from git checkout
diff --git a/Makefile b/Makefile
index 35a9437c..c95a610f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,3 +1,5 @@
+AWK ?= awk
+
.PHONY: help
help:
@awk 'sub(/^#HELP: ?/, "")' $(MAKEFILE_LIST) $(.MAKE.MAKEFILES)
@@ -19,24 +21,16 @@ $(release): $(ts-scm)
release: $(release)
#HELP: bump - Bump version
-.PHONY: bump bump-stable bump-devel
-bump-stable:
- git describe --tags | >etc/sorcery/version \
- awk -F'[^0-9]' -vOFS=. '{++$$NF;for(i=1;i<NF;i++)$$i=$$(i+1)}NF--'
-
-bump-devel:
- date -u +%Y%m%d > etc/sorcery/version
-
-bump: bump-$(BRANCH)
+.PHONY: bump
+bump:
+ git describe --tags | >etc/sorcery/version ${AWK} -f bump.awk
-devinst: install
- date +%Y%m%d | tr '\n' - > /etc/sorcery/version
- git show --oneline | head -n 1 | cut -f 1 -d ' ' >> /etc/sorcery/version
+devinst: bump install
#HELP: install - Install sorcery
-#HELP: devinst - Install with version vom active branch
+#HELP: devinst - Install with version from active branch
#HELP: uninstall - Uninstall sorcery
#HELP: convert - Convert from Pre 0.8.x grimoire to new codex format
-script-targets = install uninstall convert
+script-targets = install devinst uninstall convert
.PHONY: $(script-targets)
$(script-targets):; ./$@
diff --git a/bump.awk b/bump.awk
new file mode 100644
index 00000000..ad04bdec
--- /dev/null
+++ b/bump.awk
@@ -0,0 +1,20 @@
+BEGIN {
+ FS="[^0-9]"
+ OFS="."
+}
+
+# bump stable
+/^v/ && !/-[1-9][0-9]*-g[0-9a-f]+$/ {
+ ++$NF
+ for (i = 1; i < NF; i++)
+ $i = $(i+1)
+ --NF
+ print
+ exit
+}
+
+# bump snapshot
+{
+ sub(/.*-g/, strftime("%Y%m%d-g", systime(), 1))
+ print
+}