-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJustfile
More file actions
102 lines (88 loc) · 2.95 KB
/
Justfile
File metadata and controls
102 lines (88 loc) · 2.95 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
@_:
just --list
# Run all tests
test:
go test ./...
# Run golangci-lint with --fix
fix:
golangci-lint run --fix
# Run golangci-lint without --fix
lint:
golangci-lint run
# Build the binary
build:
go build -o zgod .
# Install the binary
install:
go install .
# Remove build artifacts
clean:
rm -rf zgod zgod.exe dist/
# Build with version info (local dev)
build-dev:
go build -ldflags "-X github.com/zigai/zgod/internal/cli.version=dev -X github.com/zigai/zgod/internal/cli.commit=$(git rev-parse --short HEAD) -X github.com/zigai/zgod/internal/cli.date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" -o zgod .
# Test goreleaser locally
release-dry-run:
goreleaser release --snapshot --clean
# Pre-release safety checks
_release-check:
#!/usr/bin/env sh
set -e
if [ -n "$(git status --porcelain)" ]; then
echo "Error: uncommitted changes. Commit or stash first." >&2
exit 1
fi
branch=$(git branch --show-current)
if [ "$branch" != "master" ]; then
echo "Error: not on master branch (on $branch)" >&2
exit 1
fi
git fetch origin master --tags
local_head=$(git rev-parse HEAD)
remote_head=$(git rev-parse origin/master)
if [ "$local_head" != "$remote_head" ]; then
echo "Error: local master differs from origin/master. Pull or push first." >&2
exit 1
fi
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -n "$latest_tag" ]; then
tag_commit=$(git rev-parse "$latest_tag"^{})
if [ "$local_head" = "$tag_commit" ]; then
echo "Error: HEAD is already tagged as $latest_tag. Make new commits first." >&2
exit 1
fi
fi
# Release a new patch version (eg. v1.0.0 -> v1.0.1)
release-patch: _release-check
#!/usr/bin/env sh
set -e
latest=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
major=$(echo "$latest" | sed 's/v//' | cut -d. -f1)
minor=$(echo "$latest" | sed 's/v//' | cut -d. -f2)
patch=$(echo "$latest" | sed 's/v//' | cut -d. -f3)
new="v${major}.${minor}.$((patch + 1))"
echo "Releasing $new (was $latest)"
git tag "$new"
git push origin "$new"
# Release a new minor version (eg. v1.0.0 -> v1.1.0)
release-minor: _release-check
#!/usr/bin/env sh
set -e
latest=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
major=$(echo "$latest" | sed 's/v//' | cut -d. -f1)
minor=$(echo "$latest" | sed 's/v//' | cut -d. -f2)
new="v${major}.$((minor + 1)).0"
echo "Releasing $new (was $latest)"
git tag "$new"
git push origin "$new"
# Release a new major version (eg. v1.0.0 -> v2.0.0)
release-major: _release-check
#!/usr/bin/env sh
set -e
latest=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
major=$(echo "$latest" | sed 's/v//' | cut -d. -f1)
new="v$((major + 1)).0.0"
echo "Releasing $new (was $latest)"
git tag "$new"
git push origin "$new"
alias release := release-patch