Add a make package target for versioned Linux CLI release tarballs
Bundles deck-engine, interpreter-cli, run-engine.sh/run-interpreter.sh, img/, i18n/, LICENSE, README.md, and docs/reading.md into dist/deck-in-a-dash-<version>-linux-<arch>.tar.gz. Version defaults to the current git tag (vX.Y.Z), falling back to a 0.0.0-dev+<sha> placeholder when untagged
This commit is contained in:
@@ -76,7 +76,11 @@ JSON_TEST_BIN := $(BUILD_DIR)/json_test
|
||||
NARRATIVE_TEST_BIN := $(BUILD_DIR)/narrative_test
|
||||
GUIDANCE_TEST_BIN := $(BUILD_DIR)/guidance_test
|
||||
|
||||
.PHONY: all test clean images i18n scripts
|
||||
# Linux CLI release tarball - see the `package` target below.
|
||||
ARCH := $(shell uname -m)
|
||||
PACKAGE_DIR := $(BUILD_DIR)/package
|
||||
|
||||
.PHONY: all test clean images i18n scripts package
|
||||
|
||||
all: $(ENGINE_BINARY) $(INTERP_BINARY) images i18n scripts
|
||||
|
||||
@@ -152,6 +156,47 @@ $(OBJ_DIR)/%.o: %.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
# Builds a versioned Linux CLI release tarball at
|
||||
# dist/deck-in-a-dash-<version>-linux-<arch>.tar.gz. Version defaults to
|
||||
# the current git tag (vX.Y.Z, tag prefix stripped) - push a tag to drive
|
||||
# a release. Override with `make package VERSION=1.2.3`, or just run it
|
||||
# untagged for a local dev build (gets a 0.0.0-dev+<sha> placeholder
|
||||
# version, with a warning).
|
||||
#
|
||||
# Copies files into the staging dir by explicit name only - never a
|
||||
# wildcard/recursive copy of dist/ itself - so a real, filled-in
|
||||
# dist/user.properties (birth data, gitignored, private) can never
|
||||
# accidentally end up in a package. The package gets the placeholder
|
||||
# template instead, same as a first-time `make` produces.
|
||||
package: all
|
||||
@V="$(VERSION)"; \
|
||||
if [ -z "$$V" ]; then \
|
||||
if TAG=$$(git describe --tags --exact-match --match 'v[0-9]*.[0-9]*.[0-9]*' 2>/dev/null); then \
|
||||
V=$${TAG#v}; \
|
||||
else \
|
||||
V="0.0.0-dev+$$(git rev-parse --short HEAD)"; \
|
||||
echo "WARNING: HEAD is not on a vX.Y.Z tag - building placeholder version $$V (push a tag to drive a real release version)" >&2; \
|
||||
fi; \
|
||||
fi; \
|
||||
case "$$V" in \
|
||||
[0-9]*.[0-9]*.[0-9]*) ;; \
|
||||
*) echo "PREFLIGHT FAIL: VERSION '$$V' is not a semantic version (expected X.Y.Z, optionally with a -pre+meta suffix)" >&2; exit 1;; \
|
||||
esac; \
|
||||
PKG_NAME="deck-in-a-dash-$$V-linux-$(ARCH)"; \
|
||||
PKG_STAGE="$(PACKAGE_DIR)/$$PKG_NAME"; \
|
||||
echo "Packaging $$PKG_NAME"; \
|
||||
rm -rf "$$PKG_STAGE"; \
|
||||
mkdir -p "$$PKG_STAGE"; \
|
||||
cp $(ENGINE_BINARY) $(INTERP_BINARY) "$$PKG_STAGE/"; \
|
||||
cp $(DIST_DIR)/run-engine.sh $(DIST_DIR)/run-interpreter.sh "$$PKG_STAGE/"; \
|
||||
cp -r $(DIST_IMG_DIR) $(DIST_I18N_DIR) "$$PKG_STAGE/"; \
|
||||
cp $(ENGINE_SCRIPTS_DIR)/user.properties.template "$$PKG_STAGE/user.properties"; \
|
||||
cp LICENSE README.md "$$PKG_STAGE/"; \
|
||||
cp docs/reading.md "$$PKG_STAGE/READING.md"; \
|
||||
tar -czf "$(DIST_DIR)/$$PKG_NAME.tar.gz" -C "$(PACKAGE_DIR)" "$$PKG_NAME"; \
|
||||
rm -rf "$(PACKAGE_DIR)"; \
|
||||
echo "Wrote $(DIST_DIR)/$$PKG_NAME.tar.gz"
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD_DIR) $(ENGINE_BINARY) $(INTERP_BINARY) $(DIST_IMG_DIR) $(DIST_I18N_DIR) \
|
||||
$(DIST_DIR)/run-engine.sh $(DIST_DIR)/run-interpreter.sh
|
||||
|
||||
Reference in New Issue
Block a user