feat(monorel): separate Windows builds and full goamd64 v1-v4 matrix

Go 1.23+ changed Windows target naming so x86_64 builds now carry a
micro-architecture suffix (e.g. _v2).  Update the goreleaser YAML
generator and monorel's own .goreleaser.yaml to match:

- Remove windows from defaultGoos/almostAllGoos; emit a dedicated
  <name>-windows build entry per binary.  Windows is kept in a separate
  build because it does not support ARM v6/v7, so it cannot share the
  same goarch matrix as non-Windows builds.
- Add defaultWindowsGoarch [amd64, arm64] and almostAllWindowsGoarch
  [386, amd64, arm64] for the Windows-specific architecture lists.
- Promote defaultGoamd64 from [v1, v2] to [v1, v2, v3, v4] so the
  full amd64 micro-architecture matrix is always generated.
- Update the archive name_template to include
  {{ if .Amd64 }}_{{ .Amd64 }}{{ end }} after x86_64.
- Include both <name> and <name>-windows in archive ids.
- Regenerate tools/monorel/.goreleaser.yaml and
  cmd/sql-migrate/.goreleaser.yaml with the new format.
This commit is contained in:
AJ ONeal 2026-03-23 11:59:25 -06:00
parent 690cf90d67
commit 7b21379a49
No known key found for this signature in database
3 changed files with 102 additions and 27 deletions

View File

@ -29,7 +29,6 @@ builds:
- netbsd - netbsd
- openbsd - openbsd
- wasip1 - wasip1
- windows
goarch: goarch:
- amd64 - amd64
- arm - arm
@ -45,17 +44,35 @@ builds:
goamd64: goamd64:
- v1 - v1
- v2 - v2
- v3
- v4
- id: sql-migrate-windows
binary: sql-migrate
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
goos:
- windows
goarch:
- amd64
- arm64
goamd64:
- v1
- v2
- v3
- v4
archives: archives:
- id: sql-migrate - id: sql-migrate
ids: [sql-migrate] ids: [sql-migrate, sql-migrate-windows]
formats: [tar.gz, tar.zst] formats: [tar.gz, tar.zst]
# this name template makes the OS and Arch compatible with the results of `uname`. # this name template makes the OS and Arch compatible with the results of `uname`.
# it uses the VERSION env var so the prefixed monorepo tag doesn't appear in archive filenames. # it uses the VERSION env var so the prefixed monorepo tag doesn't appear in archive filenames.
name_template: >- name_template: >-
sql-migrate_{{ .Env.VERSION }}_ sql-migrate_{{ .Env.VERSION }}_
{{- title .Os }}_ {{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64 {{- if eq .Arch "amd64" }}x86_64{{ if .Amd64 }}_{{ .Amd64 }}{{ end }}
{{- else if eq .Arch "386" }}i386 {{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }} {{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }}

View File

@ -34,34 +34,57 @@ builds:
- plan9 - plan9
- solaris - solaris
- wasip1 - wasip1
goarch:
- 386
- amd64
- arm
- arm64
- loong64
- mips
- mips64
- mips64le
- mipsle
- ppc64
- ppc64le
- riscv64
- s390x
- wasm
goarm:
- 6
- 7
goamd64:
- v1
- v2
- v3
- v4
- id: monorel-windows
binary: monorel
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X main.version={{.Env.VERSION}} -X main.commit={{.Commit}} -X main.date={{.Date}} -X main.builtBy=goreleaser
goos:
- windows - windows
# iOS requires CGO_ENABLED=1 and the Xcode toolchain. goarch:
#- id: monorel-ios - 386
# binary: monorel - amd64
# env: - arm64
# - CGO_ENABLED=1 goamd64:
# goos: - v1
# - ios - v2
# Android CGO_ENABLED=0 builds arm64 only; CGO builds require the NDK. - v3
#- id: monorel-android - v4
# binary: monorel
# env:
# - CGO_ENABLED=0
# goos:
# - android
# goarch:
# - arm64
archives: archives:
- id: monorel - id: monorel
ids: [monorel] ids: [monorel, monorel-windows]
formats: [tar.gz, tar.zst] formats: [tar.gz, tar.zst]
# this name template makes the OS and Arch compatible with the results of `uname`. # this name template makes the OS and Arch compatible with the results of `uname`.
# it uses the VERSION env var so the prefixed monorepo tag doesn't appear in archive filenames. # it uses the VERSION env var so the prefixed monorepo tag doesn't appear in archive filenames.
name_template: >- name_template: >-
monorel_{{ .Env.VERSION }}_ monorel_{{ .Env.VERSION }}_
{{- title .Os }}_ {{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64 {{- if eq .Arch "amd64" }}x86_64{{ if .Amd64 }}_{{ .Amd64 }}{{ end }}
{{- else if eq .Arch "386" }}i386 {{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }} {{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }} {{- if .Arm }}v{{ .Arm }}{{ end }}

View File

@ -63,14 +63,14 @@ var stopMarkers = []string{".git"}
// separately via the --ios and --android-ndk flags. // separately via the --ios and --android-ndk flags.
var defaultGoos = []string{ var defaultGoos = []string{
"darwin", "freebsd", "js", "linux", "darwin", "freebsd", "js", "linux",
"netbsd", "openbsd", "wasip1", "windows", "netbsd", "openbsd", "wasip1",
} }
// almostAllGoos extends defaultGoos with less-commonly-targeted CGO_ENABLED=0 platforms. // almostAllGoos extends defaultGoos with less-commonly-targeted CGO_ENABLED=0 platforms.
var almostAllGoos = []string{ var almostAllGoos = []string{
"aix", "darwin", "dragonfly", "freebsd", "illumos", "aix", "darwin", "dragonfly", "freebsd", "illumos",
"js", "linux", "netbsd", "openbsd", "plan9", "js", "linux", "netbsd", "openbsd", "plan9",
"solaris", "wasip1", "windows", "solaris", "wasip1",
} }
// defaultGoarch is the conservative architecture list for generated builds. // defaultGoarch is the conservative architecture list for generated builds.
@ -90,12 +90,20 @@ var almostAllGoarch = []string{
// Included whenever "arm" appears in the goarch list. // Included whenever "arm" appears in the goarch list.
var defaultGoarm = []string{"6", "7"} var defaultGoarm = []string{"6", "7"}
// defaultGoamd64 is the amd64 micro-architecture level list used with --almost-all. // defaultGoamd64 is the amd64 micro-architecture level list.
var defaultGoamd64 = []string{"v1", "v2"} var defaultGoamd64 = []string{"v1", "v2", "v3", "v4"}
// almostAllGoamd64 is the amd64 micro-architecture level list used with --almost-all. // almostAllGoamd64 is the amd64 micro-architecture level list used with --almost-all.
var almostAllGoamd64 = []string{"v1", "v2", "v3", "v4"} var almostAllGoamd64 = []string{"v1", "v2", "v3", "v4"}
// defaultWindowsGoarch is the architecture list for Windows builds.
// Windows is kept in a separate build entry because it does not support
// ARM v6/v7, so it cannot share the same goarch matrix as non-Windows builds.
var defaultWindowsGoarch = []string{"amd64", "arm64"}
// almostAllWindowsGoarch extends defaultWindowsGoarch with 32-bit x86.
var almostAllWindowsGoarch = []string{"386", "amd64", "arm64"}
// ── Types ────────────────────────────────────────────────────────────────── // ── Types ──────────────────────────────────────────────────────────────────
// binary describes one Go main package to build and release. // binary describes one Go main package to build and release.
@ -1406,10 +1414,12 @@ func goreleaserYAML(projectName string, bins []binary, opts buildOptions) string
goos := defaultGoos goos := defaultGoos
goarch := defaultGoarch goarch := defaultGoarch
goamd64 := defaultGoamd64 goamd64 := defaultGoamd64
windowsGoarch := defaultWindowsGoarch
if opts.almostAll { if opts.almostAll {
goos = almostAllGoos goos = almostAllGoos
goarch = almostAllGoarch goarch = almostAllGoarch
goamd64 = almostAllGoamd64 goamd64 = almostAllGoamd64
windowsGoarch = almostAllWindowsGoarch
} }
// When multiple binaries share a module, define the common build options // When multiple binaries share a module, define the common build options
@ -1496,17 +1506,42 @@ func goreleaserYAML(projectName string, bins []binary, opts buildOptions) string
} }
} }
// Windows-only builds: Windows does not support ARM v6/v7, so it cannot
// share the goarch matrix with the main non-Windows builds.
for _, bin := range bins {
wf(" - id: %s-windows\n", bin.name)
wf(" binary: %s\n", bin.name)
if bin.mainPath != "." {
wf(" main: %s\n", bin.mainPath)
}
wf(" env:\n - CGO_ENABLED=0\n")
wf(" ldflags:\n - -s -w"+
" -X main.version={{.Env.VERSION}}"+
" -X main.commit={{.Commit}}"+
" -X main.date={{.Date}}"+
" -X main.builtBy=goreleaser\n")
w(" goos:\n - windows\n")
w(" goarch:\n")
for _, a := range windowsGoarch {
wf(" - %s\n", a)
}
w(" goamd64:\n")
for _, v := range goamd64 {
wf(" - %s\n", v)
}
}
w("\narchives:\n") w("\narchives:\n")
for _, bin := range bins { for _, bin := range bins {
wf(" - id: %s\n", bin.name) wf(" - id: %s\n", bin.name)
wf(" ids: [%s]\n", bin.name) wf(" ids: [%s, %s-windows]\n", bin.name, bin.name)
w(" formats: [tar.gz, tar.zst]\n") w(" formats: [tar.gz, tar.zst]\n")
w(" # this name template makes the OS and Arch compatible with the results of `uname`.\n") w(" # this name template makes the OS and Arch compatible with the results of `uname`.\n")
w(" # it uses the VERSION env var so the prefixed monorepo tag doesn't appear in archive filenames.\n") w(" # it uses the VERSION env var so the prefixed monorepo tag doesn't appear in archive filenames.\n")
w(" name_template: >-\n") w(" name_template: >-\n")
wf(" %s_{{ .Env.VERSION }}_\n", bin.name) wf(" %s_{{ .Env.VERSION }}_\n", bin.name)
w(" {{- title .Os }}_\n") w(" {{- title .Os }}_\n")
w(" {{- if eq .Arch \"amd64\" }}x86_64\n") w(" {{- if eq .Arch \"amd64\" }}x86_64{{ if .Amd64 }}_{{ .Amd64 }}{{ end }}\n")
w(" {{- else if eq .Arch \"386\" }}i386\n") w(" {{- else if eq .Arch \"386\" }}i386\n")
w(" {{- else }}{{ .Arch }}{{ end }}\n") w(" {{- else }}{{ .Arch }}{{ end }}\n")
w(" {{- if .Arm }}v{{ .Arm }}{{ end }}\n") w(" {{- if .Arm }}v{{ .Arm }}{{ end }}\n")