GoReleaser需要一个GitHub API token ,其具有选择repo范围,具有部署到GitHub的权限。你可以创建一个点-这里.
此token应添加到环境变量中GITHUB_TOKEN.以下是Travis CI的使用方法:在存储库设置中,定义环境变量.
或者,您可以在文件中提供GitHub令牌。默认情况下,GoReleaser会查看~/.config/goreleaser/github_token,您可以在.goreleaser.yml文件中更改它:
# .goreleaser.yml
env_files:
github_token: ~/.path/to/my/token要使用GitHub Enterprise,你需要提供其URL搭配.goreleaser.yml配置文件,给予GoReleaser使用:
# .goreleaser.yml
github_urls:
api: https://git.company.com/api/v3/
upload: https://git.company.com/api/uploads/
download: https://git.company.com/如果没有设置,则默认为GitHub的公共URL.
重要:小心URL,它们可能会从一个安装更改为另一个安装。如果他们错了,goreleaser会在某些时候失败,所以,在开启Issue之前,确保他们是对的。例如,参见#472.
默认情况下,GoReleaser将在./dist中创建其二进制存档。如有必须,可以通过在.goreleaser.yml文件的设置,更改它:
# .goreleaser.yml
dist: another-folder-that-is-not-distmain.version默认的GoReleaser设置三个ldflags:
main.version: 当前的Git标签(v前缀被剥离)或snapshot的名称,若正在使用--snapshot参数main.commit: 当前git commit 的 SHA码main.date: RFC3339规范日期这样,在你的main.go文件,就能被使用:
package main
import "fmt"
var (
version = "dev"
commit = "none"
date = "unknown"
)
func main() {
fmt.Printf("%v, commit %v, built at %v", version, commit, date)
}您可以通过更改build部分的ldflags选项,来覆盖它.