-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (87 loc) · 3.54 KB
/
Makefile
File metadata and controls
101 lines (87 loc) · 3.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
.PHONY: help build run test lint format verify clean bump install publish bump-formula
BINARY := hackertuah
TAP_REPO := https://github.com/program247365/homebrew-tap.git
TAP_DIR := /tmp/homebrew-tap-update
VERSION := $(shell cargo metadata --no-deps --format-version 1 | python3 -c "import sys,json;print(json.load(sys.stdin)['packages'][0]['version'])")
help:
@echo "Available commands:"
@echo " make build - Build the project (cargo build)"
@echo " make run - Run the project (cargo run)"
@echo " make test - Run tests (cargo test)"
@echo " make lint - Run clippy linter (cargo clippy)"
@echo " make format - Run cargo fmt"
@echo " make verify - Format, lint, build, and test (use after any change)"
@echo " make clean - Clean build artifacts (cargo clean)"
@echo " make bump - Bump version with cog (cog bump --auto)"
@echo " make install - Build and install binary to ~/bin"
@echo " make publish - Bump version, create GitHub release, update Homebrew formula"
@echo " make bump-formula - Update Homebrew tap formula to current version"
build:
cargo build
run:
cargo run
test:
cargo test
lint:
cargo clippy -- -D warnings
format:
cargo fmt
verify: format lint build test
clean:
cargo clean
bump:
cog bump --auto
install:
mkdir -p ~/bin
cargo build --release
cp target/release/$(BINARY) ~/bin/$(BINARY)
# ── Homebrew release workflow ──────────────────────────────────────────────────
# Usage:
# make publish — bump version, push, create GitHub release, update formula
# make bump-formula — update Homebrew tap formula to current version only
publish: ## Bump version, push, create GitHub release, update Homebrew formula
cog bump --auto
$(eval TAG := $(shell git describe --tags --abbrev=0))
$(eval VERSION := $(shell echo "$(TAG)" | sed 's/^v//'))
@echo "Publishing $(TAG)..."
git push origin main
git push origin $(TAG)
gh release create $(TAG) \
--repo program247365/hackertuah \
--title "$(TAG)" \
--generate-notes
$(MAKE) bump-formula VERSION=$(VERSION)
bump-formula: ## Update Homebrew tap formula to current version (requires VERSION and TAG)
$(eval TAG ?= $(shell git describe --tags --abbrev=0))
$(eval VERSION ?= $(shell echo "$(TAG)" | sed 's/^v//'))
$(eval SHA256 := $(shell curl -sL "https://github.com/program247365/hackertuah/archive/refs/tags/$(TAG).tar.gz" | shasum -a 256 | awk '{print $$1}'))
@echo "Updating formula: v$(VERSION) sha256=$(SHA256)"
rm -rf $(TAP_DIR)
git clone $(TAP_REPO) $(TAP_DIR)
python3 -c "\
v='$(VERSION)'; s='$(SHA256)'; \
content = '''class Hackertuah < Formula\n\
desc \"Terminal UI for browsing Hacker News\"\n\
homepage \"https://github.com/program247365/hackertuah\"\n\
url \"https://github.com/program247365/hackertuah/archive/refs/tags/v{v}.tar.gz\"\n\
sha256 \"{s}\"\n\
license \"MIT\"\n\
head \"https://github.com/program247365/hackertuah.git\", branch: \"main\"\n\
\n\
depends_on \"rust\" => :build\n\
\n\
def install\n\
system \"cargo\", \"install\", *std_cargo_args\n\
end\n\
\n\
test do\n\
assert_predicate bin/\"hackertuah\", :exist?\n\
end\n\
end\n\
'''.format(v=v, s=s); \
open('$(TAP_DIR)/Formula/hackertuah.rb', 'w').write(content)"
cd $(TAP_DIR) && git add Formula/hackertuah.rb && \
git commit -m "Update hackertuah to v$(VERSION)" && \
git push origin main
rm -rf $(TAP_DIR)
@echo "Done. Install with: brew tap program247365/tap && brew install hackertuah"