Skip to content

Commit 9c9413f

Browse files
authored
Fix deploy by locking Hugo version via Pixi (#43)
I noticed that Guido's name is correctly written with "van" at https://python.github.io/editorial-board/members/ but incorrectly with "Van" at https://python.github.io/editorial-board/members/guido-van-rossum/ This has been fixed, but still on prod because the GitHub Actions deploys are failing because it tries to install Hugo 0.128.0 but 0.146.0 is now required: ``` ERROR => hugo v0.146.0 or greater is required for hugo-PaperMod to build ``` https://github.com/python/editorial-board/actions/runs/27371770982 The Netlify previews are okay, because it defines the version separately and was bumped to 0.160.1. This PR uses Pixi for reproducible builds: it pins the dependency versions, and then uses Pixi to to build on both GitHub Actions and Netlify using the same versions. This can also be used locally to ensure the same versions. This is similar to what I do at https://github.com/hugovk/hugovk.github.io.
1 parent b28de9c commit 9c9413f

8 files changed

Lines changed: 478 additions & 28 deletions

File tree

‎.github/workflows/hugo.yaml‎

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Workflow for deploying the site to GitHub Pages
2-
# Copied from: https://gohugo.io/hosting-and-deployment/hosting-on-github/
2+
# The Hugo toolchain (Hugo extended + Go) is pinned by pixi.toml / pixi.lock,
3+
# so this workflow just bootstraps pixi and runs the shared build task.
34
name: Deploy Hugo site to Pages
45

56
on:
@@ -32,15 +33,7 @@ jobs:
3233
# Build job
3334
build:
3435
runs-on: ubuntu-latest
35-
env:
36-
HUGO_VERSION: 0.160.1
3736
steps:
38-
- name: Install Hugo CLI
39-
run: |
40-
wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
41-
&& sudo dpkg -i ${{ runner.temp }}/hugo.deb
42-
- name: Install Dart Sass
43-
run: sudo snap install dart-sass
4437
- name: Checkout
4538
uses: actions/checkout@v4
4639
with:
@@ -49,18 +42,24 @@ jobs:
4942
- name: Setup Pages
5043
id: pages
5144
uses: actions/configure-pages@v5
52-
- name: Install Node.js dependencies
53-
run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
45+
- name: Set up Pixi
46+
uses: prefix-dev/setup-pixi@v0.9.6
47+
with:
48+
locked: true
49+
cache: true
50+
- name: Cache Hugo resources
51+
uses: actions/cache@v5
52+
with:
53+
path: /tmp/hugo_cache
54+
key: hugo-${{ hashFiles('go.sum', 'hugo.yaml') }}
55+
restore-keys: |
56+
hugo-
5457
- name: Build with Hugo
5558
env:
56-
HUGO_CACHEDIR: ${{ runner.temp }}/hugo_cache
59+
HUGO_CACHEDIR: /tmp/hugo_cache
5760
HUGO_ENVIRONMENT: production
58-
TZ: America/Los_Angeles
5961
run: |
60-
hugo \
61-
--gc \
62-
--minify \
63-
--baseURL "${{ steps.pages.outputs.base_url }}/"
62+
pixi run build --baseURL "${{ steps.pages.outputs.base_url }}/"
6463
- name: Upload artifact
6564
uses: actions/upload-pages-artifact@v3
6665
with:

‎.gitignore‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Hugo build output
2+
/public/
3+
/resources/_gen/
4+
.hugo_build.lock
5+
6+
# pixi environments (pixi.lock is committed; the env dir is not)
7+
.pixi/

‎README.md‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,16 @@ of the Python Docs Editorial Board. If a member did not attend the meeting, remo
6161

6262
## Building the static site locally
6363

64-
1. First install Hugo.
64+
1. First [install pixi](https://pixi.sh/latest/#installation), which pins the Hugo toolchain.
6565

66-
2. Run the command at the root of the repository:
66+
2. Run the dev server at the root of the repository:
6767

6868
```
69-
hugo server
69+
pixi run serve
7070
```
7171

72+
Use `pixi run build` to build the production site into `public/`.
73+
7274
## Writing new changelog
7375

7476
Use the template in [archetypes/changelog.md](archetypes/changelog.md).

‎go.sum‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/adityatelange/hugo-PaperMod v0.0.0-20260510052646-154d006e0182 h1:wKy2+NZXtaj3qjFwoj4RZfouaAxCAY/oY9iiUmGlCZE=
2+
github.com/adityatelange/hugo-PaperMod v0.0.0-20260510052646-154d006e0182/go.mod h1:sp5WH671pzcVNpWKveBQKlBfu6T9uvcBI/4B3BSojKw=

‎hugo.yaml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ menu:
101101
module:
102102
hugoVersion:
103103
extended: true
104-
min: 0.110.0
104+
min: 0.146.0
105105
imports:
106106
- path: github.com/adityatelange/hugo-PaperMod
107107
disable: false

‎netlify.toml‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
1+
# Netlify builds PR previews only; production deploys via GitHub Pages.
2+
# The Hugo toolchain (Hugo extended + Go) is pinned by pixi.toml / pixi.lock.
3+
# Netlify has no pixi preinstalled, so each build bootstraps it, then runs the
4+
# same pixi tasks the GitHub Pages workflow uses.
5+
16
[build]
27
publish = "public"
3-
command = "hugo --gc --minify"
4-
5-
[build.environment]
6-
HUGO_VERSION = "0.160.1"
8+
command = "curl -fsSL https://pixi.sh/install.sh | bash && export PATH=\"$HOME/.pixi/bin:$PATH\" && pixi run --locked build"
79

810
[context.production.environment]
911
HUGO_ENV = "production"
1012
HUGO_ENABLEGITINFO = "true"
1113

1214
[context.split1]
13-
command = "hugo --gc --minify --enableGitInfo"
15+
command = "curl -fsSL https://pixi.sh/install.sh | bash && export PATH=\"$HOME/.pixi/bin:$PATH\" && pixi run --locked build --enableGitInfo"
1416

1517
[context.split1.environment]
1618
HUGO_ENV = "production"
1719

1820
[context.deploy-preview]
19-
command = "hugo --gc --minify --buildFuture -b $DEPLOY_PRIME_URL"
21+
command = "curl -fsSL https://pixi.sh/install.sh | bash && export PATH=\"$HOME/.pixi/bin:$PATH\" && pixi run --locked preview -b $DEPLOY_PRIME_URL"
2022

2123
[context.branch-deploy]
22-
command = "hugo --gc --minify -b $DEPLOY_PRIME_URL"
24+
command = "curl -fsSL https://pixi.sh/install.sh | bash && export PATH=\"$HOME/.pixi/bin:$PATH\" && pixi run --locked branch -b $DEPLOY_PRIME_URL"
2325

2426
[context.next.environment]
2527
HUGO_ENABLEGITINFO = "true"

0 commit comments

Comments
 (0)