Skip to content

Commit 7efb41b

Browse files
committed
util: Cache Hugo between builds
1 parent 32b83e2 commit 7efb41b

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

.github/workflows/pull_request.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,19 @@ jobs:
4343
run: make js.deps
4444
- name: Editor config
4545
uses: snow-actions/[email protected]
46+
- name: Initialize Hugo binary cache
47+
uses: actions/cache@v2
48+
with:
49+
path: hugo.linux
50+
key: ${{ runner.os }}-hugo-${{ hashFiles('**/go.sum') }}
51+
restore-keys: |
52+
${{ runner.os }}-hugo-
53+
- name: Build Hugo binary
54+
run: make hugo.linux
4655
- name: Build docs
4756
run: make build.public
4857
env:
58+
HUGO: ./hugo.linux
4959
HUGO_BASE_URL: https://thethingsstack.io/
5060
HUGO_GOOGLEANALYTICS: ${{ secrets.HUGO_GOOGLEANALYTICS }}
5161
HUGO_PARAMS_FEEDBACK_CAMPAIGN: ${{ secrets.HUGO_PARAMS_FEEDBACK_CAMPAIGN }}

.github/workflows/release.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,19 @@ jobs:
4646
${{ runner.os }}-yarn-
4747
- name: Download Yarn dependencies
4848
run: make js.deps
49+
- name: Initialize Hugo binary cache
50+
uses: actions/cache@v2
51+
with:
52+
path: hugo.linux
53+
key: ${{ runner.os }}-hugo-${{ hashFiles('**/go.sum') }}
54+
restore-keys: |
55+
${{ runner.os }}-hugo-
56+
- name: Build Hugo binary
57+
run: make hugo.linux
4958
- name: Build docs
5059
run: make build.public
5160
env:
61+
HUGO: ./hugo.linux
5262
HUGO_BASE_URL: https://thethingsstack.io/
5363
HUGO_GOOGLEANALYTICS: ${{ secrets.HUGO_GOOGLEANALYTICS }}
5464
HUGO_PARAMS_FEEDBACK_CAMPAIGN: ${{ secrets.HUGO_PARAMS_FEEDBACK_CAMPAIGN }}

Makefile

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@
1313
# limitations under the License.
1414

1515
GO = go
16-
HUGO = $(GO) run -tags extended github.com/gohugoio/hugo
16+
HUGO_BUILD_FLAGS = -tags extended
17+
HUGO_MODULE = github.com/gohugoio/hugo
18+
HUGO ?= $(GO) run $(HUGO_BUILD_FLAGS) $(HUGO_MODULE)
1719
YARN_DEPS = doc/themes/the-things-stack/node_modules
1820
FREQUENCY_PLAN_URL ?= \
1921
https://raw.githubusercontent.com/TheThingsNetwork/lorawan-frequency-plans/master/frequency-plans.yml
@@ -78,6 +80,15 @@ $(YARN_DEPS):
7880
fi
7981
yarn --cwd doc/themes/the-things-stack/
8082

83+
hugo.exe: go.mod go.sum
84+
GOOS=windows go build -o $@ $(HUGO_BUILD_FLAGS) $(HUGO_MODULE)
85+
86+
hugo.darwin: go.mod go.sum
87+
GOOS=darwin go build -o $@ $(HUGO_BUILD_FLAGS) $(HUGO_MODULE)
88+
89+
hugo.linux: go.mod go.sum
90+
GOOS=linux go build -o $@ $(HUGO_BUILD_FLAGS) $(HUGO_MODULE)
91+
8192
.PHONY: hooks
8293
hooks:
8394
ifeq (,$(wildcard .git/hooks/commit-msg))

0 commit comments

Comments
 (0)