From 780599c3302cb14dbb1dda2471ce8f604d232fe0 Mon Sep 17 00:00:00 2001 From: Tim Meusel Date: Fri, 22 Sep 2023 10:53:13 +0200 Subject: [PATCH] Apply Vox Pupuli CI best practices --- .github/workflows/ci.yml | 11 +++++++---- .github/workflows/release.yml | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e362941..19cdf0f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,7 +1,10 @@ name: Test on: - - pull_request + pull_request: {} + push: + branches: + - master env: BUNDLE_WITHOUT: release @@ -11,10 +14,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Install Ruby 3.1 + - name: Install Ruby 3.2 uses: ruby/setup-ruby@v1 with: - ruby-version: "3.1" + ruby-version: "3.2" bundler-cache: true - name: Run rubocop run: bundle exec rake rubocop @@ -40,7 +43,7 @@ jobs: ruby-version: ${{ matrix.ruby }} bundler-cache: true - name: Verify gem builds - run: gem build *.gemspec + run: gem build --strict --verbose *.gemspec - name: Run spec tests run: bundle exec rake diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3b17187 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + release: + runs-on: ubuntu-latest + if: github.repository_owner == 'voxpupuli' + steps: + - uses: actions/checkout@v3 + - name: Install Ruby 3.0 + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.0' + env: + BUNDLE_WITHOUT: release + - name: Build gem + run: gem build --strict --verbose *.gemspec + - name: Publish gem to rubygems.org + run: gem push *.gem + env: + GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}' + - name: Setup GitHub packages access + run: | + mkdir -p ~/.gem + echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials + chmod 0600 ~/.gem/credentials + - name: Publish gem to GitHub packages + run: gem push --key github --host https://rubygems.pkg.github.com/voxpupuli *.gem