Skip to content

Commit 571d97b

Browse files
committed
Merge branch 'upgrade-hugo'
This topic branch upgrades the Hugo and Pagefind version recorded in the `hugo.yml` file to the latest versions available as of time of writing. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2 parents dd89378 + 59fa7c5 commit 571d97b

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

hugo.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ module:
3535
- source: external/docs/content
3636
target: content
3737
params:
38-
hugo_version: 0.148.2
38+
hugo_version: 0.152.2
3939
pagefind_version: 1.4.0
4040
latest_version: 2.53.0
4141
latest_relnote_url: https://gitlab.com/git-scm/git/-/blob/HEAD/Documentation/RelNotes/2.53.0.adoc
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env ruby
2+
3+
require "logger"
4+
require "octokit"
5+
require "yaml"
6+
7+
$logger = Logger.new($stderr)
8+
9+
class ReleaseVersionUpdater
10+
REPOSITORIES = {
11+
"hugo_version" => "gohugoio/hugo",
12+
"pagefind_version" => "Pagefind/pagefind"
13+
}.freeze
14+
15+
class << self
16+
def update(params)
17+
REPOSITORIES.each do |key, repository|
18+
update_param(params, key, repository)
19+
end
20+
end
21+
22+
private
23+
24+
def update_param(params, key, repository)
25+
current = params[key]
26+
latest = begin
27+
release = octokit.latest_release(repository)
28+
tag_or_name = release && (release.tag_name || release.name)
29+
tag_or_name && tag_or_name.to_s.sub(/^v/, "")
30+
rescue Octokit::NotFound
31+
$logger.warn("Repository #{repository} not found")
32+
nil
33+
rescue StandardError => e
34+
$logger.error("Failed to fetch releases for #{repository}: #{e.class} - #{e.message}")
35+
nil
36+
end
37+
38+
if latest.nil?
39+
$logger.warn("No release found for #{repository}; keeping #{current.inspect}")
40+
return
41+
end
42+
43+
if current.to_s == latest.to_s
44+
$logger.info("#{key} already at #{current}")
45+
return
46+
end
47+
48+
params[key] = latest
49+
$logger.info("Updated #{key} to #{latest}")
50+
end
51+
52+
def octokit
53+
@octokit ||= Octokit::Client.new(access_token: ENV.fetch("GITHUB_API_TOKEN", nil))
54+
end
55+
end
56+
end
57+
58+
config = YAML.load_file("hugo.yml")
59+
config["params"] ||= {}
60+
ReleaseVersionUpdater.update(config["params"])
61+
yaml = YAML.dump(config).gsub(/ *$/, "")
62+
File.write("hugo.yml", yaml)

0 commit comments

Comments
 (0)