diff --git a/.github/workflows/autobump.yml b/.github/workflows/autobump.yml index 6090e75..ddae227 100644 --- a/.github/workflows/autobump.yml +++ b/.github/workflows/autobump.yml @@ -74,8 +74,8 @@ jobs: bin/update-ruby-recipe "$latest" "$tarball_url" "$sha256" bin/validate-recipes - if ! git diff --quiet -- recipes/rubies.yml; then - git add recipes/rubies.yml + if ! git diff --quiet -- recipes/rubies.yml recipes/series.yml; then + git add recipes/rubies.yml recipes/series.yml git commit -m "Add Ruby ${latest}" fi done @@ -121,8 +121,8 @@ jobs: bin/update-ruby-recipe "$version" "$tarball_url" "$sha256" bin/validate-recipes - if ! git diff --quiet -- recipes/rubies.yml; then - git add recipes/rubies.yml + if ! git diff --quiet -- recipes/rubies.yml recipes/series.yml; then + git add recipes/rubies.yml recipes/series.yml git commit -m "Add Ruby ${version}" fi done @@ -134,3 +134,36 @@ jobs: else echo "No recipe changes to push" fi + + notify-failure: + needs: autobump + if: ${{ failure() }} + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Send failure email via Resend + env: + RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }} + NOTIFY_EMAIL: ${{ secrets.NOTIFY_EMAIL }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + run: | + set -euo pipefail + if [ -z "${RESEND_API_KEY:-}" ] || [ -z "${NOTIFY_EMAIL:-}" ]; then + echo "::warning::RESEND_API_KEY or NOTIFY_EMAIL is unset; skipping autobump failure notification" + exit 0 + fi + payload=$(jq -n \ + --arg to "$NOTIFY_EMAIL" \ + --arg run_url "$RUN_URL" \ + '{ + from: "Ruby Releases ", + to: [$to], + subject: "❌ Ruby autobump failed", + html: ("

The autobump workflow failed, so new Ruby releases are not being picked up.

View workflow run

") + }') + curl --fail-with-body -sS \ + --retry 3 --retry-all-errors --retry-delay 2 --retry-max-time 60 \ + -X POST 'https://api.resend.com/emails' \ + -H "Authorization: Bearer ${RESEND_API_KEY}" \ + -H 'Content-Type: application/json' \ + -d "$payload" diff --git a/libexec/update_ruby_recipe.rb b/libexec/update_ruby_recipe.rb index 93f8337..45569f3 100755 --- a/libexec/update_ruby_recipe.rb +++ b/libexec/update_ruby_recipe.rb @@ -8,6 +8,7 @@ class UpdateRubyRecipeError < StandardError; end class UpdateRubyRecipe ROOT = File.expand_path("..", __dir__) RECIPE_PATH = File.join(ROOT, "recipes", "rubies.yml") + SERIES_PATH = File.join(ROOT, "recipes", "series.yml") PRE_RELEASE_RANK = { "preview" => 0, "rc" => 1 @@ -34,6 +35,7 @@ def run! rubies = doc.fetch("rubies") old = rubies[@version] entry = recipe_entry + register_series(entry.fetch("series")) if old == entry puts "Ruby #{@version} already exists in recipes/rubies.yml" return @@ -46,6 +48,16 @@ def run! private + # A new minor series has no overrides yet, so it gets the defaults. + def register_series(name) + text = File.read(SERIES_PATH) + doc = YAML.safe_load(text, permitted_classes: [], aliases: false) + return if doc.fetch("series").key?(name) + + File.write(SERIES_PATH, "#{text.chomp}\n \"#{name}\": {}\n") + puts "Added series #{name} in recipes/series.yml" + end + def recipe_entry entry = { "series" => @version[/\A\d+\.\d+/],