RUBY SDK v1.0.0 #2
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .github/workflows/publish-ruby.yml | |
name: Publish Ruby Gem | |
on: | |
release: | |
types: [published] | |
push: | |
tags: | |
- "v*" | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.1" | |
bundler-cache: true | |
- name: Extract version from tag | |
id: version | |
run: | | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/v} | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
echo "Publishing version: $VERSION" | |
else | |
echo "Not a tag push, skipping" | |
exit 1 | |
fi | |
- name: Verify version matches gemspec | |
run: | | |
GEMSPEC_VERSION=$(ruby -e "spec = eval(File.read(Dir.glob('*.gemspec').first)); puts spec.version") | |
TAG_VERSION="${{ steps.version.outputs.version }}" | |
if [ "$GEMSPEC_VERSION" != "$TAG_VERSION" ]; then | |
echo "Version mismatch: gemspec=$GEMSPEC_VERSION, tag=$TAG_VERSION" | |
echo "Your Python script should have already updated the gemspec version" | |
exit 1 | |
fi | |
echo "Version verified: $GEMSPEC_VERSION" | |
- name: Run tests (if they exist) | |
run: | | |
if [ -f "spec/spec_helper.rb" ] || [ -f "test/test_helper.rb" ]; then | |
bundle exec rake test || bundle exec rspec || echo "Tests not configured, skipping" | |
else | |
echo "No tests found, skipping" | |
fi | |
- name: Build gem | |
run: | | |
gem build *.gemspec | |
echo "Built gem files:" | |
ls -la *.gem | |
- name: Configure RubyGems credentials | |
run: | | |
mkdir -p ~/.gem | |
echo ":rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials | |
chmod 600 ~/.gem/credentials | |
- name: Publish to RubyGems | |
run: | | |
GEM_FILE=$(ls *.gem | head -1) | |
echo "Publishing $GEM_FILE to RubyGems..." | |
gem push "$GEM_FILE" | |
echo "✓ Successfully published to RubyGems.org" | |
- name: Clean up credentials | |
if: always() | |
run: rm -f ~/.gem/credentials |