Skip to content

Switch to trusted publishing workflow and run it on version.rb changes #586

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish to RubyGems.org

on:
push:
branches: main
paths: lib/zendesk_api/version.rb
workflow_dispatch:

jobs:
publish:
runs-on: ubuntu-latest
environment: rubygems-publish
if: github.repository_owner == 'zendesk'
permissions:
id-token: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
bundler-cache: false

- name: Install dependencies
run: bundle install
- uses: rubygems/release-gem@v1
12 changes: 0 additions & 12 deletions .github/workflows/publish_gem.yml

This file was deleted.

32 changes: 12 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,6 @@ ticket = ZendeskAPI::Ticket.find(id: 1)
requester = ZendeskAPI::User.find(id: ticket.requester_id)
```

By explicitly fetching associated resources, you can ensure that your application only processes the data it needs, improving overall efficiency.

### Omnichannel

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

## Running the gem locally

See `.github/workflows/main.yml` to understand the CI process.

```
bundle exec rake # Runs the tests
bundle exec rubocop # Runs the lint (use `--fix` for autocorrect)
```

## Releasing a new gem version
### Releasing a new version
A new version is published to RubyGems.org every time a change to `version.rb` is pushed to the `main` branch.
In short, follow these steps:
1. Update `version.rb`,
2. merge this change into `main`, and
3. look at [the action](https://github.com/zendesk/zendesk_api_client_rb/actions/workflows/publish.yml) for output.

1. From updated master: `git checkout -b bump-vX.X.X`, according to [SemVer](https://semver.org)
2. Ensure the CHANGELOG is correct and updated, this is your last opportunity
3. Execute `bundle exec bump:patch # minor|major`, this bumps the version in a new commit, and adds the relative git tag
4. Push to GitHub `git push origin vX.X.X -u && git push --tags`
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))
6. Get it approved and merged
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
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)
To create a pre-release from a non-main branch:
1. change the version in `version.rb` to something like `1.2.0.pre.1` or `2.0.0.beta.2`,
2. push this change to your branch,
3. go to [Actions → “Publish to RubyGems.org” on GitHub](https://github.com/zendesk/zendesk_api_client_rb/actions/workflows/publish.yml),
4. click the “Run workflow” button,
5. pick your branch from a dropdown.

## Contributing

Expand Down
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
require 'bundler/setup'
require 'rake/testtask'
require 'bundler/gem_tasks'
require 'bump/tasks'
Expand Down Expand Up @@ -39,7 +40,6 @@ if defined?(RSpec)
task :default => "spec"
end

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