From 4369fd472121d35e635de8ebda2416c1971f13ab Mon Sep 17 00:00:00 2001 From: georgebell Date: Tue, 14 Nov 2023 10:17:07 +0000 Subject: [PATCH] Add pipelines --- .github/workflows/gem-push.yml | 48 ++++++++++++++++++++++++++++++++++ .github/workflows/gem-test.yml | 22 ++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .github/workflows/gem-push.yml create mode 100644 .github/workflows/gem-test.yml diff --git a/.github/workflows/gem-push.yml b/.github/workflows/gem-push.yml new file mode 100644 index 0000000..0d1f82c --- /dev/null +++ b/.github/workflows/gem-push.yml @@ -0,0 +1,48 @@ +name: Ruby Gem Publish + +on: + push: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: [ '3.0', '3.1', '3.2' ] + + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Run tests + run: bundle exec rspec + + deploy: + needs: test + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby 3.0.1 + uses: ruby/setup-ruby@v1 + with: + ruby-version: 3.1.2 + bundler-cache: true + + - name: Publish to RubyGems + run: | + mkdir -p $HOME/.gem + touch $HOME/.gem/credentials + chmod 0600 $HOME/.gem/credentials + printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials + gem build *.gemspec + gem push *.gem + env: + GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}" \ No newline at end of file diff --git a/.github/workflows/gem-test.yml b/.github/workflows/gem-test.yml new file mode 100644 index 0000000..e32e1aa --- /dev/null +++ b/.github/workflows/gem-test.yml @@ -0,0 +1,22 @@ +name: Ruby Test + +on: + pull_request: + branches: [ "main" ] + +jobs: + test: + runs-on: ubuntu-latest + strategy: + matrix: + ruby-version: [ '3.0', '3.1', '3.2' ] + + steps: + - uses: actions/checkout@v2 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + bundler-cache: true # runs 'bundle install' and caches installed gems automatically + - name: Run tests + run: bundle exec rspec \ No newline at end of file