1
0
mirror of https://github.com/goreleaser/goreleaser.git synced 2025-01-26 04:22:05 +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:
Carlos Alexandro Becker 2021-02-16 19:51:11 -03:00 committed by GitHub
parent 7e385d6c99
commit 6b26fe4106
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 48 additions and 28 deletions

View File

@ -34,7 +34,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: '1.16'
-
name: Cache Go modules
uses: actions/cache@v2.1.4

View File

@ -10,7 +10,7 @@ conduct](/CODE_OF_CONDUCT.md).
Prerequisites:
- `make`
- [Go 1.15+](https://golang.org/doc/install)
- [Go 1.16+](https://golang.org/doc/install)
- [snapcraft](https://snapcraft.io/)
- [Docker](https://www.docker.com/)
- `gpg` (probably already installed on your system)

View File

@ -1,4 +1,4 @@
FROM golang:1.15-alpine
FROM golang:1.16-alpine
RUN apk add --no-cache bash \
curl \

View File

@ -58,7 +58,7 @@ func createMainGo(t testing.TB) {
func goModInit(t testing.TB) {
createFile(t, "go.mod", `module foo
go 1.15
go 1.16
`)
}

2
go.mod
View File

@ -1,6 +1,6 @@
module github.com/goreleaser/goreleaser
go 1.15
go 1.16
require (
code.gitea.io/sdk/gitea v0.13.2

View File

@ -227,7 +227,7 @@ func checkMain(build config.Build) error {
return ferr
}
if stat.IsDir() {
packs, err := parser.ParseDir(token.NewFileSet(), main, fileFilter, 0)
packs, err := parser.ParseDir(token.NewFileSet(), main, nil, 0)
if err != nil {
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)
}
// 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 {
for _, decl := range file.Decls {
fn, isFn := decl.(*ast.FuncDecl)

View File

@ -68,6 +68,7 @@ func TestWithDefaults(t *testing.T) {
"linux_386",
"linux_arm64",
"darwin_amd64",
"darwin_arm64",
},
goBinary: "go",
},

View File

@ -133,10 +133,8 @@ var (
"androidamd64",
"androidarm",
"androidarm64",
// "darwin386", - deprecated on latest go 1.15+
"darwinamd64",
// "darwinarm", - requires admin rights and other ios stuff
// "darwinarm64", - requires admin rights and other ios stuff
"darwinarm64",
"dragonflyamd64",
"freebsd386",
"freebsdamd64",

View File

@ -69,6 +69,7 @@ func TestAllBuildTargets(t *testing.T) {
"linux_mips64le_hardfloat",
"linux_riscv64",
"darwin_amd64",
"darwin_arm64",
"freebsd_386",
"freebsd_amd64",
"freebsd_arm_6",
@ -94,6 +95,7 @@ func TestGoosGoarchCombos(t *testing.T) {
{"android", "arm", true},
{"android", "arm64", true},
{"darwin", "amd64", true},
{"darwin", "arm64", true},
{"dragonfly", "amd64", true},
{"freebsd", "386", true},
{"freebsd", "amd64", true},
@ -127,7 +129,6 @@ func TestGoosGoarchCombos(t *testing.T) {
// invalid targets
{"darwin", "386", false},
{"darwin", "arm", false},
{"darwin", "arm64", false},
{"windows", "arm", false},
{"windows", "arm64", false},
{"windows", "riscv64", false},

View File

@ -276,10 +276,18 @@ func dataFor(ctx *context.Context, cfg config.Homebrew, cl client.Client, artifa
}
// TODO: refactor
if artifact.Goos == "darwin" { // nolint: nestif
if result.MacOS.DownloadURL != "" {
return result, ErrMultipleArchivesSameOS
switch artifact.Goarch {
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" {
switch artifact.Goarch {
case "amd64":

View File

@ -41,10 +41,14 @@ func TestSimpleName(t *testing.T) {
var defaultTemplateData = templateData{
Desc: "Some desc",
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",
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68",
},
MacOSArm64: downloadable{
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_arm64.tar.gz",
SHA256: "1633f61598ab0791e213135923624eb342196b349490sadasdsadsadasdasdsd",
},
LinuxAmd64: downloadable{
DownloadURL: "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz",
SHA256: "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67",
@ -99,7 +103,8 @@ func TestFullFormulae(t *testing.T) {
func TestFullFormulaeLinuxOnly(t *testing.T) {
data := defaultTemplateData
data.MacOS = downloadable{}
data.MacOSAmd64 = downloadable{}
data.MacOSArm64 = downloadable{}
data.Install = []string{`bin.install "test"`}
formulae, err := doBuildFormula(context.New(config.Project{
ProjectName: "foo",

View File

@ -18,7 +18,8 @@ type templateData struct {
Tests []string
CustomRequire string
CustomBlock []string
MacOS downloadable
MacOSAmd64 downloadable
MacOSArm64 downloadable
LinuxAmd64 downloadable
LinuxArm downloadable
LinuxArm64 downloadable
@ -44,15 +45,22 @@ class {{ .Name }} < Formula
license "{{ .License }}"
{{ end -}}
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
{{- end }}
{{- printf "\n" }}
{{- if .MacOS.DownloadURL }}
{{- if .MacOSAmd64.DownloadURL }}
if OS.mac?
url "{{ .MacOS.DownloadURL }}"
url "{{ .MacOSAmd64.DownloadURL }}"
{{- 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 }}

View File

@ -13,6 +13,10 @@ class Test < Formula
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Darwin_x86_64.tar.gz"
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c68"
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?
url "https://github.com/caarlos0/test/releases/download/v0.1.3/test_Linux_x86_64.tar.gz"
sha256 "1633f61598ab0791e213135923624eb342196b3494909c91899bcd0560f84c67"

View File

@ -34,7 +34,7 @@ jobs:
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
go-version: 1.16
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2

View File

@ -18,7 +18,7 @@ workflows:
jobs:
release:
docker:
- image: circleci/golang:1.15
- image: circleci/golang:1.16
steps:
- checkout
- run: curl -sL https://git.io/goreleaser | bash

View File

@ -23,7 +23,7 @@ steps:
BuildMyApp:
title: Compiling go code
stage: build
image: 'golang:1.15'
image: 'golang:1.16'
commands:
- go build
ReleaseMyApp: