Skip to content

Commit d7cfb1e

Browse files
committed
Add Makefile with AUR automation scripts
1 parent 0dad556 commit d7cfb1e

1 file changed

Lines changed: 89 additions & 21 deletions

File tree

Makefile

Lines changed: 89 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,96 @@
1-
.PHONY: install build fmt
1+
.PHONY: build install clean aur-update aur-push
22

3-
VERSION := $(shell git describe --tags --abbrev=0 2>/dev/null || echo "dev")
3+
# Build the binary
4+
build:
5+
go build -o gophertube main.go
46

5-
# Install GopherTube (build, install binary, install man page, create config)
6-
install:
7-
go mod tidy
8-
go build -ldflags "-X main.version=$(VERSION)" -o gophertube main.go
7+
# Install to system
8+
install: build
99
sudo cp gophertube /usr/local/bin/
10-
sudo mkdir -p /usr/local/share/man/man1
11-
sudo cp man/gophertube.1 /usr/local/share/man/man1/
12-
sudo mandb
13-
mkdir -p ~/.config/gophertube
14-
cp config/gophertube.toml ~/.config/gophertube/gophertube.toml
15-
@echo "GopherTube installed successfully!"
16-
@echo "Configuration file created at ~/.config/gophertube/gophertube.toml"
17-
@echo "Run 'gophertube --help' to get started."
10+
sudo chmod +x /usr/local/bin/gophertube
1811

19-
build:
20-
go build -ldflags "-X main.version=$(VERSION)" -o gophertube main.go
12+
# Clean build artifacts
13+
clean:
14+
rm -f gophertube
15+
rm -rf aur-gophertube
16+
17+
# Update AUR package with current version
18+
aur-update:
19+
@echo "Updating AUR package..."
20+
@VERSION=$$(git describe --tags --abbrev=0 2>/dev/null | sed 's/v//'); \
21+
if [ -z "$$VERSION" ]; then \
22+
echo "No version tag found. Please create a tag first."; \
23+
exit 1; \
24+
fi; \
25+
echo "Current version: $$VERSION"; \
26+
\
27+
# Download source and calculate checksum
28+
wget -O gophertube-$$VERSION.tar.gz https://github.com/KrishnaSSH/GopherTube/archive/refs/tags/v$$VERSION.tar.gz; \
29+
CHECKSUM=$$(sha256sum gophertube-$$VERSION.tar.gz | cut -d' ' -f1); \
30+
echo "Checksum: $$CHECKSUM"; \
31+
\
32+
# Clone AUR repository
33+
git clone ssh://aur@aur.archlinux.org/gophertube.git aur-gophertube; \
34+
cd aur-gophertube; \
35+
\
36+
# Update PKGBUILD
37+
sed -i "s/pkgver=.*/pkgver=$$VERSION/" PKGBUILD; \
38+
sed -i "s/sha256sums=('.*')/sha256sums=('$$CHECKSUM')/" PKGBUILD; \
39+
\
40+
# Generate .SRCINFO
41+
makepkg --printsrcinfo > .SRCINFO; \
42+
\
43+
# Commit and push
44+
git config --local user.email "krishna.pytech@gmail.com"; \
45+
git config --local user.name "KrishnaSSH"; \
46+
git add PKGBUILD .SRCINFO; \
47+
git commit -m "Update to v$$VERSION"; \
48+
git push origin master; \
49+
\
50+
# Cleanup
51+
cd ..; \
52+
rm -rf aur-gophertube gophertube-$$VERSION.tar.gz; \
53+
echo "AUR package updated to v$$VERSION"
54+
55+
# Push new tag and update AUR
56+
aur-push:
57+
@echo "Creating and pushing new tag..."
58+
@VERSION=$$(git describe --tags --abbrev=0 2>/dev/null | sed 's/v//'); \
59+
if [ -z "$$VERSION" ]; then \
60+
echo "No version tag found. Please create a tag first."; \
61+
exit 1; \
62+
fi; \
63+
echo "Current version: $$VERSION"; \
64+
\
65+
# Push tag if not already pushed
66+
git push origin v$$VERSION 2>/dev/null || echo "Tag already pushed"; \
67+
\
68+
# Update AUR
69+
$(MAKE) aur-update
70+
71+
# Show current version
72+
version:
73+
@git describe --tags --abbrev=0 2>/dev/null || echo "No version tag found"
2174

22-
fmt:
23-
go fmt ./...
24-
go mod tidy
75+
# Create new version tag
76+
tag:
77+
@echo "Usage: make tag VERSION=2.2.1"
78+
@if [ -z "$(VERSION)" ]; then \
79+
echo "Please specify VERSION=2.2.1"; \
80+
exit 1; \
81+
fi; \
82+
git tag v$(VERSION); \
83+
git push origin v$(VERSION); \
84+
echo "Created and pushed tag v$(VERSION)"
2585

26-
run:
27-
go run .
86+
# Full release process
87+
release:
88+
@echo "Usage: make release VERSION=2.2.1"
89+
@if [ -z "$(VERSION)" ]; then \
90+
echo "Please specify VERSION=2.2.1"; \
91+
exit 1; \
92+
fi; \
93+
$(MAKE) tag VERSION=$(VERSION); \
94+
$(MAKE) aur-update; \
95+
echo "Release v$(VERSION) complete!"
2896

0 commit comments

Comments
 (0)