Skip to content

Commit

Permalink
add ci testing and update publishing instructions (#6)
Browse files Browse the repository at this point in the history
* update publishing instructions and add GitHub testing

* Update ci.yml

---------

Co-authored-by: Tate Thurston <[email protected]>
  • Loading branch information
tatthurs and Tate Thurston authored Jul 16, 2024
1 parent 1e966e7 commit 0b3dff8
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 58 deletions.
6 changes: 0 additions & 6 deletions .github/dependabot.yml

This file was deleted.

58 changes: 16 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,53 +1,27 @@
name: CI

on: [push, pull_request]
on:
push:
branches:
- main
- master
pull_request:

jobs:
tests:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
ruby: [2.4, 2.7, '3.0', 3.1, 3.2, truffleruby-head]

ruby: ["2.7", "3.0", "3.1", "3.2", "3.3"]
name: Ruby ${{ matrix.ruby }}
steps:
- uses: actions/checkout@v3

- name: Sets up the Ruby version
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

- name: Sets up the environment
run: |
sudo apt-get install libsqlite3-dev
- name: Install legacy bundler for Ruby 2.4
if: ${{ matrix.ruby == 2.4 }}
run: |
gem install -q bundler -v 2.3.26
- name: Install bundler 2.4+ for modern Rubies
if: ${{ matrix.ruby != 2.4 }}
run: |
gem install -q bundler
- name: Run bundle install
run: |
bundle install
- uses: actions/checkout@v4

- name: Runs code QA and tests
run: bundle exec rake
- uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}
bundler-cache: true

- name: Publish to Rubygems
continue-on-error: true
if: ${{ github.ref == 'refs/heads/master' }}
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
- run: |
bundle exec rake spec
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ Gemfile.lock

# Gem builds
/*.gem

pkg
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -838,20 +838,14 @@ This project is intended to be a safe, welcoming space for collaboration, and
contributors are expected to adhere to the
[Contributor Covenant](https://contributor-covenant.org) code of conduct.

### Publishing
### ART19 Gem Publishing

Releases are manual, performed locally on a developer's machine. Gems are published to Github Packages. A comprehesive outline of this process can be found here: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry.
Releases are manual, performed locally on a developer's machine. Gems are published to Github Packages. A comprehensive outline of this process can be found here: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry.

1. Increment the `ART19_REVISION` in [lib/jsonapi/serializer/version.rb#L5](https://github.com/art19/jsonapi-serializer/blob/master/lib/jsonapi/serializer/version.rb#L5)

2. Build the gem:
2. Publish the gem:

```
gem build jsonapi-serializer.gemspec
```

3. Publish your gem, replacing $VERSION with the gem version. You'll see the generated file after running `gem build` above, eg: 'jsonapi-serializer-2.2.0.1.gem'.

```
gem push --key github --host https://rubygems.pkg.github.com/art19 jsonapi-serializer-$VERSION.gem
bundle exec rake publish
```
8 changes: 8 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@ require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'

desc 'Build the package and publish it to rubygems.pkg.github.com'
task publish: :build do
# Requires local setup of personal access token, see:
# 1. https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-rubygems-registry#authenticating-with-a-personal-access-token
system("gem push --key github --host https://rubygems.pkg.github.com/art19 " \
"pkg/jsonapi-serializer-#{JSONAPI::Serializer::VERSION}.gem")
end

desc('Codestyle check and linter')
RuboCop::RakeTask.new('rubocop') do |task|
task.fail_on_error = true
Expand Down
1 change: 1 addition & 0 deletions lib/fast_jsonapi/object_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
require 'active_support/concern'
require 'active_support/inflector'
require 'active_support/core_ext/numeric/time'
require "active_support/core_ext/object"
require 'fast_jsonapi/helpers'
require 'fast_jsonapi/attribute'
require 'fast_jsonapi/relationship'
Expand Down

0 comments on commit 0b3dff8

Please sign in to comment.