Skip to content

Commit d8fc614

Browse files
author
James Boulton
committed
add release script
1 parent f113521 commit d8fc614

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

scripts/release.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/bin/bash
2+
set -e
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+
# Check if version argument provided
11+
if [ -z "$1" ]; then
12+
echo -e "${RED}Error: Version number required${NC}"
13+
echo "Usage: ./release.sh 3.5.8"
14+
exit 1
15+
fi
16+
17+
VERSION=$1
18+
echo -e "${YELLOW}Preparing release for version ${VERSION}${NC}"
19+
20+
# Check for uncommitted changes
21+
if [[ -n $(git status -s) ]]; then
22+
echo -e "${RED}Error: You have uncommitted changes${NC}"
23+
git status -s
24+
exit 1
25+
fi
26+
27+
# Check we're on main branch
28+
BRANCH=$(git branch --show-current)
29+
if [ "$BRANCH" != "main" ] && [ "$BRANCH" != "master" ]; then
30+
echo -e "${RED}Error: Not on main/master branch (currently on ${BRANCH})${NC}"
31+
exit 1
32+
fi
33+
34+
# Pull latest changes
35+
echo -e "${YELLOW}Pulling latest changes...${NC}"
36+
git pull
37+
38+
# Run tests
39+
echo -e "${YELLOW}Running tests...${NC}"
40+
uvx tox
41+
if [ $? -ne 0 ]; then
42+
echo -e "${RED}Tests failed! Aborting release.${NC}"
43+
exit 1
44+
fi
45+
echo -e "${GREEN}✓ All tests passed${NC}"
46+
47+
# Update version in pyproject.toml
48+
echo -e "${YELLOW}Updating version in pyproject.toml...${NC}"
49+
if [[ "$OSTYPE" == "darwin"* ]]; then
50+
# macOS
51+
sed -i '' "s/version = \"[^\"]*\"/version = \"${VERSION}\"/" pyproject.toml
52+
else
53+
# Linux
54+
sed -i "s/version = \"[^\"]*\"/version = \"${VERSION}\"/" pyproject.toml
55+
fi
56+
57+
# Show the diff
58+
git diff pyproject.toml
59+
60+
# Confirm
61+
echo -e "${YELLOW}Ready to release version ${VERSION}. Continue? (y/n)${NC}"
62+
read -r response
63+
if [[ ! "$response" =~ ^[Yy]$ ]]; then
64+
echo -e "${RED}Release aborted${NC}"
65+
git checkout pyproject.toml
66+
exit 1
67+
fi
68+
69+
# Commit and tag
70+
echo -e "${YELLOW}Creating commit and tag...${NC}"
71+
git add pyproject.toml
72+
git commit -m "Bump version to ${VERSION}"
73+
git tag "v${VERSION}"
74+
75+
# Push
76+
echo -e "${YELLOW}Pushing to origin...${NC}"
77+
git push origin main
78+
git push origin "v${VERSION}"
79+
80+
echo -e "${GREEN}✓ Release ${VERSION} complete!${NC}"
81+
echo -e "${GREEN}Check GitHub Actions for build and publish status:${NC}"
82+
echo -e "https://github.com/dashio-connect/python-dashio/actions"

0 commit comments

Comments
 (0)