Skip to content

Commit e4b090f

Browse files
committed
chore: create script to automate releases
1 parent 01ae3d8 commit e4b090f

2 files changed

Lines changed: 95 additions & 0 deletions

File tree

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,33 @@ bundle exec rubocop -A
5858
- Provide steps to reproduce
5959
- Include relevant code samples
6060

61+
## Releasing a New Version
62+
63+
**Prerequisites:**
64+
65+
- Update `lib/command_deck/version.rb` with the new version
66+
- Update `CHANGELOG.md` with changes
67+
- Commit all changes
68+
- Be on the `master` branch with a clean working directory
69+
70+
**Release:**
71+
72+
```bash
73+
bin/release
74+
```
75+
76+
This script will:
77+
78+
1. Run tests and RuboCop
79+
2. Build the gem
80+
3. Create a git tag
81+
4. Push to GitHub
82+
5. Publish to RubyGems
83+
84+
**Manual steps after release:**
85+
86+
- Create a GitHub release with the CHANGELOG content.
87+
6188
## Questions?
6289

6390
Feel free to open an issue for questions or discussions.

bin/release

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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

Comments
 (0)