Template illustrating the use of matrix builds and Go's ability to easily target multiple arch / platforms
Template illustrating the use of matrix builds and Go’s ability to easily target multiple arch / platforms.
In this example you will learn about resources for verifying your software across multiple platforms and
architectures concurrently, how to properly inject version information into Go binaries via a release
workflow, and how to create an automated release with artifacts spanning multiple platforms and architectures.
This is a GitHub template repo, so when you click “Use this template”, it will create a new copy of this
template in your org or personal repo of choice. Once you have created a repo from this template, you
should be able to clone and navigate to the root of the repository.
From the root of your repo, you should be able to run the following to build and test the Go action.
```shell script
$ make
$ ./bin/gophers version
### What's in Here?
A command line application which we will add some functionality.
```shell script
.
├── cmd
│ ├── add.go
│ ├── root.go
│ └── version.go
├── .github
│ └── workflows
│ ├── ci.yml
│ └── release.yml
├── .gitignore
├── go.mod
├── go.sum
├── LICENSE
├── main.go
├── Makefile
├── README.md
├── scripts
│ └── go_install.sh
└── xcobra
├── context.go
├── exit_handler.go
└── noop_handler.go
Contains the commands for the CLI application.
Contains a continuous integration workflow which targets multiple platforms and multiple versions of Go
to create a matrix of machines which will be used to verify the application.
We’ll also discuss how to optimize our builds through caching of module dependencies and other little
tricks.
Contains a release workflow which will show how to build release Go applications with a stamped version
for a variety of platforms and architectures. We’ll also show how to reference a step in a workflow
to add artifacts to a release.
It’s the entrypoint for the CLI application.
Contains a lot of the build foo. Generally, you shouldn’t have to change this, but it wouldn’t hurt
to familiarize yourself with the contents.
Contains a helper to install Go build tools in a tmp dir with an ephemeral Go module. This is nice
for when you want to install a build tool, but you don’t want to dirty up your go.mod file.
Contains some extra helpers Cobra helpers that make it easier to write responsive CLI applications and
easier to test too.
TODO: record and post the first lab walking through this example
Always welcome! Please open a PR or an issue, and remember to follow the Gopher Code of Conduct.