Skip to content

Commit 8d8f12c

Browse files
committed
Improve release management script
* Also fix the PyPi badge
1 parent c982131 commit 8d8f12c

File tree

2 files changed

+56
-5
lines changed

2 files changed

+56
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
[![CI/CD](https://github.com/hyperb1iss/signalrgb-python/actions/workflows/ci-cd.yml/badge.svg)](https://github.com/hyperb1iss/signalrgb-python/actions)
66
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
7-
[![PyPI version](https://badge.fury.io/py/signalrgb.svg)](https://badge.fury.io/py/signalrgb)
7+
[![PyPI version](https://img.shields.io/pypi/v/signalrgb)](https://pypi.org/project/signalrgb)
88

99
*A powerful Python client library and CLI for controlling [SignalRGB Pro](https://signalrgb.com)*
1010

scripts/release.sh

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,39 @@
11
#!/bin/bash
2-
set -e
2+
set -eo pipefail
3+
4+
# Colors for output
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m' # No Color
9+
10+
# Function to print colored output
11+
print_color() {
12+
printf "${!1}%s${NC}\n" "$2"
13+
}
14+
15+
# Function to check if command exists
16+
command_exists() {
17+
command -v "$1" >/dev/null 2>&1
18+
}
19+
20+
# Check required tools
21+
for cmd in git poetry sed; do
22+
if ! command_exists "$cmd"; then
23+
print_color "RED" "Error: $cmd is not installed. Please install it and try again."
24+
exit 1
25+
fi
26+
done
327

428
# Ensure we're on the main branch
529
if [ "$(git rev-parse --abbrev-ref HEAD)" != "main" ]; then
6-
echo "You must be on the main branch to release."
30+
print_color "RED" "Error: You must be on the main branch to release."
31+
exit 1
32+
fi
33+
34+
# Check for uncommitted changes
35+
if ! git diff-index --quiet HEAD --; then
36+
print_color "RED" "Error: You have uncommitted changes. Please commit or stash them before releasing."
737
exit 1
838
fi
939

@@ -13,11 +43,32 @@ current_version=$(poetry version -s)
1343
# Ask for the new version
1444
read -p "Current version is $current_version. What should the new version be? " new_version
1545

46+
# Validate new version format (simple check)
47+
if ! [[ $new_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
48+
print_color "RED" "Error: Invalid version format. Please use semantic versioning (e.g., 1.2.3)."
49+
exit 1
50+
fi
51+
1652
# Update the version in pyproject.toml
1753
poetry version $new_version
1854

1955
# Update documentation version
20-
sed -i "s/version: $current_version/version: $new_version/" docs/index.md
56+
if [ -f docs/index.md ]; then
57+
sed -i "s/version: $current_version/version: $new_version/" docs/index.md
58+
else
59+
print_color "YELLOW" "Warning: docs/index.md not found. Skipping documentation version update."
60+
fi
61+
62+
# Show changes and ask for confirmation
63+
print_color "YELLOW" "The following files will be modified:"
64+
git status --porcelain
65+
66+
read -p "Do you want to proceed with these changes? (y/n) " -n 1 -r
67+
echo
68+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
69+
print_color "RED" "Release cancelled."
70+
exit 1
71+
fi
2172

2273
# Commit the changes
2374
git add pyproject.toml docs/index.md
@@ -27,4 +78,4 @@ git commit -m ":bookmark: Release: $new_version"
2778
git tag -a v$new_version -m "Release: $new_version"
2879
git push origin main --tags
2980

30-
echo "Release $new_version has been created and pushed. CI will handle the rest, including documentation deployment."
81+
print_color "GREEN" "Release $new_version has been created and pushed."

0 commit comments

Comments
 (0)