Bump Ruby recipes on schedule or request #554
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Bump Ruby recipes on schedule or request | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - .github/workflows/autobump.yml | |
| workflow_dispatch: | |
| schedule: | |
| - cron: "0 0,12 * * *" | |
| permissions: | |
| contents: write | |
| jobs: | |
| autobump: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| token: ${{ secrets.RELEASE_TOKEN }} | |
| - uses: ruby/setup-ruby@v1 | |
| with: | |
| ruby-version: .ruby-version | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Check for new stable Ruby versions | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| all_tags=$(gh release list --repo ruby/ruby --limit 200 --json tagName --jq '.[].tagName') | |
| minor_versions=$(echo "$all_tags" | grep -v -iE '(preview|rc)' | \ | |
| sed 's/^v//; s/_/./g' | \ | |
| grep -oE '^[0-9]+\.[0-9]+' | \ | |
| sort -V -u) | |
| minor_versions=$(echo "$minor_versions" | awk -F. '$1 > 3 || ($1 == 3 && $2 >= 2)') | |
| echo "Discovered minor series: $(echo $minor_versions | tr '\n' ' ')" | |
| for minor in $minor_versions; do | |
| underscore_prefix="v${minor//./_}_" | |
| dot_prefix="v${minor//./\\.}\\." | |
| latest=$(echo "$all_tags" | \ | |
| grep -E "^(${underscore_prefix}|${dot_prefix})" | \ | |
| grep -viE '(preview|rc)' | \ | |
| sed 's/^v//; s/_/./g' | \ | |
| grep -E "^${minor}\.[0-9]+$" | \ | |
| sort -V | tail -1) | |
| if [[ -z "$latest" ]]; then | |
| echo "No release found for $minor series" | |
| continue | |
| fi | |
| if ruby -ryaml -e 'exit(YAML.load_file("recipes/rubies.yml").fetch("rubies").key?(ARGV.fetch(0)) ? 0 : 1)' "$latest"; then | |
| echo "Recipe already exists: $latest" | |
| continue | |
| fi | |
| tarball_url="https://cache.ruby-lang.org/pub/ruby/${minor}/ruby-${latest}.tar.gz" | |
| echo "Fetching SHA256 for $tarball_url" | |
| if ! curl -fsSL "$tarball_url" -o /tmp/ruby.tar.gz; then | |
| echo "Failed to download $tarball_url" | |
| continue | |
| fi | |
| sha256=$(sha256sum /tmp/ruby.tar.gz | cut -d' ' -f1) | |
| bin/update-ruby-recipe "$latest" "$tarball_url" "$sha256" | |
| bin/validate-recipes | |
| if ! git diff --quiet -- recipes/rubies.yml; then | |
| git add recipes/rubies.yml | |
| git commit -m "Add Ruby ${latest}" | |
| fi | |
| done | |
| - name: Check for prerelease Ruby versions | |
| env: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| run: | | |
| set -euo pipefail | |
| all_releases=$(gh release list --repo ruby/ruby --limit 200 --json tagName --jq '.[].tagName') | |
| echo "$all_releases" | while read -r tag; do | |
| if ! echo "$tag" | grep -qiE '(preview|rc)'; then | |
| continue | |
| fi | |
| if echo "$tag" | grep -q '\.'; then | |
| version=$(echo "$tag" | sed 's/^v//') | |
| else | |
| version=$(echo "$tag" | sed 's/^v//; s/_/./g' | sed 's/\.\(preview\)/-\1/i; s/\.\(rc\)/-\1/i') | |
| fi | |
| minor=$(echo "$version" | grep -oE '^[0-9]+\.[0-9]+') | |
| underscore_pattern="^v${minor//./_}_[0-9]+$" | |
| dot_pattern="^v${minor//./\\.}\.[0-9]+$" | |
| if echo "$all_releases" | grep -qE "(${underscore_pattern}|${dot_pattern})"; then | |
| echo "Skipping $version - stable releases exist for $minor series" | |
| continue | |
| fi | |
| if ruby -ryaml -e 'exit(YAML.load_file("recipes/rubies.yml").fetch("rubies").key?(ARGV.fetch(0)) ? 0 : 1)' "$version"; then | |
| echo "Recipe already exists: $version" | |
| continue | |
| fi | |
| tarball_url="https://cache.ruby-lang.org/pub/ruby/${minor}/ruby-${version}.tar.gz" | |
| echo "Fetching SHA256 for $tarball_url" | |
| if ! curl -fsSL "$tarball_url" -o /tmp/ruby.tar.gz; then | |
| echo "Failed to download $tarball_url" | |
| continue | |
| fi | |
| sha256=$(sha256sum /tmp/ruby.tar.gz | cut -d' ' -f1) | |
| bin/update-ruby-recipe "$version" "$tarball_url" "$sha256" | |
| bin/validate-recipes | |
| if ! git diff --quiet -- recipes/rubies.yml; then | |
| git add recipes/rubies.yml | |
| git commit -m "Add Ruby ${version}" | |
| fi | |
| done | |
| - name: Push changes | |
| run: | | |
| if git log --oneline "origin/${GITHUB_REF_NAME}..HEAD" | grep -q .; then | |
| git push | |
| else | |
| echo "No recipe changes to push" | |
| fi |