From 3b6a1d18fa057d44b82cae91589a0576c815ae25 Mon Sep 17 00:00:00 2001 From: geo7 Date: Sun, 6 Jul 2025 18:06:05 +0100 Subject: [PATCH] add make command to publish to pypi --- Makefile | 5 +++++ scripts/publish.sh | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 scripts/publish.sh diff --git a/Makefile b/Makefile index f244046..91db11b 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ .PHONY: test .PHONY: requirements .PHONY: help +.PHONY: publish CLOC := cloc @@ -64,6 +65,10 @@ nuke: rm -rf .venv @$(MAKE) --no-print-directory install + +publish: ## Publish package to PyPI + @bash ./scripts/publish.sh + ########## # PYTEST # ########## diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100644 index 0000000..c6b7c6e --- /dev/null +++ b/scripts/publish.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -euo pipefail + +ENV_FILE=".env" + +# Check if the .env file exists +if [ -f "$ENV_FILE" ]; then + set -a + source "$ENV_FILE" + set +a +else + echo "Error loading .env" + exit 1 +fi + +# UV_PUBLISH_TOKEN should be available +if [ -z "$UV_PUBLISH_TOKEN" ]; then + echo "Error: UV_PUBLISH_TOKEN is not set in .env." + exit 1 +fi + +# Remove old dist +rm -rf dist || true +uv build +uv publish + +if [ $? -eq 0 ]; then + echo "--- Package Published Successfully! ---" +else + echo "--- Package Publishing FAILED! ---" + exit 1 +fi