Skip to content

Commit 741b327

Browse files
author
github-actions
committed
Switch to trusted publishing workflow and run it on version.rb changes
1 parent 0c5c445 commit 741b327

File tree

4 files changed

+39
-33
lines changed

4 files changed

+39
-33
lines changed

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Publish to RubyGems.org
2+
3+
on:
4+
push:
5+
branches: main
6+
paths: lib/zendesk_api/version.rb
7+
workflow_dispatch:
8+
9+
jobs:
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+
24+
- name: Install dependencies
25+
run: bundle install
26+
- uses: rubygems/release-gem@v1

.github/workflows/publish_gem.yml

Lines changed: 0 additions & 12 deletions
This file was deleted.

README.md

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,6 @@ ticket = ZendeskAPI::Ticket.find(id: 1)
283283
requester = ZendeskAPI::User.find(id: ticket.requester_id)
284284
```
285285

286-
By explicitly fetching associated resources, you can ensure that your application only processes the data it needs, improving overall efficiency.
287-
288286
### Omnichannel
289287

290288
Support for the [Agent Availability API](https://developer.zendesk.com/api-reference/agent-availability/agent-availability-api/introduction/)
@@ -475,25 +473,19 @@ installation.destroy!
475473
ZendeskAPI::AppInstallation.destroy!(client, :id => 123)
476474
```
477475

478-
## Running the gem locally
479-
480-
See `.github/workflows/main.yml` to understand the CI process.
481-
482-
```
483-
bundle exec rake # Runs the tests
484-
bundle exec rubocop # Runs the lint (use `--fix` for autocorrect)
485-
```
486-
487-
## Releasing a new gem version
476+
### Releasing a new version
477+
A new version is published to RubyGems.org every time a change to `version.rb` is pushed to the `main` branch.
478+
In short, follow these steps:
479+
1. Update `version.rb`,
480+
2. merge this change into `main`, and
481+
3. look at [the action](https://github.com/zendesk/zendesk_api_client_rb/actions/workflows/publish.yml) for output.
488482

489-
1. From updated master: `git checkout -b bump-vX.X.X`, according to [SemVer](https://semver.org)
490-
2. Ensure the CHANGELOG is correct and updated, this is your last opportunity
491-
3. Execute `bundle exec bump:patch # minor|major`, this bumps the version in a new commit, and adds the relative git tag
492-
4. Push to GitHub `git push origin vX.X.X -u && git push --tags`
493-
5. Raise a PR ([example](https://github.com/zendesk/zendesk_api_client_rb/pull/540)) including the code diff ([example](https://github.com/zendesk/zendesk_api_client_rb/compare/v2.0.1...v3.0.0.rc1))
494-
6. Get it approved and merged
495-
7. Post a message in Slack `#rest-api` (example **TODO**), so advocacy are aware that we are going to release a new gem, just in case any customer complains about something related to the gem
496-
8. After 2 hours from the above message, you can [approve the release of the gem](https://github.com/zendesk/zendesk_api_client_rb/deployments/activity_log?environment=rubygems-publish)
483+
To create a pre-release from a non-main branch:
484+
1. change the version in `version.rb` to something like `1.2.0.pre.1` or `2.0.0.beta.2`,
485+
2. push this change to your branch,
486+
3. go to [Actions → “Publish to RubyGems.org” on GitHub](https://github.com/zendesk/zendesk_api_client_rb/actions/workflows/publish.yml),
487+
4. click the “Run workflow” button,
488+
5. pick your branch from a dropdown.
497489

498490
## Contributing
499491

Rakefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
require 'bundler/setup'
12
require 'rake/testtask'
23
require 'bundler/gem_tasks'
34
require 'bump/tasks'
@@ -39,7 +40,6 @@ if defined?(RSpec)
3940
task :default => "spec"
4041
end
4142

42-
# extracted from https://github.com/grosser/project_template
4343
rule(/^version:bump:.*/) do |t|
4444
sh "git status | grep 'nothing to commit'" # ensure we are not dirty
4545
index = %w(major minor patch).index(t.name.split(':').last)

0 commit comments

Comments
 (0)