-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
160 lines (136 loc) · 4.35 KB
/
Copy pathjustfile
File metadata and controls
160 lines (136 loc) · 4.35 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
set dotenv-load
version := `git describe --tags --always --dirty 2>/dev/null || echo dev`
module := "skate"
ldflags := "-s -w -X " + module + "/internal/version.Version=" + version
dist := "dist"
# Default recipe
default:
@just --list
# Build for current platform
build:
go build -trimpath -ldflags '{{ ldflags }}' -o skate ./cmd/skate
# Run tests
test:
go test ./...
# Install to ~/.local/bin
install: build
mkdir -p ~/.local/bin/
install -m 0755 skate ~/.local/bin/
# Cross-build for all platforms
cross-build: clean
#!/usr/bin/env bash
set -euo pipefail
mkdir -p {{ dist }}
platforms=(
"linux/amd64"
"linux/arm64"
"darwin/arm64"
"windows/amd64"
)
for platform in "${platforms[@]}"; do
IFS='/' read -r goos goarch <<< "$platform"
output="{{ dist }}/skate-${goos}-${goarch}"
if [ "$goos" = "windows" ]; then
output="${output}.exe"
fi
echo "Building ${goos}/${goarch}..."
GOOS=$goos GOARCH=$goarch go build -trimpath -ldflags '{{ ldflags }}' -o "$output" ./cmd/skate
done
echo "Done. Binaries in {{ dist }}/"
ls -lh {{ dist }}/
# Create checksums for dist binaries
checksums:
#!/usr/bin/env bash
set -euo pipefail
cd {{ dist }}
sha256sum skate-* > checksums.txt
cat checksums.txt
# Compress a single binary with upx
upx what compression="4":
upx -{{ compression }} {{ what }}
# Compress linux binaries in dist with upx
compress-linux compression="4":
#!/usr/bin/env bash
set -euo pipefail
for bin in {{ dist }}/skate-linux-*; do
[ -f "$bin" ] || continue
echo "Compressing ${bin}..."
upx -{{ compression }} "$bin"
done
echo "Done."
ls -lh {{ dist }}/skate-linux-*
# Create draft GitHub release for current tag
release: cross-build compress-linux checksums
#!/usr/bin/env bash
set -euo pipefail
tag="{{ version }}"
if [ "$tag" = "dev" ] || echo "$tag" | grep -q dirty; then
echo "Error: cannot release from dev or dirty state. Tag a version first."
exit 1
fi
# Parse GH_TOKEN from ~/.netrc if not set
if [ -z "${GH_TOKEN:-}" ]; then
if [ -f ~/.netrc ]; then
GH_TOKEN=$(grep 'machine github.com' ~/.netrc | head -1 | sed 's/.*password //')
export GH_TOKEN
fi
fi
if [ -z "${GH_TOKEN:-}" ]; then
echo "Error: GH_TOKEN not set and not found in ~/.netrc"
exit 1
fi
# Check if release already exists
if gh release view "$tag" &>/dev/null; then
echo "Release ${tag} already exists."
read -p "Delete existing release and create a new one? [y/N] " confirm
if [ "${confirm,,}" != "y" ]; then
echo "Aborted."
exit 0
fi
echo "Deleting existing release ${tag}..."
gh release delete "$tag" --yes
fi
echo "Creating draft release for ${tag}..."
gh release create "$tag" \
--draft \
--title "Skate ${tag}" \
--generate-notes \
{{ dist }}/skate-* \
{{ dist }}/checksums.txt
url=$(gh release view "$tag" --json url -q .url)
echo "Draft release created: ${url}"
# Clean build artifacts
clean:
rm -rf skate {{ dist }}
# Generate Homebrew formula from dist binaries
brew-formula: checksums
#!/usr/bin/env bash
set -euo pipefail
tag="{{ version }}"
if [ "$tag" = "dev" ] || echo "$tag" | grep -q dirty; then
echo "Error: cannot generate formula from dev or dirty state."
exit 1
fi
template="Formula/skate.rb"
if [ ! -f "$template" ]; then
echo "Error: template not found at $template"
exit 1
fi
get_sha() {
grep "$1" {{ dist }}/checksums.txt | awk '{print $1}'
}
sha_darwin_arm64=$(get_sha "skate-darwin-arm64")
sha_linux_amd64=$(get_sha "skate-linux-amd64")
sha_linux_arm64=$(get_sha "skate-linux-arm64")
sed -e "s/VERSION/${tag}/g" \
-e "s/SHA256_DARWIN_ARM64/${sha_darwin_arm64}/g" \
-e "s/SHA256_LINUX_AMD64/${sha_linux_amd64}/g" \
-e "s/SHA256_LINUX_ARM64/${sha_linux_arm64}/g" \
"$template" > {{ dist }}/skate.rb
echo "Formula generated: {{ dist }}/skate.rb"
echo "Copy to your homebrew-tap repo: cp {{ dist }}/skate.rb /path/to/homebrew-tap/Formula/"
# Lint
lint:
golangci-lint run ./...
commit:
aicommit -d --model gpt-5-mini