Update README, lint, and get CI working to auto-publish #2
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: CI | ||
| on: | ||
| pull_request: | ||
| push: | ||
| branches: [ main ] | ||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.ref }} | ||
| cancel-in-progress: true | ||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.4' | ||
| bundler-cache: true | ||
| - name: Run linters | ||
| run: bundle exec rake ci:lint | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.4' | ||
| bundler-cache: true | ||
| - name: Cache Claude CLI | ||
| id: cache-claude | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.local/bin/claude | ||
| key: claude-cli-${{ runner.os }}-${{ hashFiles('**/lockfile') || 'weekly' }}-${{ github.run_number % 100 }} | ||
| restore-keys: | | ||
| claude-cli-${{ runner.os }}- | ||
| - name: Install Claude Code CLI | ||
| if: steps.cache-claude.outputs.cache-hit != 'true' | ||
| run: curl -fsSL https://claude.ai/install.sh | bash | ||
| - name: Add Claude to PATH | ||
| run: echo "$HOME/.local/bin" >> $GITHUB_PATH | ||
| - name: Verify Claude installation | ||
| run: claude --version | ||
| - name: Run tests | ||
| run: bundle exec rake ci:test | ||
| env: | ||
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| publish: | ||
| needs: [lint, test] | ||
| name: Publish to RubyGems | ||
| if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@v5 | ||
| - name: Set up Ruby | ||
| uses: ruby/setup-ruby@v1 | ||
| with: | ||
| ruby-version: '3.4' | ||
| bundler-cache: true | ||
| - name: Build gem | ||
| run: gem build ruby_agent.gemspec | ||
| - name: Publish to RubyGems | ||
| run: | | ||
| mkdir -p ~/.gem | ||
| echo "---" > ~/.gem/credentials | ||
| echo ":rubygems_api_key: ${RUBYGEMS_API_KEY}" >> ~/.gem/credentials | ||
| chmod 0600 ~/.gem/credentials | ||
| gem push ruby_agent-*.gem | ||
| env: | ||
| RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | ||
| - name: Create git tag | ||
| run: | | ||
| VERSION=$(ruby -r ./lib/ruby_agent/version.rb -e "puts RubyAgent::VERSION") | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git tag -a "v${VERSION}" -m "Release v${VERSION}" || echo "Tag already exists" | ||
| git push origin "v${VERSION}" || echo "Tag already pushed" | ||