Skip to content

Commit

Permalink
feat: append macOS version to OS (#12)
Browse files Browse the repository at this point in the history
* Append macOS version to OS

* Remove new go:build directive

* ci(build): update to latest version
  • Loading branch information
ayn2op authored Jan 14, 2025
1 parent 23c9a53 commit aef74e0
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
21 changes: 9 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,18 @@ jobs:
os: windows

steps:
- name: Checkout sources
uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version: '1.16.2'

- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags "-s -w"
- uses: actions/upload-artifact@v2
if: ${{ matrix.os != 'windows' }}
- uses: actions/upload-artifact@v4
with:
name: bunnyfetch-${{ matrix.os }}-${{ matrix.arch }}
path: bunnyfetch
- uses: actions/upload-artifact@v2
if: ${{ matrix.os == 'windows' }}
with:
name: bunnyfetch-${{ matrix.os }}-${{ matrix.arch }}.exe
path: bunnyfetch.exe
path: |
bunnyfetch
bunnyfetch.exe
15 changes: 13 additions & 2 deletions cmd/info_darwin.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
//go:build darwin
// +build darwin

package cmd

import (
"bytes"
"os"
"os/exec"
"strings"
)

func OS() string {
out, err := exec.Command("sw_vers", "-productName").CombinedOutput()
name, err := exec.Command("sw_vers", "-productName").CombinedOutput()
if err != nil {
return "Unknown"
}
return strings.TrimSuffix(string(out), "\n")

name = bytes.TrimSuffix(name, []byte{'\n'})

version, err := exec.Command("sw_vers", "-productVersion").CombinedOutput()
if err != nil {
return string(name)
}

version = bytes.TrimSuffix(version, []byte{'\n'})
return string(name) + " " + string(version)
}

func Kernel() string {
Expand Down

0 comments on commit aef74e0

Please sign in to comment.