Skip to content
Closed
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
78 changes: 78 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Publish

on:
workflow_dispatch:

permissions:
contents: write
id-token: write

jobs:
publish:
name: Publish gem
runs-on: ubuntu-latest
environment: release

steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4"
bundler-cache: true

- name: Resolve version
id: version
run: |
version="$(bundle exec ruby -r ./lib/unleash/version -e 'puts Unleash::VERSION')"
gem_version="$(bundle exec ruby -e 'spec = Gem::Specification.load("unleash-client.gemspec"); puts spec.version')"
tag="v${version}"
echo "version=${version}" >> "$GITHUB_OUTPUT"
echo "gem_version=${gem_version}" >> "$GITHUB_OUTPUT"
echo "tag=${tag}" >> "$GITHUB_OUTPUT"

- name: Check tag does not exist
run: |
if git rev-parse "${{ steps.version.outputs.tag }}" >/dev/null 2>&1; then
echo "Tag ${{ steps.version.outputs.tag }} already exists"
exit 1
fi

- name: Download test cases
run: |
semver="$(ruby echo_client_spec_version.rb)"
git clone --depth 5 --branch "v${semver}" https://github.com/Unleash/client-specification.git client-specification

- name: Run specs
run: bundle exec rspec

- name: Run lint
run: bundle exec rubocop --format simple

- name: Build gem
run: bundle exec rake build

- name: Configure RubyGems credentials
uses: rubygems/configure-rubygems-credentials@main

- name: Publish to RubyGems
run: gem push "pkg/unleash-${{ steps.version.outputs.gem_version }}.gem"

- name: Tag release
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "${{ steps.version.outputs.tag }}"
git push origin "${{ steps.version.outputs.tag }}"

- name: Create GitHub release
env:
GH_TOKEN: ${{ github.token }}
run: |
gh release create "${{ steps.version.outputs.tag }}" \
--title "${{ steps.version.outputs.tag }}" \
--generate-notes
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,10 @@ To release a new version, follow these steps:
3. Commit changes:
- Commit the changes with a message like: `chore: bump version to x.y.z.`
4. Release the gem:
- On the `main` branch, run `bundle exec rake release` to create a git tag for the new version, push commits and tags to origin, and publish `.gem` file to [rubygems.org](https://rubygems.org).
- Merge the version and changelog changes to the `main` branch.
- Run the `Publish` GitHub Actions workflow manually.
- The workflow validates the release with `bundle exec rspec`, `bundle exec rubocop --format simple`, and `bundle exec rake build`.
- If validation passes, the workflow publishes the gem to [rubygems.org](https://rubygems.org), creates the `vX.Y.Z` git tag, and creates a GitHub release.

## Contributing

Expand Down
Loading