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