-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease
More file actions
executable file
·95 lines (76 loc) · 2.91 KB
/
Copy pathrelease
File metadata and controls
executable file
·95 lines (76 loc) · 2.91 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
#!/bin/bash
# Release script for g-sui
# Version format: v1.X.X (e.g., v1.1.0, v1.1.1, v1.1.2)
# Each release increments the patch version by 1
set -e # Exit on error
# Module path from go.mod
MODULE_PATH="github.com/michalCapo/g-sui"
# Get the latest tag matching v1.* pattern (new versioning)
LATEST_TAG=$(git tag -l "v1.*" | sort -V | tail -1)
if [ -z "$LATEST_TAG" ]; then
# No v1.* tags exist, start at v1.1.0
NEW_VERSION="v1.1.0"
echo "No v1.* tags found. Starting at version $NEW_VERSION"
else
echo "Latest version: $LATEST_TAG"
# Parse version: vMAJOR.MINOR.PATCH
MINOR=$(echo "$LATEST_TAG" | cut -d. -f2)
PATCH=$(echo "$LATEST_TAG" | cut -d. -f3)
# Increment patch version
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="v1.$MINOR.$NEW_PATCH"
echo "New version: $NEW_VERSION"
fi
# Check if working tree is clean
if ! git diff-index --quiet HEAD --; then
echo "Error: Working tree has uncommitted changes. Please commit or stash them first."
exit 1
fi
# Ensure go.mod is tidy
echo "Ensuring go.mod is tidy..."
go mod tidy
# Check if go.mod has uncommitted changes after tidy
if ! git diff-index --quiet HEAD -- go.mod go.sum; then
echo "Warning: go.mod or go.sum has changes after 'go mod tidy'"
echo "Please commit these changes before releasing:"
git diff --stat go.mod go.sum
exit 1
fi
# Verify module path matches go.mod
MODULE_IN_GOMOD=$(grep "^module " go.mod | awk '{print $2}')
if [ "$MODULE_IN_GOMOD" != "$MODULE_PATH" ]; then
echo "Error: Module path in go.mod ($MODULE_IN_GOMOD) doesn't match expected ($MODULE_PATH)"
exit 1
fi
# Check if we're on the correct branch (optional check)
CURRENT_BRANCH=$(git branch --show-current)
echo "Current branch: $CURRENT_BRANCH"
# Ensure we have the latest from origin
echo "Fetching latest from origin..."
git fetch origin --tags
# Create annotated tag
echo "Creating tag $NEW_VERSION..."
git tag -a "$NEW_VERSION" -m "Release version $NEW_VERSION"
# Push tag to origin
echo "Pushing tag $NEW_VERSION to origin..."
git push origin "$NEW_VERSION"
# Also ensure the current branch is pushed
echo "Ensuring current branch is pushed..."
git push origin "$CURRENT_BRANCH" --follow-tags || true
# Register version with Go module proxy so @latest resolves
echo "Registering version with Go module proxy..."
GOPROXY=proxy.golang.org go list -m "$MODULE_PATH@$NEW_VERSION" || echo "Warning: Failed to register with proxy (may take a few minutes to propagate)"
echo ""
echo "Successfully released version $NEW_VERSION"
echo " Tag created and pushed to origin"
echo ""
echo "Module can now be used as a dependency:"
echo " go get $MODULE_PATH@$NEW_VERSION"
echo ""
echo "Or in go.mod:"
echo " $MODULE_PATH $NEW_VERSION"
echo ""
echo "Next steps:"
echo " - Verify the module can be fetched: go list -m -versions $MODULE_PATH"
echo " - Create a GitHub release: https://github.com/michalCapo/g-sui/releases/new"
echo " - Select tag: $NEW_VERSION"