feat(build): handle macOS Big Sur and later version number

This commit is contained in:
2021-10-10 18:24:23 +01:00
parent d63cd545aa
commit 2e2f9bc98a
3 changed files with 13 additions and 3 deletions

View File

@@ -2,6 +2,7 @@ package osinfo
import (
"os/exec"
"strconv"
"strings"
)
@@ -29,8 +30,17 @@ func New() (*OSInfo, error) {
}, nil
}
func (s *OSInfo) MajorMinor() string {
// DistinctVersion returns macOS version down to a distinct "major"
// version. For macOS 10.x, this will include the first two numeric parts of the
// version (10.15), while for 11.x and later, the first numeric part is enough
// (11).
func (s *OSInfo) DistinctVersion() string {
parts := strings.Split(s.Version, ".")
if n, _ := strconv.Atoi(parts[0]); n >= 11 {
return parts[0]
}
max := len(parts)
if max > 2 {
max = 2

View File

@@ -77,7 +77,7 @@ func Create(ctx context.Context, opts *Options) (*Plan, error) {
buildName := fmt.Sprintf(
"Emacs.%s.%s.%s",
version,
sanitizeString(osInfo.Name+"-"+osInfo.MajorMinor()),
sanitizeString(osInfo.Name+"-"+osInfo.DistinctVersion()),
sanitizeString(osInfo.Arch),
)
diskImage := buildName + ".dmg"