Skip to content

Commit c09a01f

Browse files
committed
chore(make): load .env and support UV_PUBLISH_USERNAME/UV_PUBLISH_PASSWORD or token for uv publish
1 parent 4a12d68 commit c09a01f

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

Makefile

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,25 @@ build:
2727
uv build
2828

2929
publish: build
30-
@if [ -z "$${PYPI_API_TOKEN}" ]; then \
31-
echo "PYPI_API_TOKEN is not set"; \
30+
@# Load local environment if present
31+
@set -e; \
32+
if [ -f .env ]; then set -a; . ./.env; set +a; fi; \
33+
if [ -n "$${UV_PUBLISH_TOKEN:-}" ]; then \
34+
echo "Publishing with token (UV_PUBLISH_TOKEN)"; \
35+
uv publish --token "$${UV_PUBLISH_TOKEN}"; \
36+
elif [ -n "$${PYPI_API_TOKEN:-}" ]; then \
37+
echo "Publishing with token (PYPI_API_TOKEN)"; \
38+
uv publish --token "$${PYPI_API_TOKEN}"; \
39+
elif [ -n "$${UV_PUBLISH_USERNAME:-}" ] && [ -n "$${UV_PUBLISH_PASSWORD:-}" ]; then \
40+
echo "Publishing with username/password (UV_PUBLISH_USERNAME)"; \
41+
uv publish --username "$${UV_PUBLISH_USERNAME}" --password "$${UV_PUBLISH_PASSWORD}"; \
42+
elif [ -n "$${PYPI_USERNAME:-}" ] && [ -n "$${PYPI_PASSWORD:-}" ]; then \
43+
echo "Publishing with username/password (PYPI_USERNAME)"; \
44+
uv publish --username "$${PYPI_USERNAME}" --password "$${PYPI_PASSWORD}"; \
45+
else \
46+
echo "No credentials found. Set UV_PUBLISH_TOKEN or PYPI_API_TOKEN, or UV_PUBLISH_USERNAME/UV_PUBLISH_PASSWORD (or PYPI_USERNAME/PYPI_PASSWORD)."; \
3247
exit 1; \
3348
fi
34-
uv publish --token "$$PYPI_API_TOKEN"
3549

3650
clean:
3751
rm -rf build dist *.egg-info .pytest_cache .mypy_cache .ruff_cache

0 commit comments

Comments
 (0)