Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/workflows/sponsor-badges.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Sponsor badges

on:
push:
branches: [main]
paths: [".structuredmerge/kettle-jem.yml", "bin/kettle-sponsors"]
schedule:
- cron: "17 5 * * *" # picks up sponsors whose `until` date has passed
workflow_dispatch:

permissions:
contents: write

concurrency:
group: sponsor-badges
cancel-in-progress: false

jobs:
render:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1
with:
ruby-version: "3.4" # stdlib only; no bundler
- name: Checksum sponsors block
id: check
run: |
if bin/kettle-sponsors --check; then echo "changed=true" >> "$GITHUB_OUTPUT"; fi
- name: Render badges
if: steps.check.outputs.changed == 'true'
run: bin/kettle-sponsors
- name: Commit
if: steps.check.outputs.changed == 'true'
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add assets/sponsors
git diff --staged --quiet && exit 0
git commit -m "chore: refresh sponsor badges"
for i in 1 2 3; do git pull --rebase -q && git push && break; sleep 5; done
5 changes: 5 additions & 0 deletions .structuredmerge/kettle-jem.yml
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,11 @@ readme:
url: https://www.citigroup.com
- name: GitHub
url: https://github.com
- name: GitHub
url: https://github.com
img_src: https://github.githubassets.com/images/modules/logos_page/GitHub-Logo.png
since: "2026-08-29"
description: Donated "Copilot Max" plan
# Optional package-family README block.
# Supported values: structuredmerge
# Leave unset for standalone kettle-rb gems and most projects.
Expand Down
32 changes: 16 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PATH
GEM
remote: https://gem.coop/
specs:
addressable (2.9.0)
addressable (2.9.2)
public_suffix (>= 2.0.2, < 8.0)
anonymous_loader (0.1.5)
version_gem (~> 1.1, >= 1.1.17)
Expand Down Expand Up @@ -299,17 +299,17 @@ GEM
net-protocol (0.4.0)
timeout
nkf (0.3.0)
nokogiri (1.19.4-aarch64-linux-gnu)
nokogiri (1.19.7-aarch64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.4-aarch64-linux-musl)
nokogiri (1.19.7-aarch64-linux-musl)
racc (~> 1.4)
nokogiri (1.19.4-arm64-darwin)
nokogiri (1.19.7-arm64-darwin)
racc (~> 1.4)
nokogiri (1.19.4-x86_64-darwin)
nokogiri (1.19.7-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.19.4-x86_64-linux-gnu)
nokogiri (1.19.7-x86_64-linux-gnu)
racc (~> 1.4)
nokogiri (1.19.4-x86_64-linux-musl)
nokogiri (1.19.7-x86_64-linux-musl)
racc (~> 1.4)
nomono (1.1.16)
version_gem (~> 1.1, >= 1.1.16)
Expand Down Expand Up @@ -344,7 +344,7 @@ GEM
yaml-merge (= 7.1.16)
public_suffix (7.0.5)
racc (1.8.1)
rack (3.2.7)
rack (3.2.8)
rainbow (3.1.1)
rake (13.4.2)
rbs (4.2.0)
Expand Down Expand Up @@ -683,7 +683,7 @@ DEPENDENCIES
yard-yaml (~> 0.2, >= 0.2.6)

CHECKSUMS
addressable (2.9.0) sha256=7fdf6ac3660f7f4e867a0838be3f6cf722ace541dd97767fa42bc6cfa980c7af
addressable (2.9.2) sha256=9117c7e7d6ee07230e75ce41fb9401ae55354dc654fcd0e862ba41d539e9a610
anonymous_loader (0.1.5) sha256=c96a4a1b5f49f320037fae63e931ac15b3823686e4f0ee6f24f75a0ade4227cb
ansi (1.6.0) sha256=ac9ea0c0ea8d32fb4e271348e609963ac78882f34b73836c2a02b3622e666658
appraisal2 (3.2.6) sha256=6664d2404b9fe160dfbbed4dd9b78e7b9146402bc3468ff92ba78c1878bc318a
Expand Down Expand Up @@ -767,12 +767,12 @@ CHECKSUMS
net-http (0.10.0) sha256=1a2ff6e37a05724973c43f2bf7bf105f59c36a4cd0a7e9b1c021a0a566987c27
net-protocol (0.4.0) sha256=f9f90c8c6f64794a45160bf422177a336db12809de3beeeaa26b88fcd2e8c853
nkf (0.3.0) sha256=357a8dbeba38b727b75930f665146546076a394a1c243faf634ff176e3588895
nokogiri (1.19.4-aarch64-linux-gnu) sha256=1269fb644a6de405057a53dd5c762b1209b43ca7424f839454d3dbc677c31a8f
nokogiri (1.19.4-aarch64-linux-musl) sha256=35c65b9ce72b3bb03207bdbe7067915019dc18c1b9b59139684bd6690fdd01af
nokogiri (1.19.4-arm64-darwin) sha256=a46db9853286e6597b36ebc6953817d15acf3a299583eb3f89fdc6f91dd63527
nokogiri (1.19.4-x86_64-darwin) sha256=7fd17057d3e1f00e9954a74b3cd76595d3d4a5ef233b7ed9599047c204f70551
nokogiri (1.19.4-x86_64-linux-gnu) sha256=379fae440b28915e3f19d752ce2dcf8465ed2b2fbefd2a7ca0dd497bc981a06a
nokogiri (1.19.4-x86_64-linux-musl) sha256=17dfb7c1fa194ae02fbf7c51a7afc8d278045ab3fdacfd86f91d02d7b274470b
nokogiri (1.19.7-aarch64-linux-gnu) sha256=8f5e15d299602456406e1f03a9f3456cceb33a0722811e818d2ee2214eb4c84a
nokogiri (1.19.7-aarch64-linux-musl) sha256=efe0c3602e6e54521bc21c681930ce5568e2d11203de17400710b2b3ca2e4cb4
nokogiri (1.19.7-arm64-darwin) sha256=f27d7f25f4873fbc3aa35a2cc2fb680c98555fec1925348da439d0869d541142
nokogiri (1.19.7-x86_64-darwin) sha256=508e81e8c5f84aaa240dce981bf1c43faae60808726f0ce7024ee92effc5cafe
nokogiri (1.19.7-x86_64-linux-gnu) sha256=25865ccb462f714e712fdf8906fde07849cb6704a808e3d629d75baa5af5dd3b
nokogiri (1.19.7-x86_64-linux-musl) sha256=464d1f3dfb0d53cf54c0c6a7e23e8e91cf68ec3cafc2b27dc4a7682f2d9bf546
nomono (1.1.16) sha256=47a9f28329eca162292ecbb2738b3d348e535566ec98eb0c0b742d278688cf36
oauth2 (2.1.0)
openssl (4.0.2) sha256=1037ad2868ae58df9ad917891c0c0f9815a1172f6846d4bcdd508e4c2ee747c2
Expand All @@ -789,7 +789,7 @@ CHECKSUMS
psych-merge (7.1.16) sha256=35025ea6d739b704c69f1c80aa9cbb75a4f8b8ab3b9877ac9f78bf7653b28393
public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623
racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f
rack (3.2.7) sha256=93e13e1c24f93556671d85d2d79fa228c3485815c50d7e2f265b5330c6528fb7
rack (3.2.8) sha256=1fecc85e463ebc7a2a945fff829ffcd549babeb1556384796fad946c28dc4ec7
rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a
rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701
rbs (4.2.0) sha256=51f7b886dcc05bc09e10b901daa6a81829f6adc03101d6ca9ea4aac6103e0674
Expand Down
58 changes: 58 additions & 0 deletions bin/kettle-sponsors
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

# Generates assets/sponsors/*.svg from readme.corporate_sponsors in
# .structuredmerge/kettle-jem.yml. Only the sponsors block is checksummed, so
# unrelated config edits are a no-op.
#
# bin/kettle-sponsors --check exit 0 if badges are stale, 1 if current (fast; no rendering)
# bin/kettle-sponsors render if stale, then store the checksum
require "yaml"
require "date"
require "json"
require "digest"
require "fileutils"
require "cgi"

ROOT = File.expand_path("..", __dir__)
CONFIG = File.join(ROOT, ".structuredmerge/kettle-jem.yml")
OUT = File.join(ROOT, "assets/sponsors")
SUM = File.join(OUT, ".checksum")

cfg = YAML.safe_load_file(CONFIG, permitted_classes: [Date], aliases: true) || {}
today = Date.today
sponsors = Array(cfg.dig("readme", "corporate_sponsors")).select do |s|
s["until"].nil? || Date.parse(s["until"].to_s) >= today
end
# Expired sponsors drop out of the payload, so expiry changes the checksum too.
sum = Digest::SHA256.hexdigest(JSON.generate(sponsors))
current = File.exist?(SUM) && File.read(SUM).strip == sum

if ARGV.include?("--check")
puts(current ? "sponsors unchanged" : "sponsors changed")
exit(current ? 1 : 0)
end
exit 0 if current

def esc(s) = CGI.escapeHTML(s.to_s)

FileUtils.mkdir_p(OUT)
Dir[File.join(OUT, "*.svg")].each { |f| File.delete(f) }
sponsors.each do |s|
slug = s["name"].downcase.gsub(/[^a-z0-9]+/, "-").gsub(/\A-|-\z/, "")
since = s["since"] ? "since #{s["since"].to_s[0, 7]}" : "sponsor"
desc = s["description"].to_s.strip
w = [190, (s["name"].length * 9) + 40, (desc.length * 6) + 28].max
h = desc.empty? ? 40 : 54
label = [s["name"], since, desc].reject(&:empty?).join(", ")
extra = desc.empty? ? "" : %(\n <text x="14" y="46" font-family="system-ui,sans-serif" font-size="10" fill="#c9d1d9">#{esc(desc)}</text>)
File.write(File.join(OUT, "#{slug}.svg"), <<~SVG)
<svg xmlns="http://www.w3.org/2000/svg" width="#{w}" height="#{h}" viewBox="0 0 #{w} #{h}" role="img" aria-label="#{esc(label)}">
<rect x=".5" y=".5" width="#{w - 1}" height="#{h - 1}" rx="6" fill="#0d1117" stroke="#30363d"/>
<text x="14" y="18" font-family="system-ui,sans-serif" font-size="14" font-weight="700" fill="#f0f6fc">#{esc(s["name"])}</text>
<text x="14" y="32" font-family="system-ui,sans-serif" font-size="10" fill="#8b949e">#{esc(since)}</text>#{extra}
</svg>
SVG
end
File.write(SUM, "#{sum}\n")
puts "rendered #{sponsors.size} badge(s)"
Loading