Skip to content

Commit dd1208a

Browse files
committed
Extract auto-update workflow for default gems on NEWS.md
We should stop it until final release of Ruby.
1 parent 50282a5 commit dd1208a

File tree

2 files changed

+93
-59
lines changed

2 files changed

+93
-59
lines changed

.github/workflows/check_misc.yml

Lines changed: 0 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -52,65 +52,6 @@ jobs:
5252
exit $fail
5353
working-directory: include
5454

55-
- id: gems
56-
run: true
57-
if: ${{ github.ref == 'refs/heads/master' }}
58-
59-
- name: Download previous gems list
60-
run: |
61-
data=default_gems.json
62-
mkdir -p .downloaded-cache
63-
ln -s .downloaded-cache/$data .
64-
curl -O -R -z ./$data https://stdgems.org/$data
65-
if: ${{ steps.gems.outcome == 'success' }}
66-
67-
- name: Make default gems list
68-
run: |
69-
#!ruby
70-
require 'rubygems'
71-
$:.unshift "lib"
72-
rgver = File.foreach("lib/rubygems.rb") do |line|
73-
break $1 if /^\s*VERSION\s*=\s*"([^"]+)"/ =~ line
74-
end
75-
gems = Dir.glob("{ext,lib}/**/*.gemspec").map do |f|
76-
spec = Gem::Specification.load(f)
77-
"#{spec.name} #{spec.version}"
78-
end.sort
79-
File.open("gems/default_gems", "w") do |f|
80-
f.puts "RubyGems #{rgver}"
81-
f.puts gems
82-
end
83-
shell: ruby --disable=gems {0}
84-
if: ${{ steps.gems.outcome == 'success' }}
85-
86-
- name: Maintain updated gems list in NEWS
87-
run: |
88-
ruby tool/update-NEWS-gemlist.rb default
89-
if: ${{ steps.gems.outcome == 'success' }}
90-
91-
- name: Check diffs
92-
id: diff
93-
run: |
94-
git diff --color --no-ext-diff --ignore-submodules --exit-code NEWS.md ||
95-
echo update=true >> $GITHUB_OUTPUT
96-
if: ${{ steps.gems.outcome == 'success' }}
97-
98-
- name: Commit
99-
run: |
100-
git pull --ff-only origin ${GITHUB_REF#refs/heads/}
101-
git commit --message="Update default gems list at ${GITHUB_SHA:0:30} [ci skip]" NEWS.md
102-
git push origin ${GITHUB_REF#refs/heads/}
103-
env:
104-
105-
GIT_AUTHOR_NAME: git
106-
GIT_COMMITTER_NAME: git
107-
if: >-
108-
${{
109-
github.repository == 'ruby/ruby' &&
110-
!startsWith(github.event_name, 'pull') &&
111-
steps.diff.outputs.update
112-
}}
113-
11455
- name: Generate docs
11556
id: docs
11657
run: |

.github/workflows/default_gems.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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

Comments
 (0)