This was way more complicated than it should be
This commit is contained in:
parent
f5de8d1f37
commit
e072f20d9b
4 changed files with 6 additions and 24 deletions
8
Makefile
8
Makefile
|
@ -1,10 +1,6 @@
|
||||||
VERSION_FILE := VERSION.txt
|
VERSION_FILE := VERSION.txt
|
||||||
|
|
||||||
ifeq ($(wildcard $(VERSION_FILE)),)
|
REX_VERSION := $(shell bash ./generate_version.sh)
|
||||||
$(shell bash ./generate_version.sh $VERSION_FILE)
|
|
||||||
endif
|
|
||||||
|
|
||||||
REX_VERSION := $(shell cat $(VERSION_FILE))
|
|
||||||
RELEASE_NAME := rexforge_$(REX_VERSION)
|
RELEASE_NAME := rexforge_$(REX_VERSION)
|
||||||
export REX_VERSION
|
export REX_VERSION
|
||||||
|
|
||||||
|
@ -24,7 +20,7 @@ release: $(RELEASE_NAME)
|
||||||
cp ./LICENSE.txt $(RELEASE_NAME)
|
cp ./LICENSE.txt $(RELEASE_NAME)
|
||||||
cp ./README.md $(RELEASE_NAME)
|
cp ./README.md $(RELEASE_NAME)
|
||||||
mkdir -p $(RELEASE_NAME)/source
|
mkdir -p $(RELEASE_NAME)/source
|
||||||
cp ./VERSION.txt $(RELEASE_NAME)/source
|
echo $(REX_VERSION) > $(RELEASE_NAME)/source/VERSION.txt
|
||||||
git ls-files | xargs -I{} cp --parents {} $(RELEASE_NAME)/source
|
git ls-files | xargs -I{} cp --parents {} $(RELEASE_NAME)/source
|
||||||
date -I > $(RELEASE_NAME)/INFO.txt
|
date -I > $(RELEASE_NAME)/INFO.txt
|
||||||
echo $(REX_VERSION) >> $(RELEASE_NAME)/INFO.txt
|
echo $(REX_VERSION) >> $(RELEASE_NAME)/INFO.txt
|
||||||
|
|
|
@ -1,22 +1,10 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
|
||||||
echo "ERROR: No version file name provided. Usage: $0 <version_file>"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
VERSION_FILE="$1"
|
|
||||||
|
|
||||||
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||||
VERSION=$(git describe 2>/dev/null || git rev-parse --short HEAD || echo "v0.0.0-unknown")
|
VERSION=$(git describe 2>/dev/null || git rev-parse --short HEAD || echo "v0.0.0-unknown")
|
||||||
DIRTY=$(git diff-index --quiet HEAD -- || echo "-dirty")
|
DIRTY=$(git diff-index --quiet HEAD -- || echo "-dirty")
|
||||||
FULL_VERSION="${VERSION}${DIRTY}"
|
FULL_VERSION="${VERSION}${DIRTY}"
|
||||||
echo "$FULL_VERSION" >"$VERSION_FILE"
|
echo "$FULL_VERSION"
|
||||||
else
|
else
|
||||||
if [ -f "$VERSION_FILE" ]; then
|
cat ./VERSION.txt
|
||||||
echo "INFO: $VERSION_FILE already exists. Please update it manually if needed."
|
|
||||||
else
|
|
||||||
echo "ERROR: Not in a Git repository, and $VERSION_FILE does not exist. Unable to generate version!"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
NAME = rexclient
|
NAME = rexclient
|
||||||
|
|
||||||
VERSION_FILE := ../VERSION.txt
|
REX_VERSION ?= $(shell bash ../generate_version.sh)
|
||||||
REX_VERSION ?= $(shell cat $(VERSION_FILE))
|
|
||||||
|
|
||||||
build: commit.txt
|
build: commit.txt
|
||||||
go build -tags no_emoji -trimpath -ldflags="-s -w -X main.rex_version=$(REX_VERSION)" -buildvcs=false -o $(NAME)
|
go build -tags no_emoji -trimpath -ldflags="-s -w -X main.rex_version=$(REX_VERSION)" -buildvcs=false -o $(NAME)
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
NAME = rexserver
|
NAME = rexserver
|
||||||
|
|
||||||
VERSION_FILE := ../VERSION.txt
|
REX_VERSION ?= $(shell bash ../generate_version.sh)
|
||||||
REX_VERSION ?= $(shell cat $(VERSION_FILE))
|
|
||||||
|
|
||||||
build: commit.txt
|
build: commit.txt
|
||||||
go build -ldflags="-X main.rex_version=$(REX_VERSION)" -o $(NAME)
|
go build -ldflags="-X main.rex_version=$(REX_VERSION)" -o $(NAME)
|
||||||
|
|
Loading…
Add table
Reference in a new issue