No description
  • Shell 92%
  • Makefile 8%
Find a file
Stephen Way a57a377102
Some checks failed
test / unit (push) Successful in 4s
test / install (1.22.0) (push) Failing after 7s
test / install (stable) (push) Failing after 9s
test / version-file-and-cache (push) Failing after 8s
Fix cache key when no go.sum is present
The hash pipeline ran under pipefail, so an absent go.sum/go.mod (the
empty-hash fallback) made the final group exit nonzero and aborted
cache-key.sh. A trailing no-op keeps the group status 0.
2026-05-28 09:29:54 -07:00
.forgejo Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
.githooks Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
examples/workflows Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
scripts Fix cache key when no go.sum is present 2026-05-28 09:29:54 -07:00
tests Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
.editorconfig Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
.gitignore Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
action.yml Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
CHANGELOG.md Fix cache key when no go.sum is present 2026-05-28 09:29:54 -07:00
CONTRIBUTING.md Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
LICENSE Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
Makefile Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
MIGRATION.md Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
README.md Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00
SECURITY.md Add Forgejo-compatible setup-go action 2026-05-28 09:20:28 -07:00

setup-go-action

test

Install Go on Forgejo Actions runners from the official distribution (or a mirror you choose), and cache the module + build caches through rasterstate/cache-action. A port of actions/setup-go with no GitHub cache services and no PAT. Composite action, pure shell, no build step.

Quick start

jobs:
  test:
    runs-on: [self-hosted, Linux]
    env:
      # Only needed because cache defaults to true (drives cache-action).
      RASTER_CACHE_S3_BUCKET: ci-cache
      RASTER_CACHE_S3_ENDPOINT: https://fsn1.your-objectstorage.com
      RASTER_CACHE_S3_REGION: fsn1
      RASTER_CACHE_S3_ACCESS_KEY_ID: ${{ secrets.CACHE_S3_KEY_ID }}
      RASTER_CACHE_S3_SECRET_ACCESS_KEY: ${{ secrets.CACHE_S3_SECRET }}
    steps:
      - uses: actions/checkout@v6
      - uses: https://rasterhub.com/rasterstate/setup-go-action@v1
        with:
          go-version-file: go.mod
      - run: go build ./...
      - run: go test ./...

Inputs

Mirror actions/setup-go.

Input Default Description
go-version Exact (1.22.0), major.minor (1.22), stable, or oldstable.
go-version-file go.mod (uses the toolchain/go line) or .go-version. Auto-detects go.mod.
architecture runner arch amd64 or arm64.
cache true Cache module + build caches via cache-action.
cache-dependency-path go.sum + go.mod Files to hash for the key, one per line.
check-latest false Accepted; resolution always queries the live listing.
go-mirror https://go.dev/dl Distribution base URL (point at a mirror for air-gapped runners).

Outputs

Output Description
go-version Resolved version installed (with leading go).
cache-hit Exact cache match (empty when cache is disabled).

How it works

  • Install: resolves the version against the go.dev/dl JSON listing, downloads goX.Y.Z.<os>-<arch>.tar.gz, verifies it against the sha256 from that listing, installs into the runner tool cache, and sets GOROOT plus PATH (including GOPATH/bin). No GitHub API, no GitHub Releases.
  • Cache: when cache: true, a step resolves GOMODCACHE and GOCACHE and a go.sum-hash key, then a nested rasterstate/cache-action step restores and (in the job post step) saves them. This needs a configured cache backend (RASTER_CACHE_*).

Private modules and Forgejo-hosted repos

Set GOPRIVATE / GONOSUMDB and configure git auth for your Forgejo host, then run as usual:

- uses: https://rasterhub.com/rasterstate/setup-go-action@v1
  with:
    go-version: '1.22'
- run: go build ./...
  env:
    GOPRIVATE: rasterhub.com/*
    GIT_CONFIG_COUNT: '1'
    GIT_CONFIG_KEY_0: url.https://${{ secrets.FORGEJO_TOKEN }}@rasterhub.com/.insteadOf
    GIT_CONFIG_VALUE_0: https://rasterhub.com/

Version resolution scope

Exact, major.minor (latest patch), stable, and oldstable. The go.mod toolchain line is used when present, otherwise the go directive. See MIGRATION.md.

Examples

See examples/workflows.

License

MIT. See LICENSE.