Debian Codegraph @

Makefile

raw
1 # A small bit of automation for various steps in building + releasing dtrx
2
3 DTRX_TAGNAME=$(shell uv version --short)
4
5 # require make 4.3+ for grouped targets
6 MINIMUM_MAKE_VERSION = 4.3
7 MAKE_TEST_VERSION = $(shell printf "%s\n%s" $(MAKE_VERSION) $(MINIMUM_MAKE_VERSION) | sort --version-sort)
8 ifneq ($(MINIMUM_MAKE_VERSION),$(firstword $(MAKE_TEST_VERSION)))
9 $(error Make version is too low. Please upgrade to $(MINIMUM_MAKE_VERSION) or higher.)
10 endif
11
12 BUILD_ARTIFACTS= \
13 dist/dtrx-$(DTRX_TAGNAME).py \
14 dist/dtrx-$(DTRX_TAGNAME).pyz \
15 dist/dtrx-$(DTRX_TAGNAME)-py2.py3-none-any.whl \
16 dist/dtrx-$(DTRX_TAGNAME).tar.gz \
17
18 .PHONY: build
19 build: $(BUILD_ARTIFACTS)
20
21 # copy the standalone script too into ./dist/
22 dist/dtrx-$(DTRX_TAGNAME).py: dtrx/dtrx.py
23 mkdir -p $(dir $@)
24 cp $^ $@
25
26 # generate a zipapp
27 dist/dtrx-$(DTRX_TAGNAME).pyz: dtrx/dtrx.py
28 mkdir -p $(dir $@)
29 python -m zipapp dtrx --compress --main "dtrx:main" --python "/usr/bin/env python" --output $@
30
31 # build the wheel and source dist
32 dist/dtrx-$(DTRX_TAGNAME)-py2.py3-none-any.whl dist/dtrx-$(DTRX_TAGNAME).tar.gz &: dtrx/dtrx.py
33 uv build --no-build-logs
34
35 .PHONY: publish-release
36 publish-release: $(BUILD_ARTIFACTS)
37 # first confirm that we're on a tag
38 @git describe --exact-match > /dev/null || (echo ERROR: not on a tag; false)
39 # if PYPI_TOKEN is not set, fail
40 @test -n "$$PYPI_TOKEN" || (echo "ERROR: PYPI_TOKEN environment variable is not set"; false)
41 # prompt before firing off the release
42 @echo -n "About to publish to GitHub and PyPi, are you sure? [y/N] " && read ans && [ $${ans:-'N'} = 'y' ]
43 gh release create --generate-notes $(DTRX_TAGNAME)
44 gh release upload $(DTRX_TAGNAME) dist/*
45 @uv publish --token="${PYPI_TOKEN}" dist/dtrx-$(DTRX_TAGNAME).tar.gz dist/dtrx-$(DTRX_TAGNAME)-py3-none-any.whl