GoReleaser

  • https://github.com/goreleaser/goreleaser


自动化打包工具


安装

  • https://github.com/goreleaser/goreleaser/releases


使用

在目标目录执行 goreleaser init ,将会生成一个 .goreleaser.yml 配置文件

修改配置,例如

# This is an example .goreleaser.yml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
  hooks:
    # You may remove this if you don't use go modules.
    #- go mod tidy
    # you may remove this if you don't need go generate
    #- go generate ./...
builds:
  - env:
      - CGO_ENABLED=0
    id: "anewproject"
    binary: "anew"
    goos:
      - linux
      - windows
      - darwin
    goarch:
      - amd64
archives:
  - replacements:
      darwin: Darwin
      linux: Linux
      windows: Windows
      386: i386
      amd64: x86_64
checksum:
  name_template: 'checksums.txt'
snapshot:
  name_template: "v1.0.0-snapshot"
changelog:
  sort: asc
  filters:
    exclude:
      - '^docs:'
      - '^test:'

打包

这里可能会提示

直接

再运行一遍就可以了

如果提示一下报错

添加一行就行

main.go 不在根目录的情况