peaceiris / actions-hugo

GitHub Actions for Hugo ⚡️ Setup Hugo quickly and build your site fast. Hugo extended, Hugo Modules, Linux (Ubuntu), macOS, and Windows are supported.
https://github.com/marketplace/actions/hugo-setup
MIT License
1.37k stars 80 forks source link

support: Setting actions go version #640

Open c4dr01d opened 8 months ago

c4dr01d commented 8 months ago

Checklist

Describe your question

Hi, I'm deploy my hugo blog with hugo modules, when I write the actions and push to repository, the build log report the go version is mismatched, detail in the log out section. I want to set go version to 1.23, have any option can let it work?

Relevant links

Public repository: [My project repository](https://github.com/c4dr01d/c4dr01d.github.io)
YAML config: [The yaml config](https://github.com/c4dr01d/c4dr01d.github.io/blob/master/.github/workflows/main.yml)
YAML workflow: [Build](https://github.com/c4dr01d/c4dr01d.github.io/blob/master/.github/workflows/main.yml#L37)

Relevant log output

Run hugo --minify
  hugo --minify
  shell: /usr/bin/bash -e {0}
go: errors parsing go.mod:
Total in 50 ms
Error: failed to load modules: failed to download modules: failed to execute 'go [mod download -modcacherw]': failed to execute binary "go" with args [mod download -modcacherw]: go: errors parsing go.mod:
/home/runner/work/c4dr01d.github.io/c4dr01d.github.io/go.mod:3: invalid go version '1.[2](https://github.com/c4dr01d/c4dr01d.github.io/actions/runs/6610778012/job/17953372400#step:6:2)1.[3](https://github.com/c4dr01d/c4dr01d.github.io/actions/runs/6610778012/job/17953372400#step:6:3)': must match format 1.23
 *errors.errorString
/home/runner/work/c[4](https://github.com/c4dr01d/c4dr01d.github.io/actions/runs/6610778012/job/17953372400#step:6:5)dr01d.github.io/c4dr01d.github.io/go.mod:3: invalid go version '1.21.3': must match format 1.23
Error: Process completed with exit code 1.

Additional context.

No any other context about this question

128keaton commented 8 months ago

Having the same issue. macOS doesn't have a built binary for 1.23, just 1.21. As a workaround, I added this build step:

      - name: Swap Go Version
        run: sed -i -e 's/1.21.1/1.23/g' go.mod