1- .PHONY : help build run test lint format verify clean bump install
1+ .PHONY : help build run test lint format verify clean bump install publish bump-formula
2+
3+ BINARY := hackertuah
4+ TAP_REPO := https://github.com/program247365/homebrew-tap.git
5+ TAP_DIR := /tmp/homebrew-tap-update
6+ VERSION := $(shell cargo metadata --no-deps --format-version 1 | python3 -c "import sys,json;print(json.load(sys.stdin) ['packages'][0]['version'])")
27
38help :
49 @echo " Available commands:"
5- @echo " make build - Build the project (cargo build)"
6- @echo " make run - Run the project (cargo run)"
7- @echo " make test - Run tests (cargo test)"
8- @echo " make lint - Run clippy linter (cargo clippy)"
9- @echo " make format - Run cargo fmt"
10- @echo " make verify - Format, lint, build, and test (use after any change)"
11- @echo " make clean - Clean build artifacts (cargo clean)"
12- @echo " make bump - Bump version with cog (cog bump --auto)"
13- @echo " make install - Build and install binary to system bin directory"
10+ @echo " make build - Build the project (cargo build)"
11+ @echo " make run - Run the project (cargo run)"
12+ @echo " make test - Run tests (cargo test)"
13+ @echo " make lint - Run clippy linter (cargo clippy)"
14+ @echo " make format - Run cargo fmt"
15+ @echo " make verify - Format, lint, build, and test (use after any change)"
16+ @echo " make clean - Clean build artifacts (cargo clean)"
17+ @echo " make bump - Bump version with cog (cog bump --auto)"
18+ @echo " make install - Build and install binary to ~/bin"
19+ @echo " make publish - Bump version, create GitHub release, update Homebrew formula"
20+ @echo " make bump-formula - Update Homebrew tap formula to current version"
1421
1522build :
1623 cargo build
@@ -36,47 +43,56 @@ bump:
3643 cog bump --auto
3744
3845install :
39- @echo " Detecting operating system..."
40- @if [ " $( OS) " = " Windows_NT" ]; then \
41- echo " Installing for Windows..." ; \
42- cargo build --release; \
43- mkdir -p " $( USERPROFILE) /bin" ; \
44- cp target/release/hackertuah.exe " $( USERPROFILE) /bin/" ; \
45- echo " Checking PATH configuration..." ; \
46- if ! echo " $$ PATH" | grep -q " $( USERPROFILE) /bin" ; then \
47- echo " Adding $( USERPROFILE) /bin to PATH..." ; \
48- echo ' export PATH="$(USERPROFILE)/bin:$$PATH"' >> " $( USERPROFILE) /.bashrc" ; \
49- echo ' export PATH="$(USERPROFILE)/bin:$$PATH"' >> " $( USERPROFILE) /.zshrc" 2> /dev/null || true ; \
50- echo " PATH updated. Please restart your terminal or run: source ~/.bashrc" ; \
51- else \
52- echo " $( USERPROFILE) /bin is already in PATH" ; \
53- fi ; \
54- elif [ " $( shell uname) " = " Darwin" ]; then \
55- echo " Installing for macOS..." ; \
56- mkdir -p ~ /bin; \
57- cargo build --release; \
58- cp target/release/hackertuah ~ /bin/; \
59- echo " Checking PATH configuration..." ; \
60- if ! echo " $$ PATH" | grep -q " ~/bin\|$$ HOME/bin" ; then \
61- echo " Adding ~/bin to PATH..." ; \
62- echo ' export PATH="$$HOME/bin:$$PATH"' >> ~ /.zshrc; \
63- echo ' export PATH="$$HOME/bin:$$PATH"' >> ~ /.bash_profile 2> /dev/null || true ; \
64- echo " PATH updated. Please restart your terminal or run: source ~/.zshrc" ; \
65- else \
66- echo " ~/bin is already in PATH" ; \
67- fi ; \
68- else \
69- echo " Installing for Linux..." ; \
70- mkdir -p ~ /bin; \
71- cargo build --release; \
72- cp target/release/hackertuah ~ /bin/; \
73- echo " Checking PATH configuration..." ; \
74- if ! echo " $$ PATH" | grep -q " ~/bin\|$$ HOME/bin" ; then \
75- echo " Adding ~/bin to PATH..." ; \
76- echo ' export PATH="$$HOME/bin:$$PATH"' >> ~ /.bashrc; \
77- echo ' export PATH="$$HOME/bin:$$PATH"' >> ~ /.zshrc 2> /dev/null || true ; \
78- echo " PATH updated. Please restart your terminal or run: source ~/.bashrc" ; \
79- else \
80- echo " ~/bin is already in PATH" ; \
81- fi ; \
82- fi
46+ mkdir -p ~ /bin
47+ cargo build --release
48+ cp target/release/$(BINARY ) ~ /bin/$(BINARY )
49+
50+ # ── Homebrew release workflow ──────────────────────────────────────────────────
51+ # Usage:
52+ # make publish — bump version, push, create GitHub release, update formula
53+ # make bump-formula — update Homebrew tap formula to current version only
54+
55+ publish : # # Bump version, push, create GitHub release, update Homebrew formula
56+ cog bump --auto
57+ $(eval VERSION := $(shell cargo metadata --no-deps --format-version 1 | python3 -c "import sys,json;print(json.load(sys.stdin) ['packages'][0]['version']) " ))
58+ @echo " Publishing v$( VERSION) ..."
59+ git push origin main
60+ git push origin v$(VERSION )
61+ gh release create v$(VERSION ) \
62+ --repo program247365/hackertuah \
63+ --title " v$( VERSION) " \
64+ --generate-notes
65+ $(MAKE ) bump-formula VERSION=$(VERSION )
66+
67+ bump-formula : # # Update Homebrew tap formula to current version
68+ $(eval SHA256 := $(shell curl -sL "https://github.com/program247365/hackertuah/archive/refs/tags/v$(VERSION ) .tar.gz" | shasum -a 256 | awk '{print $$1}') )
69+ @echo " Updating formula: v$( VERSION) sha256=$( SHA256) "
70+ rm -rf $(TAP_DIR )
71+ git clone $(TAP_REPO ) $(TAP_DIR )
72+ python3 -c " \
73+ v ='$(VERSION ) '; s='$(SHA256 ) '; \
74+ content = '''class Hackertuah < Formula\n\
75+ desc \"Terminal UI for browsing Hacker News\"\n\
76+ homepage \"https://github.com/program247365/hackertuah\"\n\
77+ url \"https://github.com/program247365/hackertuah/archive/refs/tags/v{v}.tar.gz\"\n\
78+ sha256 \"{s}\"\n\
79+ license \"MIT\"\n\
80+ head \"https://github.com/program247365/hackertuah.git\", branch: \"main\"\n\
81+ \n\
82+ depends_on \"rust\" => :build\n\
83+ \n\
84+ def install\n\
85+ system \"cargo\", \"install\", *std_cargo_args\n\
86+ end\n\
87+ \n\
88+ test do\n\
89+ assert_predicate bin/\"hackertuah\", :exist?\n\
90+ end\n\
91+ end\n\
92+ '''.format(v=v, s=s); \
93+ open('$(TAP_DIR ) /Formula/hackertuah.rb', 'w').write(content)"
94+ cd $(TAP_DIR) && git add Formula/hackertuah.rb && \
95+ git commit -m "Update hackertuah to v$(VERSION)" && \
96+ git push origin main
97+ rm -rf $(TAP_DIR)
98+ @echo "Done. Install with: brew tap program247365/tap && brew install hackertuah"
0 commit comments