-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·117 lines (100 loc) · 3.28 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·117 lines (100 loc) · 3.28 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
#!/bin/bash
set -euo pipefail
# LiveTemplate Docs Release Script
# Usage: ./release.sh <version>
# Example: ./release.sh 0.1.0
#
# Creates a new release by tagging the repository. Unlike tinkerdown
# (which has cli-release.yml building binaries on tag push), docs has
# no tag-triggered workflow — deploy.yml fires on every push to main,
# independent of tags. A docs tag is purely a milestone marker + the
# pre-condition for `gh release create` so the history is browseable.
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
usage() {
echo "Usage: $0 <version>"
echo ""
echo "Creates a new docs release by tagging the repository."
echo "After tagging, run:"
echo " gh release create v<version> --generate-notes --title \"<title>\""
echo ""
echo "Examples:"
echo " $0 0.1.0 # Creates tag v0.1.0"
echo " $0 0.1.1 # Creates tag v0.1.1"
exit 1
}
if [ $# -ne 1 ]; then
usage
fi
VERSION="$1"
# Validate version format (semver without v prefix)
if ! [[ "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo -e "${RED}Error: Invalid version format. Expected: X.Y.Z or X.Y.Z-suffix${NC}"
echo "Examples: 0.1.0, 0.1.1, 1.0.0-rc.1"
exit 1
fi
TAG="v${VERSION}"
# Check for uncommitted changes
if ! git diff-index --quiet HEAD --; then
echo -e "${RED}Error: You have uncommitted changes. Please commit or stash them first.${NC}"
git status --short
exit 1
fi
# Check if we're on main branch
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$CURRENT_BRANCH" != "main" ]; then
echo -e "${YELLOW}Warning: You are on branch '$CURRENT_BRANCH', not 'main'.${NC}"
read -p "Continue anyway? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Check if tag already exists
if git rev-parse "$TAG" >/dev/null 2>&1; then
echo -e "${RED}Error: Tag $TAG already exists.${NC}"
exit 1
fi
# Fetch latest from remote
echo -e "${YELLOW}Fetching latest from origin...${NC}"
git fetch origin
# Check if local is up to date with remote
LOCAL=$(git rev-parse HEAD)
REMOTE=$(git rev-parse origin/main 2>/dev/null || echo "")
if [ -n "$REMOTE" ] && [ "$LOCAL" != "$REMOTE" ]; then
echo -e "${YELLOW}Warning: Local branch differs from origin/main.${NC}"
read -p "Continue anyway? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
exit 1
fi
fi
# Show what we're about to do
echo ""
echo -e "${GREEN}Release Summary:${NC}"
echo " Version: $VERSION"
echo " Tag: $TAG"
echo " Commit: $(git rev-parse --short HEAD)"
echo " Message: $(git log -1 --pretty=%s)"
echo ""
read -p "Create and push tag $TAG? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted."
exit 1
fi
# Create and push tag
echo -e "${YELLOW}Creating tag $TAG...${NC}"
git tag -a "$TAG" -m "Release $VERSION"
echo -e "${YELLOW}Pushing tag to origin...${NC}"
git push origin "$TAG"
echo ""
echo -e "${GREEN}Success! Tag $TAG has been pushed.${NC}"
echo ""
echo "Next step — create the GitHub release with auto-generated notes:"
echo " gh release create $TAG --generate-notes --title \"<title>\""
echo ""
echo "Production deploy already fired on the main-branch merge that this tag points at;"
echo "this tag is the browseable milestone marker, not a deploy trigger."