novuhq / novu-ruby

Ruby SDK for Novu - The open-source notification infrastructure for engineers. 🚀
https://rubygems.org/gems/novu
MIT License
23 stars 10 forks source link

feat: automatic rubygem release #44

Closed Eazybright closed 11 months ago

Eazybright commented 11 months ago

This PR setup a github action workflow process for publishing this SDK to RubyGems.org on New Tagged Release.

What to do:

  1. Get API key from RubyGems.org dashboard and add this variable to the env secrets: RUBYGEMS_AUTH_TOKEN.
  2. Set the neccessary workflow permissions in the repository settings.
unicodeveloper commented 11 months ago

I just added the RUBYGEMS_AUTH_TOKEN secret to this repo.

There are a couple of things we might have to change. Since this is merged, it means a new PR will need to be submitted to effect this change.

  1. The value of name in the release.yml should be more descriptive like this Publish new Novu Ruby SDK release to Ruby Gems
  2. I looked at the steps in the release.yml file. And it is in this manner:
    • A step to set up ruby
    • A step to run tests
    • A step to publish gem: This section creates a credentials file, appends our rubygems API to the file, builds the gemspec, and then publishes the gem. The first question I have is: How does it know the exact version, e.g v1.0.5 to publish as the version of the gem? Does it get it from the gemspec? Where does the number come from?

I think we might need a step to get the latest version of the GitHub tag of the repo. Something like this:

- name: Get the release version
      id: get_version
      run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT

And then we need a step to set the version as the gem version to publish: ${{ steps.get_version.outputs.VERSION }} to rubygems.

This is my assumption @Eazybright @Cliftonz. So how do we accomplish this? Because it's necessary.

unicodeveloper commented 11 months ago

This is a similar release workflow on another Novu SDK: https://github.com/novuhq/novu-java/blob/main/.github/workflows/maven-publish.yml

Eazybright commented 11 months ago

I just added the RUBYGEMS_AUTH_TOKEN secret to this repo.

There are a couple of things we might have to change. Since this is merged, it means a new PR will need to be submitted to effect this change.

  1. The value of name in the release.yml should be more descriptive like this Publish new Novu Ruby SDK release to Ruby Gems
  2. I looked at the steps in the release.yml file. And it is in this manner:
  • A step to set up ruby
  • A step to run tests
  • A step to publish gem: This section creates a credentials file, appends our rubygems API to the file, builds the gemspec, and then publishes the gem. The first question I have is: How does it know the exact version, e.g v1.0.5 to publish as the version of the gem? Does it get it from the gemspec? Where does the number come from?

I think we might need a step to get the latest version of the GitHub tag of the repo. Something like this:

- name: Get the release version
      id: get_version
      run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_OUTPUT

And then we need a step to set the version as the gem version to publish: ${{ steps.get_version.outputs.VERSION }} to rubygems.

This is my assumption @Eazybright @Cliftonz. So how do we accomplish this? Because it's necessary.

RubyGems uses the configuration in the novu.gemspec file to determine the release version. There's also a version file in the SDK lib/novu/version.rb but it's not being used at the moment.

@unicodeveloper

Eazybright commented 11 months ago

@unicodeveloper a PR has been raised: https://github.com/novuhq/novu-ruby/pull/46