Publish Go modules via Git tags
Unlike other ecosystems, Go doesn't have a traditional package registry that you push to. Instead:
v1.2.3)proxy.golang.org) automatically fetches and caches your modulego get your new versionRelease Pilot handles creating and pushing tags automatically:
permissions:
contents: write
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: a-line-services/release-pilot@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
In your .github/release-pilot.yml:
ecosystem: go
versionFile: go.mod
tagPrefix: v
go.mod. Release Pilot uses the file only for ecosystem detection. Versions come entirely from Git tags.
For private repositories, users need to configure their Go environment:
# Users of your private module need to set:
go env -w GOPRIVATE=github.com/your-org/*
Users also need Git authentication for private repos:
# Option 1: SSH
git config --global url."git@github.com:".insteadOf "https://github.com/"
# Option 2: Personal Access Token
git config --global url."https://${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/"
For repositories with multiple Go modules, use submodule prefixes in tags:
# Module at repo root
v1.2.3
# Module in subdirectory "pkg/foo"
pkg/foo/v1.2.3
Configure the tag prefix in Release Pilot:
ecosystem: go
versionFile: pkg/foo/go.mod
tagPrefix: pkg/foo/v
Go's module system requires special handling for major versions >= 2:
/v2 (or /v3, etc.) suffix to your module path in go.modv2, v3, etc.)# go.mod for v2+
module github.com/your-org/your-module/v2
go 1.21
After pushing a tag, the module proxy caches your version when someone first requests it. To pre-warm the cache:
# Add this step after release-pilot
- name: Warm proxy cache
run: |
GOPROXY=https://proxy.golang.org go list -m github.com/your-org/your-module@${{ steps.release.outputs.version }}
module github.com/your-org/your-module
go 1.21
After Release Pilot creates a tag, verify it's available:
# Check on pkg.go.dev
https://pkg.go.dev/github.com/your-org/your-module@v1.2.3
# Or via command line
go list -m -versions github.com/your-org/your-module