mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-01-20 03:59:26 +02:00
feat: support windows/arm64 (#2407)
* feat: support windows/arm64 closes #2404 closes #2405 Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * fix: broken test Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com> * docs: deprecation warnings Signed-off-by: Carlos Alexandro Becker <caarlos0@gmail.com>
This commit is contained in:
parent
d329a9c0d3
commit
a813644522
@ -59,7 +59,7 @@ func (*Builder) WithDefaults(build config.Build) (config.Build, error) {
|
|||||||
if len(build.Gomips) == 0 {
|
if len(build.Gomips) == 0 {
|
||||||
build.Gomips = []string{"hardfloat"}
|
build.Gomips = []string{"hardfloat"}
|
||||||
}
|
}
|
||||||
targets, err := matrix(build)
|
targets, err := matrix(build, goVersion(build))
|
||||||
build.Targets = targets
|
build.Targets = targets
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return build, err
|
return build, err
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package golang
|
package golang
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/apex/log"
|
"github.com/apex/log"
|
||||||
@ -25,7 +25,7 @@ func (t target) String() string {
|
|||||||
return fmt.Sprintf("%s_%s", t.os, t.arch)
|
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
|
// nolint:prealloc
|
||||||
var targets []target
|
var targets []target
|
||||||
// nolint:prealloc
|
// nolint:prealloc
|
||||||
@ -43,13 +43,20 @@ func matrix(build config.Build) ([]string, error) {
|
|||||||
if target.mips != "" && !contains(target.mips, validGomips) {
|
if target.mips != "" && !contains(target.mips, validGomips) {
|
||||||
return result, fmt.Errorf("invalid gomips: %s", target.mips)
|
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(
|
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.",
|
"DEPRECATED: skipped darwin/arm64 build on Go < 1.16 for compatibility, check %s for more info.",
|
||||||
"https://goreleaser.com/deprecations/#builds-for-darwinarm64",
|
"https://goreleaser.com/deprecations/#builds-for-darwinarm64",
|
||||||
))
|
))
|
||||||
continue
|
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) {
|
if !valid(target) {
|
||||||
log.WithField("target", target).Debug("skipped invalid build")
|
log.WithField("target", target).Debug("skipped invalid build")
|
||||||
continue
|
continue
|
||||||
@ -119,9 +126,14 @@ func ignored(build config.Build, target target) bool {
|
|||||||
return false
|
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()
|
bts, _ := exec.Command(build.GoBinary, "version").CombinedOutput()
|
||||||
return bytes.Contains(bts, []byte("go version go1.16"))
|
return bts
|
||||||
}
|
}
|
||||||
|
|
||||||
func valid(target target) bool {
|
func valid(target target) bool {
|
||||||
@ -179,6 +191,7 @@ var (
|
|||||||
"plan9arm",
|
"plan9arm",
|
||||||
"solarisamd64",
|
"solarisamd64",
|
||||||
"windowsarm",
|
"windowsarm",
|
||||||
|
"windowsarm64",
|
||||||
"windows386",
|
"windows386",
|
||||||
"windowsamd64",
|
"windowsamd64",
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,41 @@ func TestAllBuildTargets(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
result, err := matrix(build)
|
|
||||||
|
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.NoError(t, err)
|
||||||
require.Equal(t, []string{
|
require.Equal(t, []string{
|
||||||
"linux_386",
|
"linux_386",
|
||||||
@ -86,6 +120,41 @@ func TestAllBuildTargets(t *testing.T) {
|
|||||||
"windows_arm_7",
|
"windows_arm_7",
|
||||||
"js_wasm",
|
"js_wasm",
|
||||||
}, result)
|
}, 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) {
|
func TestGoosGoarchCombos(t *testing.T) {
|
||||||
@ -132,11 +201,11 @@ func TestGoosGoarchCombos(t *testing.T) {
|
|||||||
{"windows", "386", true},
|
{"windows", "386", true},
|
||||||
{"windows", "amd64", true},
|
{"windows", "amd64", true},
|
||||||
{"windows", "arm", true},
|
{"windows", "arm", true},
|
||||||
|
{"windows", "arm64", true},
|
||||||
{"js", "wasm", true},
|
{"js", "wasm", true},
|
||||||
// invalid targets
|
// invalid targets
|
||||||
{"darwin", "386", false},
|
{"darwin", "386", false},
|
||||||
{"darwin", "arm", false},
|
{"darwin", "arm", false},
|
||||||
{"windows", "arm64", false},
|
|
||||||
{"windows", "riscv64", false},
|
{"windows", "riscv64", false},
|
||||||
}
|
}
|
||||||
for _, p := range platforms {
|
for _, p := range platforms {
|
||||||
|
@ -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
|
### docker.use_buildx
|
||||||
|
|
||||||
> since 2021-06-26 (v0.172.0)
|
> since 2021-06-26 (v0.172.0)
|
||||||
@ -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`.
|
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
|
Prior to v0.156.0, GoReleaser would just ignore this target.
|
||||||
now build it if the Go version being used is 1.16.
|
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:
|
If you want to make sure it is ignored in the future, you need to add this to your build config:
|
||||||
|
|
||||||
@ -87,8 +106,7 @@ ignore:
|
|||||||
goarch: arm64
|
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
|
## Expired deprecation notices
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user