Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto update Ruby definition with Ruby releases #2430

Merged
merged 2 commits into from
Aug 2, 2024
Merged

Auto update Ruby definition with Ruby releases #2430

merged 2 commits into from
Aug 2, 2024

Conversation

hsbt
Copy link
Member

@hsbt hsbt commented Aug 1, 2024

Background:

I and release manager of Ruby improve release workflow recently. I make this manual workflow to automated workflow.

After Ruby release, ruby/ruby#11286 notify to related repositories like docker image, snap package and etc.

I would like to create new definition of ruby-build with above notification. This PR makes it with repository_dispatch feature. After that, we can update definition with simple REST call like:

curl -L -X POST \
          -H "Authorization: Bearer xxx" \
          -H "Accept: application/vnd.github+json" \
          -H "X-GitHub-Api-Version: 2022-11-28" \
          https://api.github.com/repos/rbenv/ruby-build/dispatches \
          -d '{"event_type": "update-ruby", "client_payload":{"ruby_version":"3.3.4", "openssl_version":"3.0.14"}}'

@@ -24,7 +26,17 @@ else
exit 1
fi

openssl_url="https://www.openssl.org/source/openssl-${openssl_version}.tar.gz"
if command -v sha256sum >/dev/null; then
openssl_sha256=$(sha256sum "$release_directory/$openssl_basename" | cut -d ' ' -f 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you need to download the openssl archive before this line, otherwise it won't be there

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah it's done in the workflow, I see. That doesn't seem practical if this script is ever run manually though.

git config user.name "GitHub Actions Bot"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "rake sync"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Add Ruby ${{ env.RUBY_VERSION }}" is a much better message

git commit -m "rake sync"
git push
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because this is using the default GITHUB_TOKEN it will not trigger other workflows like https://github.com/rbenv/ruby-build/blob/master/.github/workflows/mirror.yml
That seems a problem, as that one should run.
It will also not trigger the ci workflow, which doesn't seem good.
That could result in the archive not being mirrored or having an incorrect checksum, etc.

A solution is to use a PAT for this.

Or instead of pushing to create a PR, I think that's safer and clearer what's going on.
That's what I'm using for setup-ruby:
https://github.com/ruby/ruby-builder/blob/master/.github/actions/create-pr-to-setup-ruby/action.yml

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsbt hsbt merged commit a1bb3e4 into master Aug 2, 2024
6 checks passed
@hsbt hsbt deleted the auto-update branch August 2, 2024 01:57
@hsbt
Copy link
Member Author

hsbt commented Aug 2, 2024

This and hotfix are working fine: d22fa95

Thanks @eregon

Comment on lines +36 to +37
curl -sL https://cache.ruby-lang.org/pub/ruby/${{ env.ABI_VERSION }}/ruby-${{ env.RUBY_VERSION }}.tar.gz
curl -sL https://www.openssl.org/source/openssl-${{ env.OPENSSL_VERSION }}.tar.gz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these lines supposed to do or verify something? If we wanted to download these URLs to local files, I do not think curl will do it unless -O was used?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I added -O at e12c32f

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants