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..7f7c04d8 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Rakefile b/Rakefile index 56ac7c83..80718147 100644 --- a/Rakefile +++ b/Rakefile @@ -1,3 +1,4 @@ +require 'bundler/setup' require 'rake/testtask' require 'bundler/gem_tasks' require 'bump/tasks'