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

Size
696 B
Lines
17
Language
python
SHA-256
2ff8695ced96…
View on GitHub

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"""
6import hashlib
7import sys
8from pathlib import Path
9
10if len(sys.argv) != 3:
11 sys.exit(__doc__)
12tag, archive = sys.argv[1], Path(sys.argv[2])
13if not tag.startswith("v0.") or "-build." not in tag:
14 sys.exit(f"unexpected tag form: {tag}")
15template = (Path(__file__).resolve().parents[2] / "packaging/homebrew/ckey.rb.in").read_text()
16digest = hashlib.sha256(archive.read_bytes()).hexdigest()
17print(template.replace("@TAG@", tag).replace("@VERSION@", tag[1:]).replace("@SHA256@", digest), end="")