diff --git a/.github/workflows/build_releases.yml b/.github/workflows/build_releases.yml index 5b41dbe..1ceac53 100644 --- a/.github/workflows/build_releases.yml +++ b/.github/workflows/build_releases.yml @@ -11,121 +11,7 @@ env: GO_VERSION: '1.24.2' jobs: - build-common: - runs-on: ubuntu-24.04 - - steps: - - name: Checkout Main Repo - uses: actions/checkout@v4 - with: - repository: gregtwallace/apc-p15-tool - ref: ${{ env.GITHUB_REF }} - fetch-depth: 0 - - - name: Save README - uses: actions/upload-artifact@v4 - with: - name: README.md - path: ./README.md - - - name: Save LICENSE - uses: actions/upload-artifact@v4 - with: - name: LICENSE.md - path: ./LICENSE.md - - - name: Save CHANGELOG - uses: actions/upload-artifact@v4 - with: - name: CHANGELOG.md - path: ./CHANGELOG.md - -### - - build-linux-arm64: - runs-on: ubuntu-24.04-arm - steps: - - name: Checkout Repo - uses: actions/checkout@v4 - with: - repository: gregtwallace/apc-p15-tool - ref: ${{ env.GITHUB_REF }} - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '${{ env.GO_VERSION }}' - - - name: Build Tool - run: go build -o ./apc-p15-tool -v ./cmd/tool - env: - GOOS: linux - GOARCH: arm64 - CGO_ENABLED: 0 - - - name: Save Compiled Binary - uses: actions/upload-artifact@v4 - with: - name: apc-p15-tool-linux-arm64 - path: ./apc-p15-tool - - - name: Build Install Only - run: go build -o ./apc-p15-install -v ./cmd/install_only - env: - GOOS: linux - GOARCH: arm64 - CC: aarch64-linux-gnu-gcc - CGO_ENABLED: 0 - - - name: Save Compiled Binary - uses: actions/upload-artifact@v4 - with: - name: apc-p15-install-linux-arm64 - path: ./apc-p15-install - - build-linux-amd64: - runs-on: ubuntu-24.04 - steps: - - name: Checkout Backend Repo - uses: actions/checkout@v4 - with: - repository: gregtwallace/apc-p15-tool - ref: ${{ env.GITHUB_REF }} - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '${{ env.GO_VERSION }}' - - - name: Build Tool - run: go build -o ./apc-p15-tool -v ./cmd/tool - env: - GOOS: linux - GOARCH: amd64 - CGO_ENABLED: 0 - - - name: Save Compiled Binary - uses: actions/upload-artifact@v4 - with: - name: apc-p15-tool-linux-amd64 - path: ./apc-p15-tool - - - name: Build Install Only - run: go build -o ./apc-p15-install -v ./cmd/install_only - env: - GOOS: linux - GOARCH: amd64 - CGO_ENABLED: 0 - - - name: Save Compiled Binary - uses: actions/upload-artifact@v4 - with: - name: apc-p15-install-linux-amd64 - path: ./apc-p15-install - - build-windows-amd64: + build-all: runs-on: windows-latest steps: - name: Checkout Backend Repo @@ -140,332 +26,12 @@ jobs: with: go-version: '${{ env.GO_VERSION }}' - - name: Build Tool - run: go build -o ./apc-p15-tool.exe -v ./cmd/tool - env: - GOOS: windows - GOARCH: amd64 - CGO_ENABLED: 0 + - name: Build All + run: | + .\build_release.ps1 - - name: Save Compiled Binary + - name: Save Zip of all targets uses: actions/upload-artifact@v4 with: - name: apc-p15-tool-windows-amd64 - path: ./apc-p15-tool.exe - - - name: Build Install Only - run: go build -o ./apc-p15-install.exe -v ./cmd/install_only - env: - GOOS: windows - GOARCH: amd64 - CGO_ENABLED: 0 - - - name: Save Compiled Binary - uses: actions/upload-artifact@v4 - with: - name: apc-p15-install-windows-amd64 - path: ./apc-p15-install.exe - - build-darwin-arm64: - runs-on: macos-15 - steps: - - name: Checkout Backend Repo - uses: actions/checkout@v4 - with: - repository: gregtwallace/apc-p15-tool - ref: ${{ env.GITHUB_REF }} - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '${{ env.GO_VERSION }}' - - - name: Build Tool - run: go build -o ./apc-p15-tool -v ./cmd/tool - env: - GOOS: darwin - GOARCH: arm64 - CGO_ENABLED: 0 - - - name: Save Compiled Binary - uses: actions/upload-artifact@v4 - with: - name: apc-p15-tool-darwin-arm64 - path: ./apc-p15-tool - - - name: Build Install Only - run: go build -o ./apc-p15-install -v ./cmd/install_only - env: - GOOS: darwin - GOARCH: arm64 - CGO_ENABLED: 0 - - - name: Save Compiled Binary - uses: actions/upload-artifact@v4 - with: - name: apc-p15-install-darwin-arm64 - path: ./apc-p15-install - - build-darwin-amd64: - runs-on: macos-13 - steps: - - name: Checkout Backend Repo - uses: actions/checkout@v4 - with: - repository: gregtwallace/apc-p15-tool - ref: ${{ env.GITHUB_REF }} - fetch-depth: 0 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version: '${{ env.GO_VERSION }}' - - - name: Build Tool - run: go build -o ./apc-p15-tool -v ./cmd/tool - env: - GOOS: darwin - GOARCH: amd64 - CGO_ENABLED: 0 - - - name: Save Compiled Binary - uses: actions/upload-artifact@v4 - with: - name: apc-p15-tool-darwin-amd64 - path: ./apc-p15-tool - - - name: Build Install Only - run: go build -o ./apc-p15-install -v ./cmd/install_only - env: - GOOS: darwin - GOARCH: amd64 - CGO_ENABLED: 0 - - - name: Save Compiled Binary - uses: actions/upload-artifact@v4 - with: - name: apc-p15-install-darwin-amd64 - path: ./apc-p15-install - -### - - release-file-linux-arm64: - needs: [build-common, build-linux-arm64] - runs-on: ubuntu-24.04 - - steps: - - name: Make release directory - run: mkdir ./release - - - name: Download Tool Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-tool-linux-arm64 - path: ./release - - - name: Download Install Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-install-linux-arm64 - path: ./release - - - name: Download README - uses: actions/download-artifact@v4 - with: - name: README.md - path: ./release - - - name: Download LICENSE - uses: actions/download-artifact@v4 - with: - name: LICENSE.md - path: ./release - - - name: Download CHANGELOG - uses: actions/download-artifact@v4 - with: - name: CHANGELOG.md - path: ./release - - - name: Save Release - uses: actions/upload-artifact@v4 - with: - name: apc-p15-tool_linux_arm64 - path: ./release - - release-file-linux-amd64: - needs: [build-common, build-linux-amd64] - runs-on: ubuntu-24.04 - - steps: - - name: Make release directory - run: mkdir ./release - - - name: Download Tool Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-tool-linux-amd64 - path: ./release - - - name: Download Install Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-install-linux-amd64 - path: ./release - - - name: Download README - uses: actions/download-artifact@v4 - with: - name: README.md - path: ./release - - - name: Download LICENSE - uses: actions/download-artifact@v4 - with: - name: LICENSE.md - path: ./release - - - name: Download CHANGELOG - uses: actions/download-artifact@v4 - with: - name: CHANGELOG.md - path: ./release - - - name: Save Release - uses: actions/upload-artifact@v4 - with: - name: apc-p15-tool_linux_amd64 - path: ./release - - release-file-windows-amd64: - needs: [build-common, build-windows-amd64] - runs-on: ubuntu-24.04 - - steps: - - name: Make release directory - run: mkdir ./release - - - name: Download Tool Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-tool-windows-amd64 - path: ./release - - - name: Download Install Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-install-windows-amd64 - path: ./release - - - name: Download README - uses: actions/download-artifact@v4 - with: - name: README.md - path: ./release - - - name: Download LICENSE - uses: actions/download-artifact@v4 - with: - name: LICENSE.md - path: ./release - - - name: Download CHANGELOG - uses: actions/download-artifact@v4 - with: - name: CHANGELOG.md - path: ./release - - - name: Save Release - uses: actions/upload-artifact@v4 - with: - name: apc-p15-tool_windows_amd64 - path: ./release - - release-file-darwin-arm64: - needs: [build-common, build-darwin-arm64] - runs-on: ubuntu-24.04 - - steps: - - name: Make release directory - run: mkdir ./release - - - name: Download Tool Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-tool-darwin-arm64 - path: ./release - - - name: Download Install Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-install-darwin-arm64 - path: ./release - - - name: Download README - uses: actions/download-artifact@v4 - with: - name: README.md - path: ./release - - - name: Download LICENSE - uses: actions/download-artifact@v4 - with: - name: LICENSE.md - path: ./release - - - name: Download CHANGELOG - uses: actions/download-artifact@v4 - with: - name: CHANGELOG.md - path: ./release - - - name: Save Release - uses: actions/upload-artifact@v4 - with: - name: apc-p15-tool_darwin_arm64 - path: ./release - - release-file-darwin-amd64: - needs: [build-common, build-darwin-amd64] - runs-on: ubuntu-24.04 - - steps: - - name: Make release directory - run: mkdir ./release - - - name: Download Tool Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-tool-darwin-amd64 - path: ./release - - - name: Download Install Binary - uses: actions/download-artifact@v4 - with: - name: apc-p15-install-darwin-amd64 - path: ./release - - - name: Download README - uses: actions/download-artifact@v4 - with: - name: README.md - path: ./release - - - name: Download LICENSE - uses: actions/download-artifact@v4 - with: - name: LICENSE.md - path: ./release - - - name: Download CHANGELOG - uses: actions/download-artifact@v4 - with: - name: CHANGELOG.md - path: ./release - - - name: Save Release - uses: actions/upload-artifact@v4 - with: - name: apc-p15-tool_darwin_amd64 - path: ./release + name: apc-p15-tool-release + path: .\_out\_release diff --git a/build.ps1 b/build.ps1 deleted file mode 100644 index 0c8774b..0000000 --- a/build.ps1 +++ /dev/null @@ -1,58 +0,0 @@ -# Parent dir is root -$scriptDir = Get-Location -$outDir = Join-Path -Path $scriptDir -ChildPath "/_out" - -# Windows x64 -$env:GOARCH = "amd64" -$env:GOOS = "windows" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-tool-amd64.exe ./cmd/tool - -$env:GOARCH = "amd64" -$env:GOOS = "windows" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-install-amd64.exe ./cmd/install_only - -# Linux x64 -$env:GOARCH = "amd64" -$env:GOOS = "linux" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-tool-amd64 ./cmd/tool - -$env:GOARCH = "amd64" -$env:GOOS = "linux" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-install-amd64 ./cmd/install_only - -# Linux arm64 -$env:GOARCH = "arm64" -$env:GOOS = "linux" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-tool-arm64 ./cmd/tool - -$env:GOARCH = "arm64" -$env:GOOS = "linux" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-install-arm64 ./cmd/install_only - -# Darwin (MacOS) amd64 -$env:GOARCH = "amd64" -$env:GOOS = "darwin" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-tool-darwin-amd64 ./cmd/tool - -$env:GOARCH = "amd64" -$env:GOOS = "darwin" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-install-darwin-amd64 ./cmd/install_only - -# Darwin (MacOS) arm64 -$env:GOARCH = "arm64" -$env:GOOS = "darwin" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-tool-darwin-arm64 ./cmd/tool - -$env:GOARCH = "arm64" -$env:GOOS = "darwin" -$env:CGO_ENABLED = 0 -go build -o $outDir/apc-p15-install-darwin-arm64 ./cmd/install_only diff --git a/build_release.ps1 b/build_release.ps1 new file mode 100644 index 0000000..ead0c53 --- /dev/null +++ b/build_release.ps1 @@ -0,0 +1,54 @@ +# base build path, relative to script +$outRelativeDir = "\_out" + +### + +# Script dir is root +$scriptDir = Get-Location +$outBaseDir = Join-Path -Path $scriptDir -ChildPath $outRelativeDir +$outReleaseDir = Join-Path -Path $outBaseDir -ChildPath "\_release" + +# ensure release path exists +New-Item -ItemType Directory -Force -Path $outReleaseDir | Out-Null + +# get version number (tag) +$gitTag = $(git describe --tags --abbrev=0) + +# GOOS_GOARCH to build for +$targets = @( + "windows_amd64", + "linux_amd64", + "linux_arm64", + "darwin_amd64", + "darwin_arm64" +) + +# loop through and build all targets +foreach ($target in $targets) { + # environment vars + $split = $target.split("_") + $env:GOOS = $split[0] + $env:GOARCH = $split[1] + $env:CGO_ENABLED = 0 + + # send build product to GOOS_GOARCH subfolders + $targetOutDir = Join-Path -Path $outBaseDir -ChildPath "$($env:GOOS)_$($env:GOARCH)" + + # special case to add file extensions + $extension = "" + if ($env:GOOS -eq "windows") { + $extension = ".exe" + } + + # build binary and install only binary + go build -o "$($targetOutDir)\apc-p15-tool$($extension)" .\cmd\tool + go build -o "$($targetOutDir)\apc-p15-install$($extension)" .\cmd\install_only + + # copy other important files for release + Copy-Item .\README.md $targetOutDir + Copy-Item .\CHANGELOG.md $targetOutDir + Copy-Item .\LICENSE.md $targetOutDir + + # zip and drop into release folder + Compress-Archive -Path "$($targetOutDir)\*" -CompressionLevel Optimal -DestinationPath "$($outReleaseDir)\apc-p15-tool-$($gitTag)_$($target).zip" -Force +}