Configure gem and crate release automation - #1036
Conversation
f10f932 to
4c7dfff
Compare
vinistock
left a comment
There was a problem hiding this comment.
Have we already configured trusted publishing in crates.io?
| [workspace.dependencies] | ||
| rubydex = { version = "=0.4.1", path = "rubydex" } |
There was a problem hiding this comment.
Why do we need this entry? I'm not sure I understand what it does.
There was a problem hiding this comment.
This is a dependency of rubydex-sys that I moved here as a convenience so there was only one file to update when bumping the version. As discussed offline, I moved it back to rubydex-sys/Cargo.toml
| rubydex = { version = "=X.Y.Z", path = "rubydex" } | ||
| ``` | ||
|
|
||
| The Ruby gem dynamically reads its version from this manifest, so do not edit `lib/rubydex/version.rb`. For pre-release versions, Cargo requires a SemVer prerelease identifier such as `X.Y.Z-beta.N`, which `lib/rubydex/version.rb` translates to `X.Y.Z.betaN` for RubyGems. |
There was a problem hiding this comment.
I think a lot of this sentence is an implementation detail and not really instructions for releasing.
Let's tailor this section specifically for the instructions:
- Bump the version here. This controls the versions of all crates and the Ruby gem
- If you want to ship a beta release, use the format
1.2.3-beta.1
There was a problem hiding this comment.
👍 updated as suggested
| in `.github/workflows/release.yml`. That workflow verifies that the tag matches | ||
| the declared version, cross-compiles the precompiled gems, runs install | ||
| verification, publishes to RubyGems, publishes the workspace crates to | ||
| crates.io, and creates the GitHub release. You can trigger a dry run with | ||
| workflow dispatch; only tag pushes publish a release. |
There was a problem hiding this comment.
Similar here. Are these internal details or relevant instructions for someone trying to release?
I'd honestly not add anything here. If someone tries to push a tag that doesn't match the version, they will notice the mistake.
There was a problem hiding this comment.
I added a mention that it publishes to crates.io as well, and took the opportunity to simplified here
| - name: "Verify exact workspace dependency versions" | ||
| run: | | ||
| metadata="$(cargo metadata --no-deps --format-version 1 --manifest-path rust/Cargo.toml)" | ||
| ruby -rjson -e ' | ||
| metadata = JSON.parse($stdin.read) | ||
| packages = metadata.fetch("packages") | ||
| rubydex = packages.find { |package| package.fetch("name") == "rubydex" } | ||
| rubydex_sys = packages.find { |package| package.fetch("name") == "rubydex-sys" } | ||
| requirement = rubydex_sys.fetch("dependencies").find { |dependency| dependency.fetch("name") == "rubydex" }.fetch("req") | ||
| expected = "=#{rubydex.fetch("version")}" | ||
|
|
||
| if requirement != expected | ||
| abort "rubydex-sys requires rubydex #{requirement.inspect}; expected #{expected.inspect}" | ||
| end | ||
| ' <<<"$metadata" |
There was a problem hiding this comment.
What is this check protecting us from?
There was a problem hiding this comment.
This was a defensive check to make sure the dependency version was pinned to the crate version.
It's overkill; removed.
a31cc11 to
5eb7324
Compare
5eb7324 to
986902c
Compare
vinistock
left a comment
There was a problem hiding this comment.
A few questions, but the general automation looks good. Let's get it configured on the crates io side and ship 🚀
| with: | ||
| ruby-version: "3.2.9" |
There was a problem hiding this comment.
Does this need to run on Ruby 3.2.9? If not, we can just remove this and it will pick up the version specified in .ruby-version.
There was a problem hiding this comment.
Makes sense to me 👍
| with: | ||
| ruby-version: "3.2.9" | ||
| - name: "Verify the tag matches the declared version" | ||
| if: startsWith(github.ref, 'refs/tags/') |
There was a problem hiding this comment.
Should we match the other similar checks?
| if: startsWith(github.ref, 'refs/tags/') | |
| if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') |
| fi | ||
| compile: | ||
| timeout-minutes: 20 | ||
| needs: verify_version |
There was a problem hiding this comment.
Here we're adding a needs requirement to an optional step (since verify_version doesn't run if you trigger the workflow manually for debugging instead of releasing).
Will this work properly if verify_version is skipped by the conditional? Or will the entire workflow get stuck?
There was a problem hiding this comment.
This is a fair question. The condition is on the step, not on the job. So the verify_version job will run and complete regardless of the conditional step being true or not.
But now that you point it out, the previous steps will always run and that's wasteful.
I will look into an alternative approach for this
| permissions: | ||
| id-token: write | ||
| contents: read | ||
| timeout-minutes: 30 |
There was a problem hiding this comment.
30 minutes seems like a lot for just publishing the crates. Maybe 5 is fine?
|
|
||
| [dependencies] | ||
| rubydex = { version = "0.2.6", path = "../rubydex" } | ||
| rubydex = { version = "=0.4.1", path = "../rubydex" } |
There was a problem hiding this comment.
Did you confirm that if we bump the version in rust/Cargo.toml and forget to bump it here, it fails compilation?
There was a problem hiding this comment.
Yes, it fails immediately with
error: failed to select a version for the requirement `rubydex = "=0.4.1"`
candidate versions found which didn't match: 0.4.2
This PR does 2 things:
Before this PR merges, we will need to complete the setup of trusted publishing on crates.io before our next release. The steps needed for both
rubydexandrubydex-sysare:Shopifyrubydexrelease.ymlrelease