|
| 1 | +#!/bin/bash |
| 2 | +set -euo pipefail |
| 3 | + |
| 4 | +# Release script for spotify-mcp |
| 5 | +# Usage: ./release.sh [--dry-run] |
| 6 | + |
| 7 | +DRY_RUN=false |
| 8 | +if [[ "${1:-}" == "--dry-run" ]]; then |
| 9 | + DRY_RUN=true |
| 10 | + echo "=== DRY RUN MODE ===" |
| 11 | +fi |
| 12 | + |
| 13 | +# Get version from pyproject.toml |
| 14 | +VERSION=$(grep -E "^version = " pyproject.toml | sed 's/version = "\(.*\)"/\1/') |
| 15 | +TAG="v$VERSION" |
| 16 | + |
| 17 | +echo "Releasing spotify-mcp $TAG" |
| 18 | +echo "" |
| 19 | + |
| 20 | +# Check for uncommitted changes |
| 21 | +if [[ -n "$(git status --porcelain)" ]]; then |
| 22 | + echo "ERROR: Uncommitted changes detected. Commit or stash them first." |
| 23 | + exit 1 |
| 24 | +fi |
| 25 | + |
| 26 | +# Check if tag exists locally |
| 27 | +if ! git rev-parse "$TAG" >/dev/null 2>&1; then |
| 28 | + echo "ERROR: Tag $TAG doesn't exist locally." |
| 29 | + echo "Create it with: git tag -a $TAG -m 'Release notes here'" |
| 30 | + exit 1 |
| 31 | +fi |
| 32 | + |
| 33 | +# Check if release already exists on GitHub |
| 34 | +if gh release view "$TAG" >/dev/null 2>&1; then |
| 35 | + echo "ERROR: Release $TAG already exists on GitHub." |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | + |
| 39 | +# Run quality checks |
| 40 | +echo "Running quality checks..." |
| 41 | +uv run mypy src/ |
| 42 | +uv run pytest |
| 43 | +echo "Quality checks passed!" |
| 44 | +echo "" |
| 45 | + |
| 46 | +# Build the package |
| 47 | +echo "Building package..." |
| 48 | +rm -rf dist/ |
| 49 | +uv build |
| 50 | +echo "Build complete!" |
| 51 | +echo "" |
| 52 | + |
| 53 | +# Get tag annotation for release notes |
| 54 | +RELEASE_NOTES=$(git tag -l --format='%(contents)' "$TAG") |
| 55 | + |
| 56 | +if [[ -z "$RELEASE_NOTES" ]]; then |
| 57 | + echo "ERROR: Tag $TAG has no annotation. Use annotated tags:" |
| 58 | + echo " git tag -a $TAG -m 'Release notes here'" |
| 59 | + exit 1 |
| 60 | +fi |
| 61 | + |
| 62 | +echo "Release notes:" |
| 63 | +echo "---" |
| 64 | +echo "$RELEASE_NOTES" |
| 65 | +echo "---" |
| 66 | +echo "" |
| 67 | + |
| 68 | +if $DRY_RUN; then |
| 69 | + echo "[DRY RUN] Would push commits and tags" |
| 70 | + echo "[DRY RUN] Would create GitHub release $TAG" |
| 71 | + echo "[DRY RUN] Would upload: $(ls dist/)" |
| 72 | + exit 0 |
| 73 | +fi |
| 74 | + |
| 75 | +# Push commits and tags |
| 76 | +echo "Pushing to GitHub..." |
| 77 | +git push |
| 78 | +git push --tags |
| 79 | + |
| 80 | +# Create GitHub release with assets |
| 81 | +echo "Creating GitHub release..." |
| 82 | +gh release create "$TAG" \ |
| 83 | + --title "$TAG" \ |
| 84 | + --notes "$RELEASE_NOTES" \ |
| 85 | + dist/* |
| 86 | + |
| 87 | +echo "" |
| 88 | +echo "Released $TAG!" |
| 89 | +echo "https://github.com/$(gh repo view --json nameWithOwner -q .nameWithOwner)/releases/tag/$TAG" |
0 commit comments