add infrastructure for making releases
Idea: a release will be a git tag, distributed as an autogenerated archive (eg. by GitLab release feature). This version string must therefore be stored in a revisioned file, so we use `.version` for this purpose. Before tagging a new release this file will have to be updated with the new version number. When building gray the revision (shown in the output headers and usage screen) will be set to either - the latest commit hash when building from a git checkout, - from the .version file when building from release archive. The implementation is based on whether the .git directory is present.
This commit is contained in:
parent
fda4ff8a3b
commit
bc28d14ebe
15
Makefile
15
Makefile
@ -53,15 +53,24 @@ MANPAGES = $(addprefix $(SHAREDIR)/,gray.1 gray-convert.1 gray.ini.5 \
|
||||
profiles.txt.5 beamdata.txt.5 magneticdata.txt.5)
|
||||
|
||||
##
|
||||
## Git information (used in the version string)
|
||||
## Version information
|
||||
##
|
||||
|
||||
ifneq ($(wildcard .git/*),)
|
||||
# We are building from a git checkout
|
||||
|
||||
# Short hash of the latest commit
|
||||
GIT_REV ?= $(shell git rev-parse --short HEAD)
|
||||
GIT_REV ?= $(shell git rev-parse --short HEAD)
|
||||
|
||||
# Whether the worktree and the latest commit differs
|
||||
GIT_DIRTY ?= $(shell test -n "$$(git status --porcelain)" && echo "-dirty")
|
||||
|
||||
REVISION ?= $(GIT_REV)$(GIT_DIRTY)
|
||||
else
|
||||
# We are building from a release archive, use the version
|
||||
REVISION ?= v$(file < .version)
|
||||
endif
|
||||
|
||||
# Source date
|
||||
ifndef SOURCE_DATE_EPOCH
|
||||
# Use current date
|
||||
@ -76,7 +85,7 @@ DATE=$(shell LC_TIME=C date -d @$(SOURCE_DATE_EPOCH) '+%B %Y')
|
||||
LD = $(FC)
|
||||
FFLAGS += -I$(INCDIR) -fpic
|
||||
LDFLAGS += -L$(LIBDIR)
|
||||
CPPFLAGS += -DREVISION=\"$(GIT_REV)$(GIT_DIRTY)\" -DPREFIX=\"$(PREFIX)\"
|
||||
CPPFLAGS += -DREVISION=\"$(REVISION)\" -DPREFIX=\"$(PREFIX)\"
|
||||
|
||||
# Compiler-specific flags
|
||||
ifdef GNU
|
||||
|
@ -14,18 +14,19 @@ let
|
||||
sha256 = "007nv11r0z9fz593iwzn55nc0p0wj5lpgf0k2brhs1ynmikq9gjr";
|
||||
};
|
||||
|
||||
# Exclude this file and build artifacts
|
||||
# Exclude this file, build artifacts and git
|
||||
source = builtins.filterSource
|
||||
(path: type:
|
||||
!builtins.elem path [ "configure.mk" "default.nix" "result" ]
|
||||
&& baseNameOf path != "build") ./.;
|
||||
&& baseNameOf path != "build"
|
||||
&& baseNameOf path != ".git") ./.;
|
||||
|
||||
inherit (import nixpkgs {}) lib pkgs;
|
||||
|
||||
in
|
||||
pkgs.stdenv.mkDerivation rec {
|
||||
pname = "gray";
|
||||
version = "0.1";
|
||||
version = builtins.readFile ./.version;
|
||||
src = source;
|
||||
|
||||
doCheck = true;
|
||||
@ -72,8 +73,6 @@ in
|
||||
(lib.enableFeature static "static")
|
||||
"--with-katex=${katex}"
|
||||
"--enable-deterministic"
|
||||
"GIT_REV=${version}"
|
||||
"GIT_DIRTY="
|
||||
];
|
||||
|
||||
meta = {
|
||||
|
Loading…
Reference in New Issue
Block a user