From 741b3278e64ef1d62a6425446e454e23f17ac57e Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 18 Apr 2025 15:08:14 +0000 Subject: [PATCH] Switch to trusted publishing workflow and run it on version.rb changes --- .github/workflows/publish.yml | 26 +++++++++++++++++++++++++ .github/workflows/publish_gem.yml | 12 ------------ README.md | 32 ++++++++++++------------------- Rakefile | 2 +- 4 files changed, 39 insertions(+), 33 deletions(-) create mode 100644 .github/workflows/publish.yml delete mode 100644 .github/workflows/publish_gem.yml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..c48177ff --- /dev/null +++ b/.github/workflows/publish.yml @@ -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 diff --git a/.github/workflows/publish_gem.yml b/.github/workflows/publish_gem.yml deleted file mode 100644 index 3cf0d5fd..00000000 --- a/.github/workflows/publish_gem.yml +++ /dev/null @@ -1,12 +0,0 @@ -name: Publish Gem - -on: - push: - tags: v* - -jobs: - call-workflow: - uses: zendesk/gw/.github/workflows/ruby-gem-publication.yml@main - secrets: - RUBY_GEMS_API_KEY: ${{ secrets.RUBY_GEMS_API_KEY }} - RUBY_GEMS_TOTP_DEVICE: ${{ secrets.RUBY_GEMS_TOTP_DEVICE }} diff --git a/README.md b/README.md index 8e557dad..c137853c 100644 --- a/README.md +++ b/README.md @@ -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/) @@ -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 diff --git a/Rakefile b/Rakefile index 56ac7c83..cb0c77e8 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,4 @@ +require 'bundler/setup' require 'rake/testtask' require 'bundler/gem_tasks' require 'bump/tasks' @@ -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)