-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrelease.sh
More file actions
executable file
·115 lines (93 loc) · 2.95 KB
/
Copy pathrelease.sh
File metadata and controls
executable file
·115 lines (93 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
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
set -euo pipefail
# Release script for STYLiTE Orbit Mattermost to Telegrambot.
# Usage: ./release.sh [major|minor|patch]
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
BUMP_TYPE="${1:-patch}"
if [[ ! "$BUMP_TYPE" =~ ^(major|minor|patch)$ ]]; then
echo "Error: Invalid bump type '$BUMP_TYPE'. Must be major, minor, or patch."
exit 1
fi
if ! git diff-index --quiet HEAD --; then
echo "Error: You have uncommitted changes. Please commit or stash them first."
exit 1
fi
if [[ ! -f VERSION ]]; then
echo "Error: VERSION file not found."
exit 1
fi
CURRENT_VERSION=$(cat VERSION | tr -d '\n\r ')
if [[ ! "$CURRENT_VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Error: Invalid version format in VERSION file: '$CURRENT_VERSION'"
exit 1
fi
IFS='.' read -r -a VERSION_PARTS <<< "$CURRENT_VERSION"
MAJOR="${VERSION_PARTS[0]}"
MINOR="${VERSION_PARTS[1]}"
PATCH="${VERSION_PARTS[2]}"
case "$BUMP_TYPE" in
major) MAJOR=$((MAJOR + 1)); MINOR=0; PATCH=0 ;;
minor) MINOR=$((MINOR + 1)); PATCH=0 ;;
patch) PATCH=$((PATCH + 1)) ;;
esac
NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}"
TAG_NAME="${NEW_VERSION}"
echo "Current version: $CURRENT_VERSION"
echo "New version: $NEW_VERSION"
echo "Bump type: $BUMP_TYPE"
echo ""
if [[ ! -f CHANGELOG.md ]]; then
echo "Error: CHANGELOG.md not found."
exit 1
fi
TODAY=$(date +%Y-%m-%d)
if ! grep -q "^## \[Unreleased\]" CHANGELOG.md; then
echo "Warning: [Unreleased] section not found in CHANGELOG.md — adding it."
if [[ "$(uname)" == "Darwin" ]]; then
sed -i '' '7a\
\
## [Unreleased]
' CHANGELOG.md
else
sed -i '7a\\n## [Unreleased]' CHANGELOG.md
fi
fi
if [[ "$(uname)" == "Darwin" ]]; then
sed -i '' "/^## \[Unreleased\]/a\\
\\
## [$NEW_VERSION] - $TODAY
" CHANGELOG.md
else
sed -i "/^## \[Unreleased\]/a\\\n## [$NEW_VERSION] - $TODAY" CHANGELOG.md
fi
echo -n "$NEW_VERSION" > VERSION
echo "✓ Updated VERSION and CHANGELOG.md"
echo ""
echo "Version and CHANGELOG.md changes:"
git --no-pager diff VERSION CHANGELOG.md
echo ""
read -p "Proceed with commit, tag, and push? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted. Changes have been made to VERSION and CHANGELOG.md — review and commit manually if desired."
exit 0
fi
git add VERSION CHANGELOG.md
git commit -m "chore: bump version to $NEW_VERSION"
git tag -a "$TAG_NAME" -m "Release $NEW_VERSION"
echo "✓ Committed"
echo "✓ Tagged $TAG_NAME"
echo ""
echo "Pushing to origin..."
git push origin HEAD
git push origin "$TAG_NAME"
echo "✓ Pushed branch and tag"
echo ""
echo "Docker images that will be built on the tag push:"
echo " - docker.io/styliteag/mattermost2telegrambot:$NEW_VERSION"
echo " - docker.io/styliteag/mattermost2telegrambot:latest"
echo " - ghcr.io/styliteag/mattermost2telegrambot:$NEW_VERSION"
echo " - ghcr.io/styliteag/mattermost2telegrambot:latest"
echo ""
echo "Release $NEW_VERSION triggered successfully."