Add build info to orbit macos build action (#13796)

This commit is contained in:
Lucas Manuel Rodriguez 2023-09-07 13:23:38 -03:00 committed by GitHub
parent 899cb38f22
commit 811e38c0f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 4 deletions

View file

@ -1,4 +1,4 @@
name: Build, Sign and Notarize Orbit
name: Build, Sign and Notarize Orbit for macOS
on:
workflow_dispatch: # allow manual action
@ -6,6 +6,9 @@ on:
paths:
- 'orbit/**.go'
env:
ORBIT_VERSION: 1.16.0
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id}}
@ -54,6 +57,8 @@ jobs:
AC_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
AC_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
CODESIGN_IDENTITY: 51049B247B25B3119FAE7E9C0CC4375A43E47237
ORBIT_VERSION: ${{ env.ORBIT_VERSION }}
ORBIT_COMMIT: ${{ github.sha }}
- name: Upload orbit
uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v2

View file

@ -12,6 +12,7 @@ import (
"os"
"os/exec"
"path/filepath"
"time"
"github.com/fleetdm/fleet/v4/orbit/pkg/packaging"
"github.com/fleetdm/fleet/v4/pkg/buildpkg"
@ -28,6 +29,10 @@ func main() {
acPassword := os.Getenv("AC_PASSWORD")
acTeamID := os.Getenv("AC_TEAM_ID")
version := os.Getenv("ORBIT_VERSION")
commit := os.Getenv("ORBIT_COMMIT")
date := time.Now().UTC().Format("2006-01-02T15:04:05Z")
codesign := false
if codesignIdentity != "" {
codesign = true
@ -48,10 +53,10 @@ func main() {
binaryPath = "orbit-darwin"
bundleIdentifier = "com.fleetdm.orbit"
)
if err := buildOrbit(amdBinaryPath, "amd64"); err != nil {
if err := buildOrbit(amdBinaryPath, "amd64", version, commit, date); err != nil {
panic(err)
}
if err := buildOrbit(armBinaryPath, "arm64"); err != nil {
if err := buildOrbit(armBinaryPath, "arm64", version, commit, date); err != nil {
panic(err)
}
@ -93,10 +98,11 @@ func main() {
}
}
func buildOrbit(binaryPath, arch string) error {
func buildOrbit(binaryPath, arch, version, commit, date string) error {
/* #nosec G204 -- arguments are actually well defined */
buildExec := exec.Command("go", "build",
"-o", binaryPath,
"-ldflags", fmt.Sprintf("-X github.com/fleetdm/fleet/v4/orbit/pkg/build.Version=%s -X github.com/fleetdm/fleet/v4/orbit/pkg/build.Commit=%s -X github.com/fleetdm/fleet/v4/orbit/pkg/build.Date=%s", version, commit, date),
"./"+filepath.Join("orbit", "cmd", "orbit"),
)
buildExec.Env = append(os.Environ(), "GOOS=darwin", "GOARCH="+arch)