Initial implementation of EnvBao
test / test (push) Failing after 2s
release / validate (push) Successful in 2s
release / build (linux-amd64, linux-amd64) (push) Successful in 38s
release / build (macos-arm64, macos-arm64) (push) Successful in 45s
release / build (linux-arm64, linux-arm64) (push) Successful in 1m19s
release / release (push) Successful in 15s

Single-binary CLI that injects environment variables from an OpenBao
server into the shell via eval "$(envbao)".

- Strict permission policy for ~/.envbao (exits 78 if unsafe)
- KV v1/v2 engine with auto-detection, pluggable engine registry
- Safe quoting for bash/zsh/sh/fish, protected-variable denylist
- Audit logging (stderr, private rotating file, syslog); no secrets logged
- Gitea pipelines for tests and SemVer-tag releases
- PyInstaller spec, docs, BSD-3-Clause licence

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
mattandClaude Sonnet 5.5 committed 2026-10-15 21:20:15 +01:00
commit d5636c46c7
37 files changed
+3234

No files matched your search

+54
View File
@@ -0,0 +1,54 @@
"""Validate a git tag as SemVer 2.0.0 and stamp it into ``src/envbao/_version.py``.
Usage: ``python scripts/version_from_tag.py v1.2.3`` - prints the bare version.
Exits non-zero (and writes nothing) if the tag is not ``v`` + a valid SemVer string.
"""
from __future__ import annotations
import re
import sys
from pathlib import Path
# Official semver.org regex, prefixed with the literal "v".
SEMVER_TAG = re.compile(
r"^v(?P<version>(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)"
r"(?:-(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?"
r"(?:\+[0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*)?)$"
)
VERSION_FILE = Path(__file__).resolve().parent.parent / "src" / "envbao" / "_version.py"
def parse_tag(tag: str) -> str:
"""Return the version for a valid ``vX.Y.Z[-pre][+build]`` tag, else raise ValueError."""
match = SEMVER_TAG.fullmatch(tag)
if not match:
raise ValueError(f"{tag!r} is not a valid semver tag (expected vMAJOR.MINOR.PATCH)")
return match["version"]
def write_version(version: str, path: Path | None = None) -> None:
"""Overwrite the version module (default: the package's) with ``version``."""
(path or VERSION_FILE).write_text(
'"""Package version. Overwritten from the git tag by the release pipeline."""\n\n'
f'__version__ = "{version}"\n',
encoding="utf-8",
)
def main(argv: list[str]) -> int:
if len(argv) != 2:
sys.stderr.write("usage: version_from_tag.py <tag>\n")
return 2
try:
version = parse_tag(argv[1])
except ValueError as exc:
sys.stderr.write(f"error: {exc}\n")
return 1
write_version(version)
sys.stdout.write(version + "\n")
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv))