Skip to content

Commit 0b23635

Browse files
authored
Merge pull request #51 from hashicorp/next-0.1.x
Release: 0.1.0
2 parents 9aba767 + 004e638 commit 0b23635

File tree

4 files changed

+86
-3
lines changed

4 files changed

+86
-3
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ profiles
109109
.DS_Store
110110

111111
# Repo-specific
112-
bin/
112+
.bin/
113113

114114
# Generated protoset files
115115
*.protoset

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ Construct a new **pyTFE** client, then use the resource services on the client t
2525
### (Recommended) Using explicit config
2626

2727
```python
28-
import os
2928
from pytfe import TFEClient, TFEConfig
3029

3130
config = TFEConfig(

bin/publish-pypi.sh

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
5+
PYPI_REPO="${PYPI_REPO:-testpypi}" # "pypi" or "testpypi"
6+
PYPI_TOKEN="${PYPI_TOKEN:-}" # export PYPI_TOKEN="pypi-***" (or test token)
7+
PYTHON="${PYTHON:-python}" # "python" or "python3"
8+
DIST_DIR="dist"
9+
PYPROJECT="pyproject.toml"
10+
11+
12+
if [[ ! -f "$PYPROJECT" ]]; then
13+
echo "$PYPROJECT not found (are you in the project root?)"
14+
exit 1
15+
fi
16+
17+
if [[ -z "$PYPI_TOKEN" ]]; then
18+
echo "PYPI_TOKEN not set. Run: export PYPI_TOKEN='pypi-XXXX...'"
19+
exit 1
20+
fi
21+
22+
# Read project metadata (name & version) from pyproject.toml using Python
23+
read_pyproject() {
24+
"$PYTHON" - <<'PY'
25+
import sys, pathlib
26+
pp = pathlib.Path("pyproject.toml")
27+
if not pp.exists():
28+
print("unknown|unknown"); sys.exit(0)
29+
try:
30+
import tomllib
31+
except ModuleNotFoundError:
32+
# Python <3.11 fallback
33+
import json, re
34+
# very small fallback parser: good enough to grab name/version in simple cases
35+
text = pp.read_text()
36+
name = re.search(r'(?m)^\s*name\s*=\s*"([^"]+)"', text)
37+
ver = re.search(r'(?m)^\s*version\s*=\s*"([^"]+)"', text)
38+
print(f"{name.group(1) if name else 'unknown'}|{ver.group(1) if ver else 'unknown'}")
39+
sys.exit(0)
40+
41+
data = tomllib.loads(pp.read_bytes())
42+
proj = data.get("project", {})
43+
print(f"{proj.get('name','unknown')}|{proj.get('version','unknown')}")
44+
PY
45+
}
46+
47+
IFS="|" read -r PKG_NAME PKG_VER < <(read_pyproject)
48+
echo "Package: ${PKG_NAME} Version: ${PKG_VER}"
49+
50+
51+
echo "Cleaning old builds..."
52+
rm -rf "$DIST_DIR" build ./*.egg-info
53+
54+
55+
echo "Installing build tools..."
56+
$PYTHON -m pip install -q --upgrade pip build twine
57+
58+
echo "Building sdist & wheel..."
59+
$PYTHON -m build # uses hatchling per your [build-system]
60+
61+
echo "Validating with twine..."
62+
$PYTHON -m twine check "$DIST_DIR"/*
63+
64+
65+
if [[ "$PYPI_REPO" == "testpypi" ]]; then
66+
REPO_URL="https://test.pypi.org/legacy/"
67+
echo "Target: TestPyPI"
68+
else
69+
REPO_URL="https://upload.pypi.org/legacy/"
70+
echo "Target: PyPI"
71+
fi
72+
73+
# -----------------------------
74+
# Upload
75+
# -----------------------------
76+
echo "Uploading distributions..."
77+
$PYTHON -m twine upload \
78+
--non-interactive \
79+
--repository-url "$REPO_URL" \
80+
-u __token__ \
81+
-p "$PYPI_TOKEN" \
82+
"$DIST_DIR"/*
83+
84+
echo "Published ${PKG_NAME} ${PKG_VER} to ${PYPI_REPO}"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "pytfe"
7-
version = "0.0.1-alpha"
7+
version = "0.1.0"
88
description = "Official Python SDK for HashiCorp Terraform Cloud / Terraform Enterprise (TFE) API v2"
99
readme = "README.md"
1010
license = { text = "MPL-2.0" }

0 commit comments

Comments
 (0)