From d3635e9e734888a3639390cbf0ed138489e05a6d Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 16 Mar 2024 18:43:56 +0000 Subject: [PATCH] ci: update workflow, actions, and ruby versions Also restrict the release-please action to only run against the main repository, to avoid it running on forks. --- .github/workflows/ci.yml | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cebbab0..b2db1de 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,14 +1,13 @@ name: CI -on: push +on: [push, pull_request] + jobs: release-please: name: Release Please runs-on: ubuntu-latest - if: github.ref == 'refs/heads/main' + if: github.ref == 'refs/heads/main' && github.repository == 'krystal/apia' outputs: release_created: ${{ steps.release-please.outputs.release_created }} - tag_name: ${{ steps.release-please.outputs.tag_name }} # e.g. v1.0.0 - version: ${{ steps.release-please.outputs.version }} # e.g. 1.0.0 steps: - uses: google-github-actions/release-please-action@v3 id: release-please @@ -18,15 +17,12 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: - ruby-version: 3.2 - + ruby-version: 3.3 - name: Install dependencies run: bundle install - - name: Run linter run: bundle exec rake lint @@ -40,34 +36,30 @@ jobs: - "3.0" - 3.1 - 3.2 + - 3.3 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - - name: Install dependencies run: bundle install - - name: Run tests run: bundle exec rake test release: runs-on: ubuntu-latest needs: [release-please, test] - if: ${{ needs.release-please.outputs.release_created }} + if: needs.release-please.outputs.release_created steps: - - uses: actions/checkout@master - + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: - ruby-version: 3.1 - + ruby-version: 3.3 - name: Build Gem run: gem build *.gemspec - - name: Setup credentials run: | mkdir -p $HOME/.gem @@ -76,7 +68,6 @@ jobs: printf -- "---\n:rubygems_api_key: ${RUBYGEMS_API_KEY}\n" > $HOME/.gem/credentials env: RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}} - - name: Publish to RubyGems run: | gem push *.gem