| 1 | #!/usr/bin/env bash |
| 2 | # Complete release workflow for parrot |
| 3 | set -euo pipefail |
| 4 | |
| 5 | # Configuration |
| 6 | PROJECT_DIR="$(cd "$(dirname "$0")/.." && pwd)" |
| 7 | AUR_DIR="/tmp/parrot-cli" |
| 8 | OLD_VERSION="" |
| 9 | NEW_VERSION="" |
| 10 | |
| 11 | # Colors for output |
| 12 | RED='\033[0;31m' |
| 13 | GREEN='\033[0;32m' |
| 14 | YELLOW='\033[0;33m' |
| 15 | BLUE='\033[0;34m' |
| 16 | NC='\033[0m' # No Color |
| 17 | |
| 18 | log() { |
| 19 | echo -e "${BLUE}▶${NC} $1" |
| 20 | } |
| 21 | |
| 22 | success() { |
| 23 | echo -e "${GREEN}✓${NC} $1" |
| 24 | } |
| 25 | |
| 26 | warn() { |
| 27 | echo -e "${YELLOW}⚠${NC} $1" |
| 28 | } |
| 29 | |
| 30 | error() { |
| 31 | echo -e "${RED}❌${NC} $1" |
| 32 | } |
| 33 | |
| 34 | # Parse command line arguments |
| 35 | usage() { |
| 36 | echo "Usage: $0 <new-version> [old-version]" |
| 37 | echo "" |
| 38 | echo "Examples:" |
| 39 | echo " $0 1.0.5 # Auto-detect current version" |
| 40 | echo " $0 1.0.5 1.0.4 # Explicit old version" |
| 41 | echo "" |
| 42 | echo "This script will:" |
| 43 | echo " 1. Update version in Makefile and parrot.spec" |
| 44 | echo " 2. Update changelog with new entry" |
| 45 | echo " 3. Build and test the new version" |
| 46 | echo " 4. Deploy to RPM repository (~/src/repos-musicsian-com)" |
| 47 | echo " 5. Update AUR package (/tmp/parrot-cli)" |
| 48 | echo " 6. Create git tag and commit" |
| 49 | exit 1 |
| 50 | } |
| 51 | |
| 52 | if [ $# -eq 0 ]; then |
| 53 | usage |
| 54 | fi |
| 55 | |
| 56 | NEW_VERSION="$1" |
| 57 | if [ $# -gt 1 ]; then |
| 58 | OLD_VERSION="$2" |
| 59 | else |
| 60 | # Auto-detect current version from Makefile |
| 61 | OLD_VERSION=$(grep "^VERSION = " "$PROJECT_DIR/Makefile" | cut -d' ' -f3) |
| 62 | fi |
| 63 | |
| 64 | echo "🚀 Parrot Release Workflow" |
| 65 | echo "==========================" |
| 66 | echo "Old version: $OLD_VERSION" |
| 67 | echo "New version: $NEW_VERSION" |
| 68 | echo "" |
| 69 | |
| 70 | # Confirm with user |
| 71 | read -p "Continue with release? (y/N): " -n 1 -r |
| 72 | echo |
| 73 | if [[ ! $REPLY =~ ^[Yy]$ ]]; then |
| 74 | exit 1 |
| 75 | fi |
| 76 | |
| 77 | cd "$PROJECT_DIR" |
| 78 | |
| 79 | # Step 1: Update Makefile version |
| 80 | log "Updating Makefile version..." |
| 81 | sed -i "s/VERSION = $OLD_VERSION/VERSION = $NEW_VERSION/" Makefile |
| 82 | success "Updated Makefile: $OLD_VERSION → $NEW_VERSION" |
| 83 | |
| 84 | # Step 2: Update RPM spec version |
| 85 | log "Updating parrot.spec version..." |
| 86 | sed -i "s/Version: $OLD_VERSION/Version: $NEW_VERSION/" parrot.spec |
| 87 | success "Updated parrot.spec: $OLD_VERSION → $NEW_VERSION" |
| 88 | |
| 89 | # Step 3: Add changelog entry (user will need to edit) |
| 90 | log "Adding changelog entry to parrot.spec..." |
| 91 | DATE=$(date '+%a %b %d %Y') |
| 92 | |
| 93 | # Create a temporary file with the changelog entry |
| 94 | cat > /tmp/changelog_entry << EOF |
| 95 | * $DATE mfw <espadonne@outlook.com> - $NEW_VERSION-1 |
| 96 | - [ADD YOUR CHANGELOG ENTRIES HERE] |
| 97 | |
| 98 | EOF |
| 99 | |
| 100 | # Insert the changelog entry after %changelog line |
| 101 | sed -i '/^%changelog/r /tmp/changelog_entry' parrot.spec |
| 102 | rm -f /tmp/changelog_entry |
| 103 | |
| 104 | warn "Please edit parrot.spec and update the changelog entry with actual changes!" |
| 105 | |
| 106 | # Step 4: Build and test |
| 107 | log "Building new version..." |
| 108 | make clean |
| 109 | make build |
| 110 | |
| 111 | log "Running smoke tests..." |
| 112 | ./parrot --version |
| 113 | ./parrot --help >/dev/null |
| 114 | ./parrot mock "test command" "1" >/dev/null |
| 115 | |
| 116 | success "Build and tests completed" |
| 117 | |
| 118 | # Step 5: Deploy to RPM repository |
| 119 | log "Deploying to RPM repository..." |
| 120 | echo "You'll need to run 'make deploy' manually after this script completes." |
| 121 | echo "The deploy requires sudo access for the web server." |
| 122 | |
| 123 | # Step 6: Update AUR package |
| 124 | if [ -d "$AUR_DIR" ]; then |
| 125 | log "Updating AUR package..." |
| 126 | cd "$AUR_DIR" |
| 127 | |
| 128 | # Update PKGBUILD version |
| 129 | sed -i "s/pkgver=$OLD_VERSION/pkgver=$NEW_VERSION/" PKGBUILD |
| 130 | |
| 131 | # Update git tag reference |
| 132 | sed -i "s/#tag=v$OLD_VERSION/#tag=v$NEW_VERSION/" PKGBUILD |
| 133 | |
| 134 | # Reset pkgrel to 1 for new version |
| 135 | sed -i "s/pkgrel=[0-9]*/pkgrel=1/" PKGBUILD |
| 136 | |
| 137 | success "Updated AUR PKGBUILD: $OLD_VERSION → $NEW_VERSION" |
| 138 | |
| 139 | # Generate new .SRCINFO |
| 140 | log "Generating .SRCINFO..." |
| 141 | makepkg --printsrcinfo > .SRCINFO |
| 142 | |
| 143 | success "Generated new .SRCINFO" |
| 144 | |
| 145 | warn "Don't forget to:" |
| 146 | warn " 1. Review the PKGBUILD changes" |
| 147 | warn " 2. Test build with: makepkg -si" |
| 148 | warn " 3. Commit and push to AUR" |
| 149 | else |
| 150 | warn "AUR directory not found at $AUR_DIR" |
| 151 | fi |
| 152 | |
| 153 | # Step 7: Git operations |
| 154 | cd "$PROJECT_DIR" |
| 155 | log "Git operations..." |
| 156 | |
| 157 | # Check if we have uncommitted changes |
| 158 | if ! git diff --quiet || ! git diff --cached --quiet; then |
| 159 | warn "You have uncommitted changes. Commit them first:" |
| 160 | warn " git add -A" |
| 161 | warn " git commit -m \"Bump version to $NEW_VERSION\"" |
| 162 | warn " git tag v$NEW_VERSION" |
| 163 | warn " git push origin trunk v$NEW_VERSION" |
| 164 | else |
| 165 | log "Creating git commit and tag..." |
| 166 | git add -A |
| 167 | git commit -m "Bump version to $NEW_VERSION" |
| 168 | git tag "v$NEW_VERSION" |
| 169 | |
| 170 | warn "Don't forget to push:" |
| 171 | warn " git push origin trunk v$NEW_VERSION" |
| 172 | fi |
| 173 | |
| 174 | echo "" |
| 175 | echo "🎉 Release workflow completed!" |
| 176 | echo "" |
| 177 | echo "Next steps:" |
| 178 | echo "1. Edit parrot.spec changelog entry" |
| 179 | echo "2. Run 'make deploy' (requires sudo)" |
| 180 | echo "3. Test the RPM repository update" |
| 181 | echo "4. Review and test AUR package in $AUR_DIR" |
| 182 | echo "5. Push git changes: git push origin trunk v$NEW_VERSION" |
| 183 | echo "6. Commit and push AUR changes" |