|
| 1 | +name: Update default gems list |
| 2 | +on: [push, pull_request, merge_group] |
| 3 | + |
| 4 | +concurrency: |
| 5 | + group: ${{ github.workflow }} / ${{ startsWith(github.event_name, 'pull') && github.ref_name || github.sha }} |
| 6 | + cancel-in-progress: ${{ startsWith(github.event_name, 'pull') }} |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
| 10 | + |
| 11 | +jobs: |
| 12 | + update_default_gems: |
| 13 | + name: Update default gems list |
| 14 | + |
| 15 | + permissions: |
| 16 | + contents: write # for Git to git push |
| 17 | + |
| 18 | + runs-on: ubuntu-latest |
| 19 | + |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@d632683dd7b4114ad314bca15554477dd762a938 # v4.2.0 |
| 22 | + with: |
| 23 | + token: ${{ (github.repository == 'ruby/ruby' && !startsWith(github.event_name, 'pull')) && secrets.MATZBOT_GITHUB_TOKEN || secrets.GITHUB_TOKEN }} |
| 24 | + |
| 25 | + - uses: ./.github/actions/setup/directories |
| 26 | + with: |
| 27 | + makeup: true |
| 28 | + # Skip overwriting MATZBOT_GITHUB_TOKEN |
| 29 | + checkout: '' # false (ref: https://github.com/actions/runner/issues/2238) |
| 30 | + |
| 31 | + - id: gems |
| 32 | + run: true |
| 33 | + if: ${{ github.ref == 'refs/heads/master' }} |
| 34 | + |
| 35 | + - name: Download previous gems list |
| 36 | + run: | |
| 37 | + data=default_gems.json |
| 38 | + mkdir -p .downloaded-cache |
| 39 | + ln -s .downloaded-cache/$data . |
| 40 | + curl -O -R -z ./$data https://stdgems.org/$data |
| 41 | + if: ${{ steps.gems.outcome == 'success' }} |
| 42 | + |
| 43 | + - name: Make default gems list |
| 44 | + run: | |
| 45 | + #!ruby |
| 46 | + require 'rubygems' |
| 47 | + $:.unshift "lib" |
| 48 | + rgver = File.foreach("lib/rubygems.rb") do |line| |
| 49 | + break $1 if /^\s*VERSION\s*=\s*"([^"]+)"/ =~ line |
| 50 | + end |
| 51 | + gems = Dir.glob("{ext,lib}/**/*.gemspec").map do |f| |
| 52 | + spec = Gem::Specification.load(f) |
| 53 | + "#{spec.name} #{spec.version}" |
| 54 | + end.sort |
| 55 | + File.open("gems/default_gems", "w") do |f| |
| 56 | + f.puts "RubyGems #{rgver}" |
| 57 | + f.puts gems |
| 58 | + end |
| 59 | + shell: ruby --disable=gems {0} |
| 60 | + if: ${{ steps.gems.outcome == 'success' }} |
| 61 | + |
| 62 | + - name: Maintain updated gems list in NEWS |
| 63 | + run: | |
| 64 | + ruby tool/update-NEWS-gemlist.rb default |
| 65 | + if: ${{ steps.gems.outcome == 'success' }} |
| 66 | + |
| 67 | + - name: Check diffs |
| 68 | + id: diff |
| 69 | + run: | |
| 70 | + git diff --color --no-ext-diff --ignore-submodules --exit-code NEWS.md || |
| 71 | + echo update=true >> $GITHUB_OUTPUT |
| 72 | + if: ${{ steps.gems.outcome == 'success' }} |
| 73 | + |
| 74 | + - name: Commit |
| 75 | + run: | |
| 76 | + git pull --ff-only origin ${GITHUB_REF#refs/heads/} |
| 77 | + git commit --message="Update default gems list at ${GITHUB_SHA:0:30} [ci skip]" NEWS.md |
| 78 | + git push origin ${GITHUB_REF#refs/heads/} |
| 79 | + env: |
| 80 | + |
| 81 | + GIT_AUTHOR_NAME: git |
| 82 | + GIT_COMMITTER_NAME: git |
| 83 | + if: >- |
| 84 | + ${{ |
| 85 | + github.repository == 'ruby/ruby' && |
| 86 | + !startsWith(github.event_name, 'pull') && |
| 87 | + steps.diff.outputs.update |
| 88 | + }} |
| 89 | +
|
| 90 | + - uses: ./.github/actions/slack |
| 91 | + with: |
| 92 | + SLACK_WEBHOOK_URL: ${{ secrets.SIMPLER_ALERTS_URL }} # ruby-lang slack: ruby/simpler-alerts-bot |
| 93 | + if: ${{ failure() }} |
0 commit comments