|
| 1 | +#!/usr/bin/env bash |
| 2 | +set -euo pipefail |
| 3 | +IFS=$'\n\t' |
| 4 | + |
| 5 | +# Get the current version from version.rb |
| 6 | +VERSION=$(ruby -r ./lib/command_deck/version.rb -e 'puts CommandDeck::VERSION') |
| 7 | + |
| 8 | +echo "=====================================" |
| 9 | +echo "Releasing command_deck v${VERSION}" |
| 10 | +echo "=====================================" |
| 11 | +echo |
| 12 | + |
| 13 | +# Verify we're on master branch |
| 14 | +BRANCH=$(git rev-parse --abbrev-ref HEAD) |
| 15 | +if [ "$BRANCH" != "master" ]; then |
| 16 | + echo "Error: You must be on the master branch to release" |
| 17 | + exit 1 |
| 18 | +fi |
| 19 | + |
| 20 | +# Verify working directory is clean |
| 21 | +if [ -n "$(git status --porcelain)" ]; then |
| 22 | + echo "Error: Working directory is not clean. Commit or stash your changes first." |
| 23 | + exit 1 |
| 24 | +fi |
| 25 | + |
| 26 | +# Run tests |
| 27 | +echo "Running tests..." |
| 28 | +bundle exec rake test || { echo "Tests failed!"; exit 1; } |
| 29 | +echo |
| 30 | + |
| 31 | +# Run rubocop |
| 32 | +echo "Running rubocop..." |
| 33 | +bundle exec rubocop || { echo "RuboCop failed!"; exit 1; } |
| 34 | +echo |
| 35 | + |
| 36 | +# Build the gem |
| 37 | +echo "Building gem..." |
| 38 | +rm -f *.gem |
| 39 | +gem build command_deck.gemspec || { echo "Gem build failed!"; exit 1; } |
| 40 | +echo |
| 41 | + |
| 42 | +# Create git tag |
| 43 | +echo "Creating git tag v${VERSION}..." |
| 44 | +if git rev-parse "v${VERSION}" >/dev/null 2>&1; then |
| 45 | + echo "Error: Tag v${VERSION} already exists" |
| 46 | + exit 1 |
| 47 | +fi |
| 48 | +git tag "v${VERSION}" |
| 49 | +echo |
| 50 | + |
| 51 | +# Push to GitHub |
| 52 | +echo "Pushing to GitHub..." |
| 53 | +git push origin master |
| 54 | +git push origin "v${VERSION}" |
| 55 | +echo |
| 56 | + |
| 57 | +# Push to RubyGems |
| 58 | +echo "Publishing to RubyGems..." |
| 59 | +gem push "command_deck-${VERSION}.gem" |
| 60 | +echo |
| 61 | + |
| 62 | +echo "=====================================" |
| 63 | +echo "✅ Successfully released v${VERSION}" |
| 64 | +echo "=====================================" |
| 65 | +echo |
| 66 | +echo "Next steps:" |
| 67 | +echo "1. Create a GitHub release at https://github.com/crow-rojas/command_deck/releases" |
| 68 | +echo "2. Wait a few minutes for the gem to appear on https://rubygems.org/gems/command_deck" |
0 commit comments