Skip to content

Commit ceb1a3d

Browse files
Add guards if Hugo submodule version doesn't match
1 parent 279b25a commit ceb1a3d

5 files changed

Lines changed: 43 additions & 3 deletions

File tree

.github/update-hugo.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ https://github.com/gohugoio/hugo/releases/tag/v${LATEST_VERSION}
1212

1313
### Release checklist
1414

15+
- [ ] Confirm the `hugo-src` submodule is at the correct tag (`git submodule status` should show `v${LATEST_VERSION}`)
1516
- [ ] Check the release notes for any interesting changes, and if the Go version has been updated (if so, update the Go version in `ci.yml`, `cd.yml`, and `docs/go.mod` manually)
1617
- [ ] Merge this PR
1718
- [ ] Run `nox -s tag -- v${LATEST_VERSION}` locally to create a signed tag

.github/workflows/cd.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,12 @@ jobs:
399399
VERSION="${TAG#v}"
400400
401401
# Select template based on whether this is a patch release
402+
# A fourth version component would mean that it's a patch
403+
# release for hugo-python-distributions to fix a problem
404+
# with a stable/patch release of Hugo
402405
PATCH=$(echo "$VERSION" | cut -d. -f3)
403-
if [ "$PATCH" -gt 0 ]; then
406+
PKG_PATCH=$(echo "$VERSION" | cut -d. -f4)
407+
if [ "$PATCH" -gt 0 ] || [ -n "$PKG_PATCH" ]; then
404408
TEMPLATE="release_notes/patch.md"
405409
else
406410
TEMPLATE="release_notes/stable.md"

.github/workflows/update-hugo.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,14 @@ jobs:
6868
git checkout "v$LATEST_VERSION"
6969
cd ..
7070
71+
# Verify the submodule HEAD is exactly at the expected tag
72+
SUBMODULE_TAG=$(git -C hugo-src describe --tags --exact-match HEAD)
73+
if [ "$SUBMODULE_TAG" != "v$LATEST_VERSION" ]; then
74+
echo "ERROR: submodule tag '$SUBMODULE_TAG' does not match 'v$LATEST_VERSION'"
75+
exit 1
76+
fi
77+
echo "Submodule verified at $SUBMODULE_TAG"
78+
7179
echo "updated=true" >> "$GITHUB_OUTPUT"
7280
echo "latest_version=$LATEST_VERSION" >> "$GITHUB_OUTPUT"
7381
echo "current_version=$CURRENT_VERSION" >> "$GITHUB_OUTPUT"

hugo-src

Submodule hugo-src updated 394 files

meson.build

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project(
22
'hugo-python-distributions',
3-
version : '0.162.0',
3+
version : '0.162.0.1',
44
meson_version : '>=1.3.0',
55
default_options : ['warning_level=0'],
66
)
@@ -15,6 +15,33 @@ py = import('python').find_installation(pure: true)
1515
go = find_program('go', required: true)
1616
git = find_program('git', required: true)
1717

18+
# Verify the hugo-src submodule tag matches the declared version at configure time
19+
fs = import('fs')
20+
_hugo_src = meson.project_source_root() / 'hugo-src'
21+
_hugo_tag = ''
22+
if fs.is_file(_hugo_src / '.git') or fs.is_dir(_hugo_src / '.git')
23+
_r = run_command(
24+
git, '-C', _hugo_src, 'describe', '--tags', '--exact-match', 'HEAD',
25+
check: false,
26+
capture: true,
27+
)
28+
if _r.returncode() == 0
29+
_hugo_tag = _r.stdout().strip()
30+
endif
31+
endif
32+
if _hugo_tag != ''
33+
# We need some special handling so that we can have a different X.Y.Z.W version scheme for
34+
# the Python package than the Hugo versioning scheme of X.Y.Z. The submodule is expected to
35+
# be tagged with 'vX.Y.Z' matching the first three components of the meson.build version.
36+
version = meson.project_version().split('.')
37+
_expected_hugo_tag = 'v' + version[0] + '.' + version[1] + '.' + version[2]
38+
if _hugo_tag != _expected_hugo_tag
39+
error(
40+
'the hugo-src submodule is at \'' + _hugo_tag + '\' but meson.build declares v' + meson.project_version()
41+
)
42+
endif
43+
endif
44+
1845
configure_file(
1946
input : 'src/hugo/_version.py.in',
2047
output : '_version.py',

0 commit comments

Comments
 (0)