mirror of
https://github.com/Sea-Haven-Industries/afterhours-shift-manager.git
synced 2026-09-30 21:53:11 +00:00
Version the bot continuously from CHANGELOG.md (the single source of truth for both the version and the staff-readable notes) and surface changes to users in two ways: - A new afterhours-release-notifier Lambda posts a "What's New" message to the shift channel on minor/major releases (patches stay silent). - The bot gains an App Home "About" tab showing what it does, the command list, and the current version's notes. release.yaml runs on Deploy success (not release:published — GITHUB_TOKEN events don't start downstream workflows), checks out the deployed commit, and tags + publishes a GitHub Release + invokes the notifier. It assumes a dedicated, boundary-carrying OIDC role scoped to InvokeFunction on the notifier; the account's cfn role gates role creation on that boundary. The manual Version Bump workflow is retired. A CI guard enforces that a CHANGELOG edit is a clean SemVer bump and that the in-package copy matches.
52 lines
1.6 KiB
Python
52 lines
1.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Thin CLI over ``shared.changelog`` for the release workflow.
|
|
|
|
Keeps all changelog parsing in one tested module instead of inline shell/Python
|
|
in the workflow. Reads the changelog file given as an argument.
|
|
|
|
Usage:
|
|
changelog_cli.py top-version <file> # newest entry's version
|
|
changelog_cli.py bump-kind <file> <prev> # major|minor|patch|none vs <prev>
|
|
changelog_cli.py payload <file> <version> # JSON {version, notes, date_label}
|
|
"""
|
|
|
|
import json
|
|
import pathlib
|
|
import sys
|
|
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1] / "src" / "shared"))
|
|
|
|
from shared.changelog import bump_kind, entry_for, top_version # noqa: E402
|
|
|
|
|
|
def main(argv: list[str]) -> int:
|
|
if len(argv) < 3:
|
|
sys.exit(__doc__)
|
|
cmd, path = argv[1], argv[2]
|
|
text = pathlib.Path(path).read_text()
|
|
|
|
if cmd == "top-version":
|
|
sys.stdout.write(top_version(text) or "")
|
|
elif cmd == "bump-kind":
|
|
prev = argv[3].lstrip("v")
|
|
top = top_version(text)
|
|
sys.stdout.write((bump_kind(top, prev) or "none") if top else "none")
|
|
elif cmd == "payload":
|
|
version = argv[3].lstrip("v")
|
|
entry = entry_for(text, version)
|
|
sys.stdout.write(
|
|
json.dumps(
|
|
{
|
|
"version": version,
|
|
"notes": entry.body if entry else "",
|
|
"date_label": entry.date_label if entry else "",
|
|
}
|
|
)
|
|
)
|
|
else:
|
|
sys.exit(f"unknown command: {cmd}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main(sys.argv))
|