Some checks failed
Lint Code / lint (push) Failing after 2m2s
CI/CD Pipeline / lint (push) Successful in 0s
Run Tests / test (3.12) (push) Successful in 54s
CI/CD Pipeline / build-and-release (push) Has been cancelled
CI/CD Pipeline / test (push) Has been cancelled
CI/CD Pipeline / notify (push) Has been cancelled
Run Tests / test (3.13) (push) Has been cancelled
- Create a GitHub Actions workflow for testing with Python 3.12 and 3.13. - Update Makefile to include release management commands and pipeline checks. - Document the CI/CD pipeline structure and usage in PIPELINE.md. - Add structlog for structured logging and enhance logging utilities. - Implement release management script for automated versioning and tagging. - Modify logging configuration to support structured logging and improved formatting. - Update dependencies in pyproject.toml and poetry.lock to include structlog. - Enhance access logging in server and middleware to include structured data.
107 lines
2.9 KiB
Bash
Executable File
107 lines
2.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# Release management script for PyServeX
|
|
# Usage: ./scripts/release.sh [patch|minor|major]
|
|
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
PROJECT_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m'
|
|
|
|
print_color() {
|
|
local color=$1
|
|
local message=$2
|
|
echo -e "${color}${message}${NC}"
|
|
}
|
|
|
|
if ! git rev-parse --git-dir > /dev/null 2>&1; then
|
|
print_color $RED "Error: Not in a git repository"
|
|
exit 1
|
|
fi
|
|
|
|
if [[ -n $(git status --porcelain) ]]; then
|
|
print_color $RED "Error: Working directory has uncommitted changes"
|
|
print_color $YELLOW "Commit all changes before creating a release"
|
|
git status --short
|
|
exit 1
|
|
fi
|
|
|
|
VERSION_TYPE=${1:-patch}
|
|
if [[ ! "$VERSION_TYPE" =~ ^(patch|minor|major)$ ]]; then
|
|
print_color $RED "Error: Invalid version type. Use: patch, minor or major"
|
|
exit 1
|
|
fi
|
|
|
|
print_color $BLUE "Starting release process..."
|
|
|
|
cd "$PROJECT_DIR"
|
|
|
|
CURRENT_VERSION=$(poetry version -s)
|
|
print_color $YELLOW "Current version: $CURRENT_VERSION"
|
|
|
|
print_color $BLUE "Updating version ($VERSION_TYPE)..."
|
|
poetry version $VERSION_TYPE
|
|
|
|
NEW_VERSION=$(poetry version -s)
|
|
print_color $GREEN "New version: $NEW_VERSION"
|
|
|
|
print_color $BLUE "Running tests..."
|
|
if ! poetry run pytest tests/ -v; then
|
|
print_color $RED "Tests failed. Rolling back changes..."
|
|
git checkout pyproject.toml
|
|
exit 1
|
|
fi
|
|
|
|
print_color $BLUE "Running linter checks..."
|
|
if ! make lint; then
|
|
print_color $RED "Linter found issues. Rolling back changes..."
|
|
git checkout pyproject.toml
|
|
exit 1
|
|
fi
|
|
|
|
print_color $BLUE "Building package..."
|
|
if ! poetry build; then
|
|
print_color $RED "Build failed. Rolling back changes..."
|
|
git checkout pyproject.toml
|
|
exit 1
|
|
fi
|
|
|
|
print_color $BLUE "Committing version change..."
|
|
git add pyproject.toml
|
|
git commit -m "bump version to $NEW_VERSION"
|
|
|
|
print_color $BLUE "Creating tag v$NEW_VERSION..."
|
|
git tag "v$NEW_VERSION"
|
|
|
|
print_color $YELLOW "Ready to push to server:"
|
|
print_color $YELLOW " - Commit with new version: $NEW_VERSION"
|
|
print_color $YELLOW " - Tag: v$NEW_VERSION"
|
|
echo
|
|
read -p "Push changes to server? (y/N): " -n 1 -r
|
|
echo
|
|
|
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
|
print_color $BLUE "Pushing commit and tag to server..."
|
|
git push origin main
|
|
git push origin "v$NEW_VERSION"
|
|
|
|
print_color $GREEN "Release created successfully!"
|
|
print_color $GREEN "Version: $NEW_VERSION"
|
|
print_color $GREEN "Tag: v$NEW_VERSION pushed"
|
|
print_color $YELLOW "Pipeline will automatically create draft release in Gitea"
|
|
print_color $YELLOW "Don't forget to edit release description in Gitea interface"
|
|
else
|
|
print_color $YELLOW "Changes not pushed to server"
|
|
print_color $YELLOW "To push later, run:"
|
|
print_color $BLUE " git push origin main"
|
|
print_color $BLUE " git push origin v$NEW_VERSION"
|
|
fi
|
|
|
|
print_color $GREEN "Script completed!"
|