Skip to content

Commit 0a0f627

Browse files
BhacazIMillerPetal
andauthored
General maintenance of the gem (#120)
* Update README.md Co-authored-by: IMillerPetal <98353053+IMillerPetal@users.noreply.github.com> --------- Co-authored-by: IMillerPetal <98353053+IMillerPetal@users.noreply.github.com>
1 parent bbd61d8 commit 0a0f627

17 files changed

Lines changed: 276 additions & 34 deletions

.github/workflows/build.yml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,37 @@ on:
77
- master
88
jobs:
99
Build:
10-
runs-on: ubuntu-latest
10+
runs-on: ubuntu-24.04
1111
strategy:
1212
matrix:
1313
ruby: ['2.7', '3.0', '3.1', '3.2', '3.3', '3.4']
1414
steps:
15-
- uses: actions/checkout@v4
16-
with:
17-
ref: ${{ github.event.pull_request.head.sha }}
18-
- name: Set up Ruby ${{ matrix.ruby }}
19-
uses: ruby/setup-ruby@v1
20-
with:
21-
ruby-version: ${{ matrix.ruby }}
22-
bundler-cache: true
23-
- name: Bundle install
24-
run: bundle install
25-
- name: Specs with coverage
26-
if: ${{ matrix.ruby == 2.7 }}
27-
run: "RUBYOPT='--enable=frozen-string-literal --debug=frozen-string-literal' bundle exec rake"
28-
env:
29-
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
30-
CI_PULL_REQUEST: ${{ github.event.number }}
31-
CI_BRANCH: ${{ github.head_ref }}
32-
- name: Specs
33-
if: ${{ matrix.ruby != 2.7 }}
34-
run: "RUBYOPT='--enable=frozen-string-literal --debug=frozen-string-literal' bundle exec rake"
15+
- uses: actions/checkout@v4
16+
with:
17+
ref: ${{ github.event.pull_request.head.sha }}
18+
- name: Set up Ruby ${{ matrix.ruby }}
19+
uses: ruby/setup-ruby@v1
20+
with:
21+
ruby-version: ${{ matrix.ruby }}
22+
bundler-cache: true
23+
- name: Bundle install
24+
run: bundle install
25+
- name: Specs with coverage
26+
if: ${{ matrix.ruby == 2.7 }}
27+
run: "RUBYOPT='--enable=frozen-string-literal --debug=frozen-string-literal' bundle exec rake"
28+
env:
29+
COVERAGE: true
30+
- name: Specs
31+
if: ${{ matrix.ruby != 2.7 }}
32+
run: "RUBYOPT='--enable=frozen-string-literal --debug=frozen-string-literal' bundle exec rake"
33+
- name: Coverage report
34+
if: ${{ matrix.ruby == 2.7 }}
35+
uses: joshmfrankel/simplecov-check-action@0743d75f9c88262f651e1ec402bbd3d586f6e7ac
36+
with:
37+
github_token: ${{ secrets.GITHUB_TOKEN }}
38+
3539
Rubocop:
36-
runs-on: ubuntu-latest
40+
runs-on: ubuntu-24.04
3741
steps:
3842
- uses: actions/checkout@v4
3943
- name: Set up Ruby 2.7

.github/workflows/release.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# .github/workflows/publish-release.yml
2+
name: Publish release
3+
on:
4+
push:
5+
tags:
6+
- "v*"
7+
jobs:
8+
github_release:
9+
name: GitHub release
10+
runs-on: ubuntu-24.04
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Create GitHub release
16+
run: |
17+
tag_name="$(git describe --tags --abbrev=0)"
18+
gh release create "${tag_name}" --verify-tag --generate-notes
19+
env:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
rubygems_publish:
22+
name: Push gem to RubyGems.org
23+
runs-on: ubuntu-24.04
24+
permissions:
25+
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
26+
contents: write # IMPORTANT: this permission is required for `rake release` to push the release tag
27+
steps:
28+
- uses: actions/checkout@v4
29+
- name: Set up Ruby
30+
uses: ruby/setup-ruby@v1
31+
with:
32+
bundler-cache: true
33+
ruby-version: ruby
34+
- uses: rubygems/release-gem@v1
35+
with:
36+
await-release: false

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
/pkg/
77
/spec/reports/
88
/tmp/
9-
Gemfile.lock
109

1110
# rspec failure tracking
1211
.rspec_status

CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# Change log
1+
# Changelog
22

3-
## master (unreleased)
4-
5-
* Conditional block executed in the context of serializer ([#119](https://github.com/petalmd/bright_serializer/pull/119))
3+
> [!NOTE]
4+
For newer versions see [GitHub releases](https://github.com/petalmd/bright_serializer/releases).
65

76
## 0.5.2 (2023-09-19)
87

Gemfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ source 'https://rubygems.org'
66
gemspec
77

88
group :development do
9-
gem 'coveralls_reborn', require: false
109
gem 'faker'
1110
gem 'rake'
1211
gem 'rspec'
1312
gem 'rubocop'
1413
gem 'rubocop-performance'
1514
gem 'rubocop-rspec'
15+
gem 'simplecov', require: false
1616
end

Gemfile.lock

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
PATH
2+
remote: .
3+
specs:
4+
bright_serializer (0.5.2)
5+
activesupport (>= 7.0)
6+
oj (~> 3.0)
7+
8+
GEM
9+
remote: https://rubygems.org/
10+
specs:
11+
activesupport (7.1.5.1)
12+
base64
13+
benchmark (>= 0.3)
14+
bigdecimal
15+
concurrent-ruby (~> 1.0, >= 1.0.2)
16+
connection_pool (>= 2.2.5)
17+
drb
18+
i18n (>= 1.6, < 2)
19+
logger (>= 1.4.2)
20+
minitest (>= 5.1)
21+
mutex_m
22+
securerandom (>= 0.3)
23+
tzinfo (~> 2.0)
24+
ast (2.4.3)
25+
base64 (0.3.0)
26+
benchmark (0.4.1)
27+
bigdecimal (3.2.2)
28+
concurrent-ruby (1.3.5)
29+
connection_pool (2.5.3)
30+
diff-lcs (1.6.2)
31+
docile (1.4.1)
32+
drb (2.2.3)
33+
faker (3.4.2)
34+
i18n (>= 1.8.11, < 2)
35+
i18n (1.14.7)
36+
concurrent-ruby (~> 1.0)
37+
json (2.13.2)
38+
language_server-protocol (3.17.0.5)
39+
lint_roller (1.1.0)
40+
logger (1.7.0)
41+
minitest (5.25.5)
42+
mutex_m (0.3.0)
43+
oj (3.16.11)
44+
bigdecimal (>= 3.0)
45+
ostruct (>= 0.2)
46+
ostruct (0.6.3)
47+
parallel (1.27.0)
48+
parser (3.3.9.0)
49+
ast (~> 2.4.1)
50+
racc
51+
prism (1.4.0)
52+
racc (1.8.1)
53+
rainbow (3.1.1)
54+
rake (13.3.0)
55+
regexp_parser (2.11.0)
56+
rspec (3.13.1)
57+
rspec-core (~> 3.13.0)
58+
rspec-expectations (~> 3.13.0)
59+
rspec-mocks (~> 3.13.0)
60+
rspec-core (3.13.5)
61+
rspec-support (~> 3.13.0)
62+
rspec-expectations (3.13.5)
63+
diff-lcs (>= 1.2.0, < 2.0)
64+
rspec-support (~> 3.13.0)
65+
rspec-mocks (3.13.5)
66+
diff-lcs (>= 1.2.0, < 2.0)
67+
rspec-support (~> 3.13.0)
68+
rspec-support (3.13.4)
69+
rubocop (1.79.2)
70+
json (~> 2.3)
71+
language_server-protocol (~> 3.17.0.2)
72+
lint_roller (~> 1.1.0)
73+
parallel (~> 1.10)
74+
parser (>= 3.3.0.2)
75+
rainbow (>= 2.2.2, < 4.0)
76+
regexp_parser (>= 2.9.3, < 3.0)
77+
rubocop-ast (>= 1.46.0, < 2.0)
78+
ruby-progressbar (~> 1.7)
79+
unicode-display_width (>= 2.4.0, < 4.0)
80+
rubocop-ast (1.46.0)
81+
parser (>= 3.3.7.2)
82+
prism (~> 1.4)
83+
rubocop-performance (1.25.0)
84+
lint_roller (~> 1.1)
85+
rubocop (>= 1.75.0, < 2.0)
86+
rubocop-ast (>= 1.38.0, < 2.0)
87+
rubocop-rspec (3.6.0)
88+
lint_roller (~> 1.1)
89+
rubocop (~> 1.72, >= 1.72.1)
90+
ruby-progressbar (1.13.0)
91+
securerandom (0.3.2)
92+
simplecov (0.22.0)
93+
docile (~> 1.1)
94+
simplecov-html (~> 0.11)
95+
simplecov_json_formatter (~> 0.1)
96+
simplecov-html (0.13.2)
97+
simplecov_json_formatter (0.1.4)
98+
tzinfo (2.0.6)
99+
concurrent-ruby (~> 1.0)
100+
unicode-display_width (3.1.4)
101+
unicode-emoji (~> 4.0, >= 4.0.4)
102+
unicode-emoji (4.0.4)
103+
104+
PLATFORMS
105+
ruby
106+
107+
DEPENDENCIES
108+
bright_serializer!
109+
faker
110+
rake
111+
rspec
112+
rubocop
113+
rubocop-performance
114+
rubocop-rspec
115+
simplecov
116+
117+
BUNDLED WITH
118+
2.4.22

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,14 @@ To install this gem onto your local machine, run `bundle exec rake install`.
223223

224224
## New release
225225

226-
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
226+
Commit all changes in git before bumping the version.
227+
Bump version with:
228+
229+
```shell
230+
bin/bump major|minor|patch
231+
```
232+
233+
GitHub Actions will take care of the rest
227234

228235
## Contributing
229236

bin/bump

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
SEM = %w[major minor patch].freeze
5+
6+
# raise if git not clean
7+
raise 'Git is not clean' unless system('git', 'diff', '--quiet')
8+
9+
sem = ARGV[0]
10+
11+
if sem.nil? || !SEM.include?(sem)
12+
puts "Please provide a valid semver: #{SEM.join(', ')}"
13+
exit 1
14+
end
15+
16+
version_file_path = Dir.glob('lib/*/version.rb').first
17+
raise 'Version file not found in lib/*/version.rb' if version_file_path.nil?
18+
19+
current_version_file_content = File.read(version_file_path)
20+
current_version_file_content =~ /VERSION = \W(\d+\.\d+\.\d+)\W/
21+
current_version = Regexp.last_match(1)
22+
23+
major, minor, patch = current_version.split('.').map(&:to_i)
24+
25+
case sem
26+
when 'major'
27+
major += 1
28+
minor = 0
29+
patch = 0
30+
when 'minor'
31+
minor += 1
32+
patch = 0
33+
when 'patch'
34+
patch += 1
35+
end
36+
37+
new_version = "#{major}.#{minor}.#{patch}"
38+
39+
File.write(version_file_path, current_version_file_content.gsub(current_version, new_version))
40+
41+
puts "Bumped version from #{current_version} to #{new_version}"
42+
43+
begin
44+
system('bundle', 'install')
45+
46+
system('git', 'add', '.')
47+
system('git', 'commit', '-m', "Bump to v#{new_version}")
48+
system('git', 'tag', '-am', "v#{new_version}", "v#{new_version}")
49+
50+
system('git', 'push')
51+
system('git', 'push', '--tags')
52+
rescue StandardError => e
53+
puts "Failed: #{e.message}"
54+
exit 1
55+
end

bright_serializer.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
1616

1717
spec.metadata = {
1818
'homepage_uri' => spec.homepage,
19-
'changelog_uri' => 'https://github.com/petalmd/bright_serializer/blob/master/CHANGELOG.md',
19+
'changelog_uri' => 'https://github.com/petalmd/bright_serializer/releases',
2020
'source_code_uri' => 'https://github.com/petalmd/bright_serializer',
2121
'bug_tracker_uri' => 'https://github.com/petalmd/bright_serializer/issues',
2222
'rubygems_mfa_required' => 'true'

spec/bright_serializer/extensions/instrumentation_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
let(:serializer_class) do
1515
Class.new do
1616
include BrightSerializer::Serializer
17+
1718
attributes :id, :name
1819

1920
def self.name

0 commit comments

Comments
 (0)