From d3005457d46015bd10a87f7af61fa5a62d30caa9 Mon Sep 17 00:00:00 2001 From: Prabuddha Chakraborty Date: Tue, 28 Oct 2025 12:29:48 +0530 Subject: [PATCH 1/3] update release --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 31f289f2..5d42334f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pytfe" -version = "0.0.1-alpha" +version = "0.1.1" description = "Official Python SDK for HashiCorp Terraform Cloud / Terraform Enterprise (TFE) API v2" readme = "README.md" license = { text = "MPL-2.0" } From f23406c1001f930e645b6d85ad1970ccf1dde21d Mon Sep 17 00:00:00 2001 From: Prabuddha Chakraborty Date: Tue, 28 Oct 2025 15:01:06 +0530 Subject: [PATCH 2/3] add pypi push script --- .gitignore | 2 +- bin/publish-pypi.sh | 84 +++++++++++++++++++++++++++++++++++++++++++++ pyproject.toml | 2 +- 3 files changed, 86 insertions(+), 2 deletions(-) create mode 100755 bin/publish-pypi.sh diff --git a/.gitignore b/.gitignore index 7e44cac2..17c23a00 100644 --- a/.gitignore +++ b/.gitignore @@ -109,7 +109,7 @@ profiles .DS_Store # Repo-specific -bin/ +.bin/ # Generated protoset files *.protoset diff --git a/bin/publish-pypi.sh b/bin/publish-pypi.sh new file mode 100755 index 00000000..9185a936 --- /dev/null +++ b/bin/publish-pypi.sh @@ -0,0 +1,84 @@ +#!/usr/bin/env bash +set -euo pipefail + + +PYPI_REPO="${PYPI_REPO:-testpypi}" # "pypi" or "testpypi" +PYPI_TOKEN="${PYPI_TOKEN:-}" # export PYPI_TOKEN="pypi-***" (or test token) +PYTHON="${PYTHON:-python}" # "python" or "python3" +DIST_DIR="dist" +PYPROJECT="pyproject.toml" + + +if [[ ! -f "$PYPROJECT" ]]; then + echo "$PYPROJECT not found (are you in the project root?)" + exit 1 +fi + +if [[ -z "$PYPI_TOKEN" ]]; then + echo "PYPI_TOKEN not set. Run: export PYPI_TOKEN='pypi-XXXX...'" + exit 1 +fi + +# Read project metadata (name & version) from pyproject.toml using Python +read_pyproject() { + "$PYTHON" - <<'PY' +import sys, pathlib +pp = pathlib.Path("pyproject.toml") +if not pp.exists(): + print("unknown|unknown"); sys.exit(0) +try: + import tomllib +except ModuleNotFoundError: + # Python <3.11 fallback + import json, re + # very small fallback parser: good enough to grab name/version in simple cases + text = pp.read_text() + name = re.search(r'(?m)^\s*name\s*=\s*"([^"]+)"', text) + ver = re.search(r'(?m)^\s*version\s*=\s*"([^"]+)"', text) + print(f"{name.group(1) if name else 'unknown'}|{ver.group(1) if ver else 'unknown'}") + sys.exit(0) + +data = tomllib.loads(pp.read_bytes()) +proj = data.get("project", {}) +print(f"{proj.get('name','unknown')}|{proj.get('version','unknown')}") +PY +} + +IFS="|" read -r PKG_NAME PKG_VER < <(read_pyproject) +echo "Package: ${PKG_NAME} Version: ${PKG_VER}" + + +echo "Cleaning old builds..." +rm -rf "$DIST_DIR" build ./*.egg-info + + +echo "Installing build tools..." +$PYTHON -m pip install -q --upgrade pip build twine + +echo "Building sdist & wheel..." +$PYTHON -m build # uses hatchling per your [build-system] + +echo "Validating with twine..." +$PYTHON -m twine check "$DIST_DIR"/* + + +if [[ "$PYPI_REPO" == "testpypi" ]]; then + REPO_URL="https://test.pypi.org/legacy/" + echo "Target: TestPyPI" +else + REPO_URL="https://upload.pypi.org/legacy/" + echo "Target: PyPI" +fi + +# ----------------------------- +# Upload +# ----------------------------- +echo "Uploading distributions..." +$PYTHON -m twine upload \ + --non-interactive \ + --repository-url "$REPO_URL" \ + -u __token__ \ + -p "$PYPI_TOKEN" \ + "$DIST_DIR"/* + +echo "Published ${PKG_NAME} ${PKG_VER} to ${PYPI_REPO}" diff --git a/pyproject.toml b/pyproject.toml index 5d42334f..7f0fc627 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "pytfe" -version = "0.1.1" +version = "0.1.0" description = "Official Python SDK for HashiCorp Terraform Cloud / Terraform Enterprise (TFE) API v2" readme = "README.md" license = { text = "MPL-2.0" } From 004e6385ddf1d4a2057141603a022dc221e97618 Mon Sep 17 00:00:00 2001 From: Prabuddha Chakraborty Date: Tue, 28 Oct 2025 15:09:20 +0530 Subject: [PATCH 3/3] update readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1c0d9e7f..2aefdf4b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,6 @@ Construct a new **pyTFE** client, then use the resource services on the client t ### (Recommended) Using explicit config ```python -import os from pytfe import TFEClient, TFEConfig config = TFEConfig(