Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support windows/arm64 #2407

Merged
merged 3 commits into from Aug 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/builders/golang/build.go
Expand Up @@ -59,7 +59,7 @@ func (*Builder) WithDefaults(build config.Build) (config.Build, error) {
if len(build.Gomips) == 0 {
build.Gomips = []string{"hardfloat"}
}
targets, err := matrix(build)
targets, err := matrix(build, goVersion(build))
build.Targets = targets
if err != nil {
return build, err
Expand Down
23 changes: 18 additions & 5 deletions internal/builders/golang/targets.go
@@ -1,9 +1,9 @@
package golang

import (
"bytes"
"fmt"
"os/exec"
"regexp"
"strings"

"github.com/apex/log"
Expand All @@ -25,7 +25,7 @@ func (t target) String() string {
return fmt.Sprintf("%s_%s", t.os, t.arch)
}

func matrix(build config.Build) ([]string, error) {
func matrix(build config.Build, version []byte) ([]string, error) {
// nolint:prealloc
var targets []target
// nolint:prealloc
Expand All @@ -43,13 +43,20 @@ func matrix(build config.Build) ([]string, error) {
if target.mips != "" && !contains(target.mips, validGomips) {
return result, fmt.Errorf("invalid gomips: %s", target.mips)
}
if target.os == "darwin" && target.arch == "arm64" && !isGo116(build) {
if target.os == "darwin" && target.arch == "arm64" && !go116re.Match(version) {
log.Warn(color.New(color.Bold, color.FgHiYellow).Sprintf(
"DEPRECATED: skipped darwin/arm64 build on Go < 1.16 for compatibility, check %s for more info.",
"https://goreleaser.com/deprecations/#builds-for-darwinarm64",
))
continue
}
if target.os == "windows" && target.arch == "arm64" && !go117re.Match(version) {
log.Warn(color.New(color.Bold, color.FgHiYellow).Sprintf(
"DEPRECATED: skipped windows/arm64 build on Go < 1.17 for compatibility, check %s for more info.",
"https://goreleaser.com/deprecations/#builds-for-windowsarm64",
))
continue
}
if !valid(target) {
log.WithField("target", target).Debug("skipped invalid build")
continue
Expand Down Expand Up @@ -119,9 +126,14 @@ func ignored(build config.Build, target target) bool {
return false
}

func isGo116(build config.Build) bool {
var (
go116re = regexp.MustCompile(`go version go1.1[6-9]`)
go117re = regexp.MustCompile(`go version go1.1[7-9]`)
)

func goVersion(build config.Build) []byte {
bts, _ := exec.Command(build.GoBinary, "version").CombinedOutput()
return bytes.Contains(bts, []byte("go version go1.16"))
return bts
}

func valid(target target) bool {
Expand Down Expand Up @@ -179,6 +191,7 @@ var (
"plan9arm",
"solarisamd64",
"windowsarm",
"windowsarm64",
"windows386",
"windowsamd64",
}
Expand Down
131 changes: 100 additions & 31 deletions internal/builders/golang/targets_test.go
Expand Up @@ -56,36 +56,105 @@ func TestAllBuildTargets(t *testing.T) {
},
},
}
result, err := matrix(build)
require.NoError(t, err)
require.Equal(t, []string{
"linux_386",
"linux_amd64",
"linux_arm_6",
"linux_arm64",
"linux_mips_hardfloat",
"linux_mips_softfloat",
"linux_mips64_softfloat",
"linux_mipsle_hardfloat",
"linux_mipsle_softfloat",
"linux_mips64le_hardfloat",
"linux_riscv64",
"darwin_amd64",
"darwin_arm64",
"freebsd_386",
"freebsd_amd64",
"freebsd_arm_6",
"freebsd_arm_7",
"freebsd_arm64",
"openbsd_386",
"openbsd_amd64",
"openbsd_arm64",
"windows_386",
"windows_amd64",
"windows_arm_6",
"windows_arm_7",
"js_wasm",
}, result)

t.Run("go 1.15", func(t *testing.T) {
result, err := matrix(build, []byte("go version go1.15.0"))
require.NoError(t, err)
require.Equal(t, []string{
"linux_386",
"linux_amd64",
"linux_arm_6",
"linux_arm64",
"linux_mips_hardfloat",
"linux_mips_softfloat",
"linux_mips64_softfloat",
"linux_mipsle_hardfloat",
"linux_mipsle_softfloat",
"linux_mips64le_hardfloat",
"linux_riscv64",
"darwin_amd64",
"freebsd_386",
"freebsd_amd64",
"freebsd_arm_6",
"freebsd_arm_7",
"freebsd_arm64",
"openbsd_386",
"openbsd_amd64",
"openbsd_arm64",
"windows_386",
"windows_amd64",
"windows_arm_6",
"windows_arm_7",
"js_wasm",
}, result)
})

t.Run("go 1.16", func(t *testing.T) {
result, err := matrix(build, []byte("go version go1.16.2"))
require.NoError(t, err)
require.Equal(t, []string{
"linux_386",
"linux_amd64",
"linux_arm_6",
"linux_arm64",
"linux_mips_hardfloat",
"linux_mips_softfloat",
"linux_mips64_softfloat",
"linux_mipsle_hardfloat",
"linux_mipsle_softfloat",
"linux_mips64le_hardfloat",
"linux_riscv64",
"darwin_amd64",
"darwin_arm64",
"freebsd_386",
"freebsd_amd64",
"freebsd_arm_6",
"freebsd_arm_7",
"freebsd_arm64",
"openbsd_386",
"openbsd_amd64",
"openbsd_arm64",
"windows_386",
"windows_amd64",
"windows_arm_6",
"windows_arm_7",
"js_wasm",
}, result)
})

t.Run("go 1.17", func(t *testing.T) {
result, err := matrix(build, []byte("go version go1.17.0"))
require.NoError(t, err)
require.Equal(t, []string{
"linux_386",
"linux_amd64",
"linux_arm_6",
"linux_arm64",
"linux_mips_hardfloat",
"linux_mips_softfloat",
"linux_mips64_softfloat",
"linux_mipsle_hardfloat",
"linux_mipsle_softfloat",
"linux_mips64le_hardfloat",
"linux_riscv64",
"darwin_amd64",
"darwin_arm64",
"freebsd_386",
"freebsd_amd64",
"freebsd_arm_6",
"freebsd_arm_7",
"freebsd_arm64",
"openbsd_386",
"openbsd_amd64",
"openbsd_arm64",
"windows_386",
"windows_amd64",
"windows_arm_6",
"windows_arm_7",
"windows_arm64",
"js_wasm",
}, result)
})
}

func TestGoosGoarchCombos(t *testing.T) {
Expand Down Expand Up @@ -132,11 +201,11 @@ func TestGoosGoarchCombos(t *testing.T) {
{"windows", "386", true},
{"windows", "amd64", true},
{"windows", "arm", true},
{"windows", "arm64", true},
{"js", "wasm", true},
// invalid targets
{"darwin", "386", false},
{"darwin", "arm", false},
{"windows", "arm64", false},
{"windows", "riscv64", false},
}
for _, p := range platforms {
Expand Down
26 changes: 22 additions & 4 deletions www/docs/deprecations.md
Expand Up @@ -38,6 +38,25 @@ Description.
-->

### builds for windows/arm64

> since 2021-08-16 (v0.175.0)
Since Go 1.17, `windows/arm64` is a valid target.

Prior to v0.175.0, GoReleaser would just ignore this target.
Since in Go 1.17 it is now a valid target, GoReleaser will build it if the Go version being used is 1.17 or later.

If you want to make sure it is ignored in the future, you need to add this to your build config:

```yaml
ignore:
- goos: windows
goarch: arm64
```

If you try to use new versions of GoReleaser with Go 1.16 or older, it will warn about it until this deprecation warning expires, after that your build will likely fail.

### docker.use_buildx

> since 2021-06-26 (v0.172.0)
Expand Down Expand Up @@ -76,8 +95,8 @@ Because of that, once this deprecation expires, GoReleaser will hard fail on non
Since Go 1.16, `darwin/arm64` is macOS on Apple Silicon instead of `iOS`.

Prior to v0.156.0, GoReleaser would just ignore this target, but since in Go 1.16 it is a valid target, GoReleaser will
now build it if the Go version being used is 1.16.
Prior to v0.156.0, GoReleaser would just ignore this target.
Since in Go 1.16 and later it is a valid target, GoReleaser will now build it if the Go version being used is 1.16 or later.

If you want to make sure it is ignored in the future, you need to add this to your build config:

Expand All @@ -87,8 +106,7 @@ ignore:
goarch: arm64
```

If you try to use new versions of GoReleaser with Go 1.15, it will warn about it until this deprecation warning expires.

If you try to use new versions of GoReleaser with Go 1.15 or older, it will warn about it until this deprecation warning expires, after that your build will likely fail.

## Expired deprecation notices

Expand Down