Skip to content

Commit

Permalink
fix build/release process
Browse files Browse the repository at this point in the history
  • Loading branch information
milonoir committed Oct 12, 2023
1 parent 9e0886d commit 3569029
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ jobs:
bin/win64/*
bin/darwin/*
body_path: ".github/RELEASE-TEMPLATE.md"
tag_name: ${VERSION}
tag_name: ${{ env.VERSION }}
draft: false
prerelease: false
2 changes: 1 addition & 1 deletion internal/client/ui/version_panel.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ func (p *VersionPanel) GetTextView() *tview.TextView {
}

func (p *VersionPanel) SetVersion(v string) {
p.tv.SetText(fmt.Sprintf("The Business Club v%s", v))
p.tv.SetText(fmt.Sprintf("The Business Club %s", v))
}
65 changes: 47 additions & 18 deletions magefile.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,35 @@ import (
"github.com/magefile/mage/sh"
)

// Path to main packages.
const (
mainServer = "./cmd/bc-server"
mainClient = "./cmd/bc-client"
)

// Target binary names.
const (
targetServer = "bin/bc-server"
targetClient = "bin/bc-client"
)

// Target file name suffixes.
const (
targetLinux = ".linux-x86_64"
targetWindows = ".windows-x86_64.exe"
targetMac = ".darwin-x86_64"
)

// Target file names.
const (
targetLinuxServer = targetServer + targetLinux
targetLinuxClient = targetClient + targetLinux
targetWindowsServer = targetServer + targetWindows
targetWindowsClient = targetClient + targetWindows
targetMacServer = targetServer + targetMac
targetMacClient = targetClient + targetMac
)

// Default target to run when none is specified
// If not set, running mage will list available targets
var Default = Build.All
Expand Down Expand Up @@ -63,13 +92,13 @@ func (b Build) All() error {
func (Build) Server() error {
mg.Deps(Deps)
fmt.Println("Building Linux server...")
return sh.Run("go", "build", "-o", "bin/bc-server", "./cmd/bc-server")
return sh.Run("go", "build", "-o", targetLinuxServer, mainServer)
}

func (Build) Client() error {
mg.Deps(Deps)
fmt.Println("Building Linux client...")
return sh.Run("go", "build", "-o", "bin/bc-client", "./cmd/bc-client")
return sh.Run("go", "build", "-o", targetLinuxClient, mainClient)
}

func (b Build) WinAll() error {
Expand All @@ -83,13 +112,13 @@ func (b Build) WinAll() error {
func (Build) WinServer() error {
mg.Deps(Deps)
fmt.Println("Building Windows server...")
return sh.RunWith(envWin, "go", "build", "-o", "bin/win64/bc-server.exe", "./cmd/bc-server")
return sh.RunWith(envWin, "go", "build", "-o", targetWindowsServer, mainServer)
}

func (Build) WinClient() error {
mg.Deps(Deps)
fmt.Println("Building Windows client...")
return sh.RunWith(envWin, "go", "build", "-o", "bin/win64/bc-client.exe", "./cmd/bc-client")
return sh.RunWith(envWin, "go", "build", "-o", targetWindowsClient, mainClient)
}

func (b Build) MacAll() error {
Expand All @@ -103,13 +132,13 @@ func (b Build) MacAll() error {
func (Build) MacServer() error {
mg.Deps(Deps)
fmt.Println("Building Mac server...")
return sh.RunWith(envMac, "go", "build", "-o", "bin/darwin/bc-server", "./cmd/bc-server")
return sh.RunWith(envMac, "go", "build", "-o", targetMacServer, mainServer)
}

func (Build) MacClient() error {
mg.Deps(Deps)
fmt.Println("Building Mac client...")
return sh.RunWith(envMac, "go", "build", "-o", "bin/darwin/bc-client", "./cmd/bc-client")
return sh.RunWith(envMac, "go", "build", "-o", targetMacClient, mainClient)
}

func (v Versioned) All(version string) error {
Expand All @@ -122,16 +151,16 @@ func (v Versioned) All(version string) error {

func (Versioned) Server(version string) error {
mg.Deps(Deps)
fmt.Printf("Building Linux server (v%s)...\n", version)
fmt.Printf("Building Linux server (%s)...\n", version)
vf := fmt.Sprintf("-X 'github.com/milonoir/business-club-game/internal/game.Version=%s'", version)
return sh.Run("go", "build", "-ldflags", vf, "-o", "bin/bc-server", "./cmd/bc-server")
return sh.Run("go", "build", "-ldflags", vf, "-o", targetLinuxServer, mainServer)
}

func (Versioned) Client(version string) error {
mg.Deps(Deps)
fmt.Printf("Building Linux client (v%s)...\n", version)
fmt.Printf("Building Linux client (%s)...\n", version)
vf := fmt.Sprintf("-X 'github.com/milonoir/business-club-game/internal/game.Version=%s'", version)
return sh.Run("go", "build", "-ldflags", vf, "-o", "bin/bc-client", "./cmd/bc-client")
return sh.Run("go", "build", "-ldflags", vf, "-o", targetLinuxClient, mainClient)
}

func (v Versioned) WinAll(version string) error {
Expand All @@ -144,16 +173,16 @@ func (v Versioned) WinAll(version string) error {

func (Versioned) WinServer(version string) error {
mg.Deps(Deps)
fmt.Printf("Building Windows server (v%s)...\n", version)
fmt.Printf("Building Windows server (%s)...\n", version)
vf := fmt.Sprintf("-X 'github.com/milonoir/business-club-game/internal/game.Version=%s'", version)
return sh.RunWith(envWin, "go", "build", "-ldflags", vf, "-o", "bin/win64/bc-server.exe", "./cmd/bc-server")
return sh.RunWith(envWin, "go", "build", "-ldflags", vf, "-o", targetWindowsServer, mainServer)
}

func (Versioned) WinClient(version string) error {
mg.Deps(Deps)
fmt.Printf("Building Windows client (v%s)...\n", version)
fmt.Printf("Building Windows client (%s)...\n", version)
vf := fmt.Sprintf("-X 'github.com/milonoir/business-club-game/internal/game.Version=%s'", version)
return sh.RunWith(envWin, "go", "build", "-ldflags", vf, "-o", "bin/win64/bc-client.exe", "./cmd/bc-client")
return sh.RunWith(envWin, "go", "build", "-ldflags", vf, "-o", targetWindowsClient, mainClient)
}

func (v Versioned) MacAll(version string) error {
Expand All @@ -166,16 +195,16 @@ func (v Versioned) MacAll(version string) error {

func (Versioned) MacServer(version string) error {
mg.Deps(Deps)
fmt.Printf("Building Mac server (v%s)...\n", version)
fmt.Printf("Building Mac server (%s)...\n", version)
vf := fmt.Sprintf("-X 'github.com/milonoir/business-club-game/internal/game.Version=%s'", version)
return sh.RunWith(envMac, "go", "build", "-ldflags", vf, "-o", "bin/darwin/bc-server", "./cmd/bc-server")
return sh.RunWith(envMac, "go", "build", "-ldflags", vf, "-o", targetMacServer, mainServer)
}

func (Versioned) MacClient(version string) error {
mg.Deps(Deps)
fmt.Printf("Building Mac client (v%s)...\n", version)
fmt.Printf("Building Mac client (%s)...\n", version)
vf := fmt.Sprintf("-X 'github.com/milonoir/business-club-game/internal/game.Version=%s'", version)
return sh.RunWith(envMac, "go", "build", "-ldflags", vf, "-o", "bin/darwin/bc-client", "./cmd/bc-client")
return sh.RunWith(envMac, "go", "build", "-ldflags", vf, "-o", targetMacClient, mainClient)
}

func Deps() error {
Expand Down

0 comments on commit 3569029

Please sign in to comment.