https://github.com/the-gophers/matrix-builds
Template illustrating the use of matrix builds and Go's ability to easily target multiple arch / platforms
https://github.com/the-gophers/matrix-builds
actions golang gophercon multiarch multiplatform
Last synced: about 2 months ago
JSON representation
Template illustrating the use of matrix builds and Go's ability to easily target multiple arch / platforms
- Host: GitHub
- URL: https://github.com/the-gophers/matrix-builds
- Owner: the-gophers
- License: mit
- Created: 2020-11-08T02:28:00.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-13T14:33:56.000Z (almost 5 years ago)
- Last Synced: 2025-01-27T05:51:17.518Z (9 months ago)
- Topics: actions, golang, gophercon, multiarch, multiplatform
- Language: Go
- Homepage:
- Size: 21.5 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Building, Testing and Releasing for Multiple 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.
## Getting Started
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.
### First Build
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
```
#### [cmd](./cmd)
Contains the commands for the CLI application.
#### [.github/workflows/ci.yml](./.github/workflows/ci.yml)
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.
#### [.github/workflows/release.yml](./.github/workflows/release.yml)
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.
#### [main.go](./main.go)
It's the entrypoint for the CLI application.
#### [Makefile](./Makefile)
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.
#### [scripts](./scripts)
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.
#### [xcobra](./xcobra)
Contains some extra helpers Cobra helpers that make it easier to write responsive CLI applications and
easier to test too.
## Lab Video
TODO: record and post the first lab walking through this example
## Contributions
Always welcome! Please open a PR or an issue, and remember to follow the [Gopher Code of Conduct](https://www.gophercon.com/page/1475132/code-of-conduct).