Files
arti-pack/Makefile
T
unkin-agent 73960b03e2
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/lint Pipeline was successful
Gate pull requests on stylua formatting
- add a fmt-check make target running stylua --check over lua, tests and plugin
- add a fmt step to the lint pipeline fetching pinned stylua v2.5.2
- verify the download against its sha256 before use
2026-09-09 23:29:48 +10:00

83 lines
2.9 KiB
Makefile

.PHONY: test lint fmt fmt-check pre-commit package verify-package patch minor major _tag
VERSION ?= $(shell git describe --tags --always)
# Archive names drop the leading "v", the way tag source archives do.
BARE_VERSION = $(patsubst v%,%,$(VERSION))
DIST = dist
ARCHIVE = $(DIST)/arti-pack-$(BARE_VERSION).zip
test:
nvim --headless -l tests/run.lua
lint:
luacheck lua tests
LUA_SOURCES = lua tests plugin
fmt:
stylua $(LUA_SOURCES)
fmt-check:
stylua --check $(LUA_SOURCES)
pre-commit:
@uvx pre-commit run --all-files
# The prefix directory is what arti-pack's own extractor strips on install.
package:
@mkdir -p $(DIST)
git archive --format=zip --prefix=arti-pack-$(BARE_VERSION)/ -o $(ARCHIVE) HEAD
@echo $(ARCHIVE)
# Published uploads are immutable, so a malformed archive cannot be replaced at
# its version path. Assert the shape before anything ships.
RUNTIME_PATHS = lua/ plugin/ doc/ README.md
EXCLUDED_PATHS = tests/ .woodpecker/ Makefile .editorconfig .gitattributes \
.gitignore .luacheckrc .pre-commit-config.yaml .stylua.toml
verify-package:
@test -f $(ARCHIVE) || { echo "verify-package: $(ARCHIVE) not built"; exit 1; }
@names=$$(unzip -Z1 $(ARCHIVE)); \
roots=$$(printf '%s\n' "$$names" | cut -d/ -f1 | sort -u); \
if [ "$$(printf '%s\n' "$$roots" | wc -l)" -ne 1 ]; then \
echo "verify-package: expected one top-level directory, found:"; \
printf ' %s\n' $$roots; exit 1; \
fi; \
fail=0; \
printf '%s\n' "$$names" | grep -q "^$$roots/." || \
{ echo "verify-package: top-level $$roots is not a directory"; fail=1; }; \
for p in $(RUNTIME_PATHS); do \
printf '%s\n' "$$names" | grep -q "^$$roots/$$p" || \
{ echo "verify-package: missing runtime path $$p"; fail=1; }; \
done; \
for p in $(EXCLUDED_PATHS); do \
if printf '%s\n' "$$names" | grep -q "^$$roots/$$p"; then \
echo "verify-package: excluded path $$p leaked into the archive"; fail=1; \
fi; \
done; \
[ $$fail -eq 0 ] || exit 1; \
echo "verify-package: $(ARCHIVE) ok, root $$roots"
# Bump helpers — read the latest semver tag and create the next one.
# If no tag exists yet, start from v0.0.0.
_LATEST = $(shell git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$$' | head -1)
_BASE = $(if $(_LATEST),$(_LATEST),v0.0.0)
_MAJ = $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f1)
_MIN = $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f2)
_PAT = $(shell echo $(_BASE) | sed 's/^v//' | cut -d. -f3)
patch:
@NEW=v$(_MAJ).$(_MIN).$(shell expr $(_PAT) + 1); \
git tag -a $$NEW -m "Release $$NEW" && echo "Tagged $$NEW" && $(MAKE) _tag TAG=$$NEW
minor:
@NEW=v$(_MAJ).$(shell expr $(_MIN) + 1).0; \
git tag -a $$NEW -m "Release $$NEW" && echo "Tagged $$NEW" && $(MAKE) _tag TAG=$$NEW
major:
@NEW=v$(shell expr $(_MAJ) + 1).0.0; \
git tag -a $$NEW -m "Release $$NEW" && echo "Tagged $$NEW" && $(MAKE) _tag TAG=$$NEW
_tag:
git push origin $(TAG)