Viewing is open to everyone. Downloading and starring need a GitHub sign-in.
Sign in with GitHub
make_homebrew_formula.py
v0.1.0-build.85
Latest
Commit ede38f5
Sign in with GitHub to download. Each download is recorded with your GitHub username.
| 1 | #!/usr/bin/env python3 |
| 2 | """Write the Homebrew formula for a release tag from its source archive. |
| 3 | |
| 4 | tools/release/make_homebrew_formula.py v0.1.0-build.66 ckey-v0.1.0-build.66.tar.gz > ckey.rb |
| 5 | """ |
| 6 | import hashlib |
| 7 | import sys |
| 8 | from pathlib import Path |
| 9 | |
| 10 | if len(sys.) != 3: |
| 11 | sys.exit(__doc__) |
| 12 | tag, archive = sys.argv[1], Path(sys.argv[2]) |
| 13 | if not tag.startswith("v0.") or "-build." not in tag: |
| 14 | sys.exit(f"unexpected tag form: {tag}") |
| 15 | template = (Path(__file__).resolve().parents[2] / "packaging/homebrew/ckey.rb.in").read_text() |
| 16 | digest = hashlib.sha256(archive.read_bytes()).hexdigest() |
| 17 | print(template.replace("@TAG@", tag).replace("@VERSION@", tag[1:]).replace("@SHA256@", digest), end="") |