diff --git a/.github/workflows/build_publish.yml b/.github/workflows/build_publish.yml new file mode 100644 index 0000000..9435188 --- /dev/null +++ b/.github/workflows/build_publish.yml @@ -0,0 +1,63 @@ +name: Build and publish + +on: + workflow_call: {} + +jobs: + build: + name: Build + runs-on: ubuntu-latest + permissions: + contents: read + packages: read + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_6.1.gemfile + steps: + - uses: actions/checkout@v4 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Build gem + run: bundle exec rake build + + - name: Archive coverage + if: success() + uses: actions/upload-artifact@v4 + with: + name: gem-pkg + path: pkg/*.gem + + publish: + name: Publish + needs: build + if: github.ref_type == 'tag' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.2' + + - uses: actions/download-artifact@v4 + with: + name: gem-pkg + path: pkg/ + + - name: Publish to GPR + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} pkg/*.gem + env: + GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}" + OWNER: ${{ github.repository_owner }} + diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000..2d0d659 --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,29 @@ +name: Changelog + +on: + pull_request: + branches: + - '**' + +jobs: + changelog-updated: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 1 + - name: Check if changelog updated + id: changed-files-specific + uses: tj-actions/changed-files@v44 + with: + base_sha: ${{ github.event.pull_request.base.sha }} + files: | + CHANGELOG.md + env: + GITHUB_TOKEN: ${{ github.token }} + + - name: Fail job if changelog not updated + if: steps.changed-files-specific.outputs.any_changed == 'false' + run: | + exit 1 + diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4063259..df8fdc9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,14 +2,19 @@ name: CI on: push: - branches: [ main ] - pull_request: - branches: [ main ] + branches: + - '**' + tags: + - '**' jobs: test: if: github.ref_type == 'branch' && github.ref_name != 'main' uses: ./.github/workflows/test.yml - # code_quality: - # if: github.ref_type == 'branch' && github.ref_name != 'main' - # uses: ./.github/workflows/code_quality.yml + + code_quality: + if: github.ref_type == 'branch' && github.ref_name != 'main' + uses: ./.github/workflows/code_quality.yml + + build_publish: + uses: ./.github/workflows/build_publish.yml diff --git a/.github/workflows/code_quality.yml b/.github/workflows/code_quality.yml new file mode 100644 index 0000000..7443081 --- /dev/null +++ b/.github/workflows/code_quality.yml @@ -0,0 +1,20 @@ +name: 'Code quality' +on: + workflow_call: {} + +jobs: + rubocop: + name: Rubocop + runs-on: ubuntu-latest + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_7.2.gemfile + steps: + - uses: actions/checkout@v4 + + - uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Inspecting with Rubocop + run: bundle exec rubocop + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index fe03015..22ecc2e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,8 +21,7 @@ jobs: env: BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile steps: - - uses: actions/checkout@v3 - + - uses: actions/checkout@v4 - name: Set up Ruby uses: ruby/setup-ruby@v1 with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 4324278..d0e37ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added ### Fixed +- Reinstated static code analysis checks in CI (#73) ### Removed