mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-02-03 13:11:48 +02:00
feat: support go 1.16 and apple silicon (#1956)
* feat: support apple silicon Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: test Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * feat: go 1.16 Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * feat: go 1.16 Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * feat: go 1.16 Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * test: fix Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: test case Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * Update .github/workflows/build.yml Co-authored-by: Radek Simko <radek.simko@gmail.com> * docs: go 1.16 Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> Co-authored-by: Radek Simko <radek.simko@gmail.com>
This commit is contained in:
parent
7e385d6c99
commit
6b26fe4106
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -34,7 +34,7 @@ jobs:
|
|||||||
name: Set up Go
|
name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.15
|
go-version: '1.16'
|
||||||
-
|
-
|
||||||
name: Cache Go modules
|
name: Cache Go modules
|
||||||
uses: actions/cache@v2.1.4
|
uses: actions/cache@v2.1.4
|
||||||
|
@ -10,7 +10,7 @@ conduct](/CODE_OF_CONDUCT.md).
|
|||||||
Prerequisites:
|
Prerequisites:
|
||||||
|
|
||||||
- `make`
|
- `make`
|
||||||
- [Go 1.15+](https://golang.org/doc/install)
|
- [Go 1.16+](https://golang.org/doc/install)
|
||||||
- [snapcraft](https://snapcraft.io/)
|
- [snapcraft](https://snapcraft.io/)
|
||||||
- [Docker](https://www.docker.com/)
|
- [Docker](https://www.docker.com/)
|
||||||
- `gpg` (probably already installed on your system)
|
- `gpg` (probably already installed on your system)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
FROM golang:1.15-alpine
|
FROM golang:1.16-alpine
|
||||||
|
|
||||||
RUN apk add --no-cache bash \
|
RUN apk add --no-cache bash \
|
||||||
curl \
|
curl \
|
||||||
|
@ -58,7 +58,7 @@ func createMainGo(t testing.TB) {
|
|||||||
func goModInit(t testing.TB) {
|
func goModInit(t testing.TB) {
|
||||||
createFile(t, "go.mod", `module foo
|
createFile(t, "go.mod", `module foo
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -1,6 +1,6 @@
|
|||||||
module github.com/goreleaser/goreleaser
|
module github.com/goreleaser/goreleaser
|
||||||
|
|
||||||
go 1.15
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
code.gitea.io/sdk/gitea v0.13.2
|
code.gitea.io/sdk/gitea v0.13.2
|
||||||
|
@ -227,7 +227,7 @@ func checkMain(build config.Build) error {
|
|||||||
return ferr
|
return ferr
|
||||||
}
|
}
|
||||||
if stat.IsDir() {
|
if stat.IsDir() {
|
||||||
packs, err := parser.ParseDir(token.NewFileSet(), main, fileFilter, 0)
|
packs, err := parser.ParseDir(token.NewFileSet(), main, nil, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to parse dir: %s: %w", main, err)
|
return fmt.Errorf("failed to parse dir: %s: %w", main, err)
|
||||||
}
|
}
|
||||||
@ -250,11 +250,6 @@ func checkMain(build config.Build) error {
|
|||||||
return fmt.Errorf("build for %s does not contain a main function", build.Binary)
|
return fmt.Errorf("build for %s does not contain a main function", build.Binary)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: can be removed once we migrate from go 1.15 to 1.16.
|
|
||||||
func fileFilter(info os.FileInfo) bool {
|
|
||||||
return !info.IsDir()
|
|
||||||
}
|
|
||||||
|
|
||||||
func hasMain(file *ast.File) bool {
|
func hasMain(file *ast.File) bool {
|
||||||
for _, decl := range file.Decls {
|
for _, decl := range file.Decls {
|
||||||
fn, isFn := decl.(*ast.FuncDecl)
|
fn, isFn := decl.(*ast.FuncDecl)
|
||||||
|
@ -68,6 +68,7 @@ func TestWithDefaults(t *testing.T) {
|
|||||||
"linux_386",
|
"linux_386",
|
||||||
"linux_arm64",
|
"linux_arm64",
|
||||||
"darwin_amd64",
|
"darwin_amd64",
|
||||||
|
"darwin_arm64",
|
||||||
},
|
},
|
||||||
goBinary: "go",
|
goBinary: "go",
|
||||||
},
|
},
|
||||||
|
@ -133,10 +133,8 @@ var (
|
|||||||
"androidamd64",
|
"androidamd64",
|
||||||
"androidarm",
|
"androidarm",
|
||||||
"androidarm64",
|
"androidarm64",
|
||||||
// "darwin386", - deprecated on latest go 1.15+
|
|
||||||
"darwinamd64",
|
"darwinamd64",
|
||||||
// "darwinarm", - requires admin rights and other ios stuff
|
"darwinarm64",
|
||||||
// "darwinarm64", - requires admin rights and other ios stuff
|
|
||||||
"dragonflyamd64",
|
"dragonflyamd64",
|
||||||
"freebsd386",
|
"freebsd386",
|
||||||
"freebsdamd64",
|
"freebsdamd64",
|
||||||
|
@ -69,6 +69,7 @@ func TestAllBuildTargets(t *testing.T) {
|
|||||||
"linux_mips64le_hardfloat",
|
"linux_mips64le_hardfloat",
|
||||||
"linux_riscv64",
|
"linux_riscv64",
|
||||||
"darwin_amd64",
|
"darwin_amd64",
|
||||||
|
"darwin_arm64",
|
||||||
"freebsd_386",
|
"freebsd_386",
|
||||||
"freebsd_amd64",
|
"freebsd_amd64",
|
||||||
"freebsd_arm_6",
|
"freebsd_arm_6",
|
||||||
@ -94,6 +95,7 @@ func TestGoosGoarchCombos(t *testing.T) {
|
|||||||
{"android", "arm", true},
|
{"android", "arm", true},
|
||||||
{"android", "arm64", true},
|
{"android", "arm64", true},
|
||||||
{"darwin", "amd64", true},
|
{"darwin", "amd64", true},
|
||||||
|
{"darwin", "arm64", true},
|
||||||
{"dragonfly", "amd64", true},
|
{"dragonfly", "amd64", true},
|
||||||
{"freebsd", "386", true},
|
{"freebsd", "386", true},
|
||||||
{"freebsd", "amd64", true},
|
{"freebsd", "amd64", true},
|
||||||
@ -127,7 +129,6 @@ func TestGoosGoarchCombos(t *testing.T) {
|
|||||||
// invalid targets
|
// invalid targets
|
||||||
{"darwin", "386", false},
|
{"darwin", "386", false},
|
||||||
{"darwin", "arm", false},
|
{"darwin", "arm", false},
|
||||||
{"darwin", "arm64", false},
|
|
||||||
{"windows", "arm", false},
|
{"windows", "arm", false},
|
||||||
{"windows", "arm64", false},
|
{"windows", "arm64", false},
|
||||||
{"windows", "riscv64", false},
|
{"windows", "riscv64", false},
|
||||||
|
@ -276,10 +276,18 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifa
|
|||||||
}
|
}
|
||||||
// TODO: refactor
|
// TODO: refactor
|
||||||
if artifact.Goos == "darwin" { // nolint: nestif
|
if artifact.Goos == "darwin" { // nolint: nestif
|
||||||
if result.MacOS.DownloadURL != "" {
|
switch artifact.Goarch {
|
||||||
return result, ErrMultipleArchivesSameOS
|
case "amd64":
|
||||||
|
if result.MacOSAmd64.DownloadURL != "" {
|
||||||
|
return result, ErrMultipleArchivesSameOS
|
||||||
|
}
|
||||||
|
result.MacOSAmd64 = down
|
||||||
|
case "arm64":
|
||||||
|
if result.MacOSArm64.DownloadURL != "" {
|
||||||
|
return result, ErrMultipleArchivesSameOS
|
||||||
|
}
|
||||||
|
result.MacOSArm64 = down
|
||||||
}
|
}
|
||||||
result.MacOS = down
|
|
||||||
} else if artifact.Goos == "linux" {
|
} else if artifact.Goos == "linux" {
|
||||||
switch artifact.Goarch {
|
switch artifact.Goarch {
|
||||||
case "amd64":
|
case "amd64":
|
||||||
|
@ -41,10 +41,14 @@ func TestSimpleName(t *testing.T) {
|
|||||||
var defaultTemplateData = templateData{
|
var defaultTemplateData = templateData{
|
||||||
Desc: "Some desc",
|
Desc: "Some desc",
|
||||||
Homepage: "https://google.com",
|
Homepage: "https://google.com",
|
||||||
MacOS: downloadable{
|
MacOSAmd64: downloadable{
|
||||||
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz",
|
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz",
|
||||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
|
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
|
||||||
},
|
},
|
||||||
|
MacOSArm64: downloadable{
|
||||||
|
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz",
|
||||||
|
SHA256: "1633f61598ab0791e213135923624eb342196b349490sadasdsadsadasdasdsd",
|
||||||
|
},
|
||||||
LinuxAmd64: downloadable{
|
LinuxAmd64: downloadable{
|
||||||
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz",
|
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz",
|
||||||
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
|
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
|
||||||
@ -99,7 +103,8 @@ func TestFullFormulae(t *testing.T) {
|
|||||||
|
|
||||||
func TestFullFormulaeLinuxOnly(t *testing.T) {
|
func TestFullFormulaeLinuxOnly(t *testing.T) {
|
||||||
data := defaultTemplateData
|
data := defaultTemplateData
|
||||||
data.MacOS = downloadable{}
|
data.MacOSAmd64 = downloadable{}
|
||||||
|
data.MacOSArm64 = downloadable{}
|
||||||
data.Install = []string{`bin.install "test"`}
|
data.Install = []string{`bin.install "test"`}
|
||||||
formulae, err := doBuildFormula(context.New(config.Project{
|
formulae, err := doBuildFormula(context.New(config.Project{
|
||||||
ProjectName: "foo",
|
ProjectName: "foo",
|
||||||
|
@ -18,7 +18,8 @@ type templateData struct {
|
|||||||
Tests []string
|
Tests []string
|
||||||
CustomRequire string
|
CustomRequire string
|
||||||
CustomBlock []string
|
CustomBlock []string
|
||||||
MacOS downloadable
|
MacOSAmd64 downloadable
|
||||||
|
MacOSArm64 downloadable
|
||||||
LinuxAmd64 downloadable
|
LinuxAmd64 downloadable
|
||||||
LinuxArm downloadable
|
LinuxArm downloadable
|
||||||
LinuxArm64 downloadable
|
LinuxArm64 downloadable
|
||||||
@ -44,15 +45,22 @@ class {{ .Name }} < Formula
|
|||||||
license "{{ .License }}"
|
license "{{ .License }}"
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
bottle :unneeded
|
bottle :unneeded
|
||||||
{{- if and (not .MacOS.DownloadURL) (or .LinuxAmd64.DownloadURL .LinuxArm.DownloadURL .LinuxArm64.DownloadURL) }}
|
{{- if and (not .MacOSAmd64.DownloadURL) (not .MacOSArm64.DownloadURL) (or .LinuxAmd64.DownloadURL .LinuxArm.DownloadURL .LinuxArm64.DownloadURL) }}
|
||||||
depends_on :linux
|
depends_on :linux
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- printf "\n" }}
|
{{- printf "\n" }}
|
||||||
{{- if .MacOS.DownloadURL }}
|
{{- if .MacOSAmd64.DownloadURL }}
|
||||||
if OS.mac?
|
if OS.mac?
|
||||||
url "{{ .MacOS.DownloadURL }}"
|
url "{{ .MacOSAmd64.DownloadURL }}"
|
||||||
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||||
sha256 "{{ .MacOS.SHA256 }}"
|
sha256 "{{ .MacOSAmd64.SHA256 }}"
|
||||||
|
end
|
||||||
|
{{- end }}
|
||||||
|
{{- if .MacOSArm64.DownloadURL }}
|
||||||
|
if OS.mac? && Hardware::CPU.arm?
|
||||||
|
url "{{ .MacOSArm64.DownloadURL }}"
|
||||||
|
{{- if .DownloadStrategy }}, :using => {{ .DownloadStrategy }}{{- end }}
|
||||||
|
sha256 "{{ .MacOSArm64.SHA256 }}"
|
||||||
end
|
end
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
4
internal/pipe/brew/testdata/test.rb.golden
vendored
4
internal/pipe/brew/testdata/test.rb.golden
vendored
@ -13,6 +13,10 @@ class Test < Formula
|
|||||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz"
|
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz"
|
||||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68"
|
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68"
|
||||||
end
|
end
|
||||||
|
if OS.mac? && Hardware::CPU.arm?
|
||||||
|
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz"
|
||||||
|
sha256 "1633f61598ab0791e213135923624eb342196b349490sadasdsadsadasdasdsd"
|
||||||
|
end
|
||||||
if OS.linux? && Hardware::CPU.intel?
|
if OS.linux? && Hardware::CPU.intel?
|
||||||
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz"
|
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz"
|
||||||
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"
|
||||||
|
@ -34,7 +34,7 @@ jobs:
|
|||||||
name: Set up Go
|
name: Set up Go
|
||||||
uses: actions/setup-go@v2
|
uses: actions/setup-go@v2
|
||||||
with:
|
with:
|
||||||
go-version: 1.15
|
go-version: 1.16
|
||||||
-
|
-
|
||||||
name: Run GoReleaser
|
name: Run GoReleaser
|
||||||
uses: goreleaser/goreleaser-action@v2
|
uses: goreleaser/goreleaser-action@v2
|
||||||
|
@ -18,7 +18,7 @@ workflows:
|
|||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
docker:
|
docker:
|
||||||
- image: circleci/golang:1.15
|
- image: circleci/golang:1.16
|
||||||
steps:
|
steps:
|
||||||
- checkout
|
- checkout
|
||||||
- run: curl -sL https://git.io/goreleaser | bash
|
- run: curl -sL https://git.io/goreleaser | bash
|
||||||
|
@ -23,7 +23,7 @@ steps:
|
|||||||
BuildMyApp:
|
BuildMyApp:
|
||||||
title: Compiling go code
|
title: Compiling go code
|
||||||
stage: build
|
stage: build
|
||||||
image: 'golang:1.15'
|
image: 'golang:1.16'
|
||||||
commands:
|
commands:
|
||||||
- go build
|
- go build
|
||||||
ReleaseMyApp:
|
ReleaseMyApp:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user