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

Merged
merged 1 commit into from
May 23, 2025
Merged
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.

25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -484,16 +484,21 @@ bundle exec rake # Runs the tests
bundle exec rubocop # Runs the lint (use `--fix` for autocorrect)
```

## Releasing a new gem version

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)
### 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`,
3. post a message in Slack `#rest-api`, 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,
4. 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)
5. look at [the action](https://github.com/zendesk/zendesk_api_client_rb/actions/workflows/publish.yml) for output.

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
1 change: 1 addition & 0 deletions 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
Loading