Skip to content

Instantly share code, notes, and snippets.

@moisoto
Created December 7, 2023 23:12
Show Gist options
  • Save moisoto/e578a12a21a0f5656fa83240e1dd3a69 to your computer and use it in GitHub Desktop.
Save moisoto/e578a12a21a0f5656fa83240e1dd3a69 to your computer and use it in GitHub Desktop.
GitHub - Publishing you Go Package

Publishing your Package

Go Module!

If you haven't already go and make your package a module:

# This assumes you have your package located at ~/go/src/github.com/your_account/your_package
go mod init github.com/your_account/your_package
go mod tidy

This will create the following files:

go.sum
go.mod

If you have a remote then is best to commit this and push it:

git add go.mod go.sum
git commit -m "Initialize Go Module."
git push

Tag your version

You can tag your package version using the git tag command:

git tag -a v1.0.0 -m "Version 1.0.0"

To see your tag information:

# Just the Tags
git tag -n

# More detailed info
git show v1.0.0

Push the tag to ORIGIN:

git push origin v1.0.0

If you want to undo your tag for some reason:

git tag -d v1.0.0
git push --delete origin v1.0.0

# Or this way??? (need to check)
git push origin :refs/tags/v1.0.0
git tag -d v1.0.0

Add Version Badge

It's recommended that you put a badge in your README.md to let users know what's the latest release:

[![Release](https://img.shields.io/github/v/tag/your_user/your_repo?label=Release&sort=semver)](https://github.com/your_user/your_repo/releases/latest)

Check and Refresh your public documentation

First go to proxy.golang.org and fech your new version info:

https://proxy.golang.org/github.com/your_user/your_repo/@v/v1.0.0.info

Then check that the documentation was refreshed. If not, check if there's a "Request" button and click it:

https://pkg.go.dev/github.com/your_user/your_repo

Some useful links:

Basic Tagging

How to Crate Git Tags

How to Delete Local and Remore Tags on Git

About Go.dev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment