Dev/0.5 #37
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/CD Pipeline | |
| on: | |
| push: | |
| branches: [ main, "release/**" ] | |
| tags: | |
| - 'v*.*.*' | |
| pull_request: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 10 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.2' | |
| bundler-cache: true | |
| - name: Install dependencies | |
| run: | | |
| bundle install --jobs 4 --retry 3 | |
| bundle list | |
| - name: Run PR test suite | |
| run: bundle exec rake pr_test | |
| publish-gem: | |
| runs-on: ubuntu-latest | |
| needs: test | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Ruby | |
| uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: '3.2' | |
| bundler-cache: true | |
| - name: Extract version from tag | |
| id: version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Install dependencies | |
| run: bundle install --jobs 4 --retry 3 | |
| - name: Build gem | |
| run: bundle exec rake build | |
| - name: Publish to RubyGems | |
| run: | | |
| mkdir -p ~/.gem | |
| echo ":rubygems_api_key: ${{ secrets.RUBYGEMS_API_KEY }}" > ~/.gem/credentials | |
| chmod 0600 ~/.gem/credentials | |
| gem push pkg/asciisourcerer-*.gem | |
| env: | |
| RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }} | |
| - name: Verify publication | |
| run: | | |
| echo "Gem published successfully!" | |
| echo "Version: ${{ steps.version.outputs.VERSION }}" | |
| echo "View at: https://rubygems.org/gems/asciisourcerer/versions/${{ steps.version.outputs.VERSION }}" |