3.0 KiB
title |
---|
Quick Start |
In this example we will build, archive and release a Golang project. Create a GitHub repository and add a single main package:
// main.go
package main
func main() {
println("Ba dum, tss!")
}
By default GoReleaser will build the current directory, but you can change the build package path in the GoReleaser configuration file.
# .goreleaser.yml
# Build customization
builds:
- binary: drum-roll
goos:
- windows
- darwin
- linux
goarch:
- amd64
PS: Invalid GOOS/GOARCH combinations will automatically be skipped.
This configuration specifies the build operating systems to Windows, Linux and
MacOS using 64bit architecture, the name of the binaries is drum-roll
.
GoReleaser will then archive the result binaries of each Os/Arch into a
separate file. The default format is {{.ProjectName}}_{{.Os}}_{{.Arch}}
.
You can change the archives name and format. You can also replace the OS
and the Architecture with your own.
Another useful feature is to add files to archives, this is very useful for
integrating assets like resource files.
# .goreleaser.yml
# Build customization
builds:
- main: main.go
binary: drum-roll
goos:
- windows
- darwin
- linux
goarch:
- amd64
# Archive customization
archive:
format: tar.gz
replacements:
amd64: 64-bit
darwin: macOS
linux: Tux
files:
- drum-roll.licence.txt
This configuration will generate tar archives, containing an additional
file called drum-roll.licence.txt
. The archives will be located in the `dist``
folder:
./dist/drum-roll_windows_64-bit.tar.gz
./dist/drum-roll_macOS_64-bit.tar.gz
./dist/drum-roll_Tux_64-bit.tar.gz
Next export a GITHUB_TOKEN
environment variable with the repo
scope
selected. This will be used to deploy releases to your GitHub repository.
Create yours here.
$ export GITHUB_TOKEN=`YOUR_TOKEN`
GoReleaser uses the latest Git tag of your repository. Create a tag and push it to GitHub:
$ git tag -a v0.1.0 -m "First release"
$ git push origin v0.1.0
Note: We recommend the use of semantic versioning. We
are not enforcing it though. We do remove the v
prefix and then enforce
that the next character is a number. So, v0.1.0
and 0.1.0
are virtually the
same and are both accepted, while version0.1.0
is not.
If you don't want to create a tag yet but instead simply create a package
based on the latest commit, then you can also use the --snapshot
flag.
Now you can run GoReleaser at the root of your repository:
$ goreleaser
That's it! Check your GitHub project's release page. The release should look like this: