Release #6
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
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| ref: main | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.3.6' | |
| bundler-cache: false | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| # Extract version from tag name, handling both 'v' prefix and no prefix | |
| if [[ $GITHUB_REF == refs/tags/v* ]]; then | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| else | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| fi | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Extracted version: $VERSION" | |
| - name: Check current version | |
| id: current_version | |
| run: | | |
| CURRENT_VERSION=$(ruby -e "require_relative 'lib/session_recorder/version'; puts Multiplayer::SessionRecorder::VERSION") | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| echo "Current version in file: $CURRENT_VERSION" | |
| echo "Tag version: ${{ steps.version.outputs.version }}" | |
| - name: Update version file | |
| run: | | |
| # Update the version in lib/session_recorder/version.rb | |
| cat > lib/session_recorder/version.rb << EOF | |
| # frozen_string_literal: true | |
| module Multiplayer | |
| module SessionRecorder | |
| VERSION = "${{ steps.version.outputs.version }}" | |
| end | |
| end | |
| EOF | |
| echo "Updated version to ${{ steps.version.outputs.version }}" | |
| - name: Commit and push changes | |
| run: | | |
| git config --local user.email "[email protected]" | |
| git config --local user.name "GitHub Action" | |
| # Check if there are changes to commit | |
| if git diff --quiet; then | |
| echo "No changes to commit - version already up to date" | |
| else | |
| git add lib/session_recorder/version.rb | |
| git commit -m "chore: bump version to ${{ steps.version.outputs.version }}" | |
| git push origin main | |
| echo "Version updated and pushed successfully" | |
| fi | |
| - name: Configure Bundler | |
| run: | | |
| bundle config set --local frozen false | |
| bundle config set --local deployment false | |
| bundle config set --local path vendor/bundle | |
| - name: Install build dependencies | |
| run: | | |
| gem install bundler | |
| bundle install | |
| - name: Build gem | |
| run: | | |
| bundle exec rake build | |
| echo "Gem built successfully" | |
| ls -la pkg/ || echo "pkg/ directory contents:" | |
| ls -la *.gem || echo "No .gem files in current directory" | |
| - name: Find and verify gem file | |
| id: gem_file | |
| run: | | |
| # Look for gem files in pkg/ directory (default Rake location) | |
| if [ -d "pkg" ]; then | |
| gem_file=$(ls pkg/*.gem | head -1) | |
| if [ -n "$gem_file" ]; then | |
| echo "Found gem in pkg/: $gem_file" | |
| echo "gem_path=$gem_file" >> $GITHUB_OUTPUT | |
| else | |
| echo "No .gem files found in pkg/ directory" | |
| exit 1 | |
| fi | |
| else | |
| # Fallback: look in current directory | |
| gem_file=$(ls *.gem | head -1) | |
| if [ -n "$gem_file" ]; then | |
| echo "Found gem in current directory: $gem_file" | |
| echo "gem_path=$gem_file" >> $GITHUB_OUTPUT | |
| else | |
| echo "No .gem files found anywhere" | |
| exit 1 | |
| fi | |
| fi | |
| - name: Configure RubyGems credentials | |
| run: | | |
| # Create .gemrc file with correct API key format | |
| cat > ~/.gemrc << EOF | |
| --- | |
| :rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }} | |
| :backtrace: false | |
| :bulk_threshold: 1000 | |
| :sources: | |
| - https://rubygems.org/ | |
| :update_sources: true | |
| :verbose: true | |
| EOF | |
| echo "RubyGems configuration created" | |
| # Also set the API key via environment variable | |
| echo "RUBYGEMS_API_KEY=${{ secrets.RUBYGEMS_API_KEY }}" >> $GITHUB_ENV | |
| - name: Publish to RubyGems | |
| env: | |
| RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
| run: | | |
| # Verify API key is set | |
| if [ -z "$RUBYGEMS_API_KEY" ]; then | |
| echo "Error: RUBYGEMS_API_KEY is not set" | |
| exit 1 | |
| fi | |
| echo "API key length: ${#RUBYGEMS_API_KEY}" | |
| echo "Publishing gem: ${{ steps.gem_file.outputs.gem_path }}" | |
| # Try multiple authentication methods | |
| if gem push "${{ steps.gem_file.outputs.gem_path }}" --key "$RUBYGEMS_API_KEY"; then | |
| echo "Gem published successfully using --key flag" | |
| elif gem push "${{ steps.gem_file.outputs.gem_path }}"; then | |
| echo "Gem published successfully using .gemrc configuration" | |
| else | |
| echo "Failed to publish gem with all authentication methods" | |
| exit 1 | |
| fi | |
| - name: Create GitHub Release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ github.ref }} | |
| release_name: Release ${{ steps.version.outputs.version }} | |
| body: | | |
| ## What's Changed | |
| Release version ${{ steps.version.outputs.version }} | |
| ### Installation | |
| ```bash | |
| gem install multiplayer-session-recorder | |
| ``` | |
| ### Usage | |
| ```ruby | |
| require 'session-recorder' | |
| # Create exporter | |
| exporter = SessionRecorder::Exporters.create_http_trace_exporter( | |
| api_key: 'your-api-key' | |
| ) | |
| ``` | |
| See [README.md](README.md) for full documentation. | |
| draft: false | |
| prerelease: false |