diff options
author | Benjamin Chausse <benjamin@chausse.xyz> | 2024-06-16 10:32:23 -0400 |
---|---|---|
committer | Benjamin Chausse <benjamin@chausse.xyz> | 2024-06-16 10:32:23 -0400 |
commit | 1f5af9b941ac429d485ebcc80c17b5a6862f5a64 (patch) | |
tree | bbb9174bcc783c87b54594b77231b040982e92c2 | |
parent | 106597566c8d9b901aa5cad75767340386e00cd8 (diff) |
Add versioning
-rw-r--r-- | Makefile | 27 | ||||
-rw-r--r-- | sixkcd.go | 3 |
2 files changed, 23 insertions, 7 deletions
@@ -1,24 +1,37 @@ # sixkcd - Fetch XKCD comics from the command line # See LICENSE file for copyright and license details. +COMMIT := $(shell git rev-parse --short HEAD) +VERSION := $(or $(SIXKCD_VERSION),dev-$(COMMIT)) + +SRC := $(shell go list -f '{{range .GoFiles}}{{$$.Dir}}/{{.}} {{end}}' ./...) + +CMD := sixkcd PREFIX=/usr/local MANPREFIX=$(PREFIX)/share/man -all: +sixkcd: $(SRC) go mod download - go build -o sixkcd ./sixkcd.go + go mod verify + go build -ldflags "-X main.version=$(VERSION)" -o $(CMD) ./$(CMD).go install: all mkdir -p $(PREFIX)/bin mkdir -p $(MANPREFIX)/man1 - cp -f sixkcd $(PREFIX)/bin - cp -f sixkcd.1 $(MANPREFIX)/man1 + cp -f $(CMD) $(PREFIX)/bin + cp -f $(CMD).1 $(MANPREFIX)/man1 clean: - rm -f ./sixkcd + rm -f ./$(CMD) uninstall: - rm -f $(PREFIX)/bin/sixkcd - rm -f $(MANPREFIX)/man1/sixkcd.1 + rm -f $(PREFIX)/bin/$(CMD) + rm -f $(MANPREFIX)/man1/$(CMD).1 + +info: + @echo "$(CMD)" + @echo "Version: $(VERSION)" + +all: info sixkcd .PHONY: all install clean uninstall help @@ -22,6 +22,8 @@ const ( target = "info.0.json" ) +var version string + type Comic struct { Month string Num int @@ -40,6 +42,7 @@ func main() { app := &cli.App{ Name: "siXKCD", Usage: "Sixel viewer/fetcher for XKCD Comics", + Version: version, Authors: []*cli.Author{ { Name: "Benjamin Chausse", |