Files
2025-07-13 21:52:27 +00:00

48 lines
1.3 KiB
Python

"""
A release script to build and tag docker files, commit changes, and create release tags.
It requires `toml` to be installed (in Ubuntu via `sudo apt install python3 python3-toml` and then
`python3 release.py`).
Bump the version manually in Cargo.toml before running this script. You'll be asked for
confirmation before running all the steps, so you're safe if you forget.
"""
import os
import toml
def get_release_version():
"""
Reads the version from the Cargo.toml file.
"""
cargo_toml_path = os.path.join(os.path.dirname(__file__), "Cargo.toml")
with open(cargo_toml_path, "r", encoding="UTF-8") as f:
cargo_toml = toml.load(f)
return cargo_toml["package"]["version"]
version = get_release_version()
input(f"The current version is v{version}. Is this properly bumped? (Enter/Ctrl+C)")
SCRIPT = f"""
docker build -t registry.nyeki.dev/nyeki/api:latest .
docker push registry.nyeki.dev/nyeki/api:latest
docker tag registry.nyeki.dev/nyeki/api:latest registry.nyeki.dev/nyeki/api:v{version}
docker push registry.nyeki.dev/nyeki/api:v{version}
git add .
git commit -m "Release version v{version}"
git tag -a v{version} -m "Release version v{version}"
git push origin main
git push origin v{version}
"""
os.system(SCRIPT)
print(f"v{version} was released. Congratulations!")