go-project-template

Deploy

Build

Compile the app as a single binary in the unversioned build directory.

$ make build

Run the build:

$ build/myapp -h

You can share that binary with others to download and run.

For example, add the binary to a GitHub release as an asset and add Download button in your docs. That will make it easy for someone to download from GitHub.

Note that a binary is specific to an OS and architecture (e.g. Windows 64-bit). Though Go CLI lets you build release for multiple architectures.

Install globally

It can be useful to install the app globally and then use it a bit before releasing it.

See the Install globally doc.

CI flow

This project used GitHub Actions for CI.

See the workflow config. This builds the app on pushes.

Nothing is persisted. For info on using CI to build and release your assets, see this guide.

Release steps

Manual

  1. Push any unpushed changes.
  2. Check that the GH Actions workflow run was successful. See CI flow below.
  3. Local steps:
    1. Increment the version number in main.go.
    2. Commit as “Bump version number”.
    3. Tag the commit.
    4. Build a binary file (this will include the version number in its help output). See Build section below.
    5. Zip the file
    6. Rename the zip file. e.g. for macOS: go_project_template_0.4.0_darwin.tar.gz.
    7. Test the file.
    8. Push the commits. and the tag.
  4. Create a Release on GitHub.
  5. Upload the binary file as a asset on the Release.

Automated

The Go Releaser action be used so that GitHub Actions will create a GH release and add built assets to it whenever a tag is pushed.

See my Go Releaser recipe for more info.