Skip to content

Commit a4556ff

Browse files
github-actionsrazumau
authored andcommitted
Switch to trusted publishing workflow and run it on version.rb changes
1 parent 9e0e025 commit a4556ff

File tree

5 files changed

+41
-14
lines changed

5 files changed

+41
-14
lines changed

.github/workflows/publish.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,26 @@
1-
name: Publish Gem
1+
name: Publish to RubyGems.org
22

33
on:
44
push:
5-
tags: v*
5+
branches: main
6+
paths: lib/prop/version.rb
7+
workflow_dispatch:
68

79
jobs:
8-
call-workflow:
9-
uses: zendesk/gw/.github/workflows/ruby-gem-publication.yml@main
10-
secrets:
11-
RUBY_GEMS_API_KEY: ${{ secrets.RUBY_GEMS_API_KEY }}
12-
RUBY_GEMS_TOTP_DEVICE: ${{ secrets.RUBY_GEMS_TOTP_DEVICE }}
10+
publish:
11+
runs-on: ubuntu-latest
12+
environment: rubygems-publish
13+
if: github.repository_owner == 'zendesk'
14+
permissions:
15+
id-token: write
16+
contents: write
17+
steps:
18+
- uses: actions/checkout@v4
19+
- name: Set up Ruby
20+
uses: ruby/setup-ruby@v1
21+
with:
22+
bundler-cache: false
23+
ruby-version: "3.4"
24+
- name: Install dependencies
25+
run: bundle install
26+
- uses: rubygems/release-gem@v1

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Prop ![Build status](https://github.com/zendesk/prop/workflows/ci/badge.svg)
32

43
A gem to rate limit requests/actions of any kind.<br/>
@@ -40,7 +39,7 @@ of the result of the evaluation.
4039
Prop.after_evaluated do |handle, counter, options|
4140
Rails.logger.info "Prop #{handle} has just been check. current value: #{counter}"
4241
end
43-
````
42+
```
4443

4544
## Defining thresholds
4645

@@ -246,6 +245,20 @@ Prop.configure(:api_request, strategy: :leaky_bucket, burst_rate: 20, threshold:
246245

247246
* `:threshold` value here would be the "leak rate" of leaky bucket algorithm.
248247

248+
### Releasing a new version
249+
A new version is published to RubyGems.org every time a change to `version.rb` is pushed to the `main` branch.
250+
In short, follow these steps:
251+
1. Update `version.rb`,
252+
2. update version in all `Gemfile.lock` files,
253+
3. merge this change into `main`, and
254+
4. look at [the action](https://github.com/zendesk/prop/actions/workflows/publish.yml) for output.
255+
256+
To create a pre-release from a non-main branch:
257+
1. change the version in `version.rb` to something like `1.2.0.pre.1` or `2.0.0.beta.2`,
258+
2. push this change to your branch,
259+
3. go to [Actions → “Publish to RubyGems.org” on GitHub](https://github.com/zendesk/prop/actions/workflows/publish.yml),
260+
4. click the “Run workflow” button,
261+
5. pick your branch from a dropdown.
249262

250263
## License
251264

lib/prop.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
require "forwardable"
44

55
module Prop
6-
VERSION = "2.9.0"
7-
8-
# Short hand for accessing Prop::Limiter methods
6+
# Shorthand for accessing Prop::Limiter methods
97
class << self
108
extend Forwardable
119
def_delegators :"Prop::Limiter", :read, :write, :cache, :cache=, :configure, :configurations, :disabled, :before_throttle

lib/prop/version.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module Prop
2+
VERSION = "2.9.0"
3+
end

prop.gemspec

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
$LOAD_PATH.unshift "lib"
2-
require "prop"
1+
require_relative "lib/prop/version"
32

43
Gem::Specification.new "prop", Prop::VERSION do |s|
54
s.license = "Apache License Version 2.0"

0 commit comments

Comments
 (0)