Skip to content

Commit

Permalink
Set build version using linker flags (#183)
Browse files Browse the repository at this point in the history
  • Loading branch information
majd authored May 20, 2023
1 parent 9a361cf commit cf926d7
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 29 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/dry-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ jobs:
with:
go-version: '1.19.3'
cache: true
- run: ./tools/version.sh
- run: go build -o ipatool-$GOOS-$GOARCH.exe
env:
GOOS: windows
Expand All @@ -37,7 +36,6 @@ jobs:
with:
go-version: '1.19.3'
cache: true
- run: ./tools/version.sh
- run: go build -o ipatool-$GOOS-$GOARCH
env:
GOOS: linux
Expand All @@ -55,7 +53,6 @@ jobs:
with:
go-version: '1.19.3'
cache: true
- run: ./tools/version.sh
- run: go build -o ipatool-$GOOS-$GOARCH
env:
GOOS: darwin
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ jobs:
with:
go-version: '1.19.3'
cache: true
- run: ./tools/version.sh
- run: go build -o ipatool
env:
CGO_CFLAGS: -mmacosx-version-min=10.15
Expand Down
20 changes: 12 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
with:
go-version: '1.19.3'
cache: true
- run: ./tools/version.sh
- run: go test -v github.com/majd/ipatool/...
build:
name: Build
Expand All @@ -35,34 +34,39 @@ jobs:
with:
go-version: '1.19.3'
cache: true
- run: ./tools/version.sh
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-windows-arm64.exe
- run: go build -ldflags="-X github.com/majd/ipatool/cmd.version=$VERSION" -o ipatool-$VERSION-windows-arm64.exe
env:
GOOS: windows
GOARCH: arm64
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-windows-amd64.exe
VERSION: ${{ needs.get_version.outputs.version }}
- run: go build -ldflags="-X github.com/majd/ipatool/cmd.version=$VERSION" -o ipatool-$VERSION-windows-amd64.exe
env:
GOOS: windows
GOARCH: amd64
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-linux-arm64
VERSION: ${{ needs.get_version.outputs.version }}
- run: go build -ldflags="-X github.com/majd/ipatool/cmd.version=$VERSION" -o ipatool-$VERSION-linux-arm64
env:
GOOS: linux
GOARCH: arm64
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-linux-amd64
VERSION: ${{ needs.get_version.outputs.version }}
- run: go build -ldflags="-X github.com/majd/ipatool/cmd.version=$VERSION" -o ipatool-$VERSION-linux-amd64
env:
GOOS: linux
GOARCH: amd64
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-macos-arm64
VERSION: ${{ needs.get_version.outputs.version }}
- run: go build -ldflags="-X github.com/majd/ipatool/cmd.version=$VERSION" -o ipatool-$VERSION-macos-arm64
env:
GOOS: darwin
GOARCH: arm64
VERSION: ${{ needs.get_version.outputs.version }}
CGO_CFLAGS: -mmacosx-version-min=10.15
CGO_LDFLAGS: -mmacosx-version-min=10.15
CGO_ENABLED: 1
- run: go build -o ipatool-${{ needs.get_version.outputs.version }}-macos-amd64
- run: go build -ldflags="-X github.com/majd/ipatool/cmd.version=$VERSION" -o ipatool-$VERSION-macos-amd64
env:
GOOS: darwin
GOARCH: amd64
VERSION: ${{ needs.get_version.outputs.version }}
CGO_CFLAGS: -mmacosx-version-min=10.15
CGO_LDFLAGS: -mmacosx-version-min=10.15
CGO_ENABLED: 1
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ jobs:
with:
go-version: '1.19.3'
cache: true
- run: ./tools/version.sh
- run: go test -v github.com/majd/ipatool/...
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
.AppleDouble
.LSOverride
.vscode/
.idea/
cmd/version.go
.idea/
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"golang.org/x/net/context"
)

var version = "dev"

func rootCmd() *cobra.Command {
var verbose bool
var nonInteractive bool
Expand Down Expand Up @@ -48,7 +50,7 @@ func rootCmd() *cobra.Command {
return cmd
}

// Execute runs the program and returns the approperiate exit status code.
// Execute runs the program and returns the appropriate exit status code.
func Execute() (exitCode int) {
cmd := rootCmd()
err := cmd.Execute()
Expand Down
13 changes: 0 additions & 13 deletions tools/version.sh

This file was deleted.

0 comments on commit cf926d7

Please sign in to comment.