Files
zurg/.github/workflows/binary-build.yml
2023-10-28 22:08:06 +02:00

68 lines
1.9 KiB
YAML

name: Build zurg-testing executable binary
on:
push:
branches:
- main
tags:
- v0*
- latest
jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
goos: [windows, darwin, linux]
goarch: [386, amd64, arm, arm64]
exclude:
- goos: darwin
goarch: 386
- goos: darwin
goarch: arm
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 'stable'
- name: Determine version/tag
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "BUILD_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
else
echo "BUILD_VERSION=latest" >> $GITHUB_ENV
fi
- name: Build
run: |
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o zurg-v${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }} cmd/zurg/main.go
# Install and use UPX to compress the binary, but exclude specific combinations
- name: Install and Compress with UPX
if: (matrix.goos != 'windows' || matrix.goarch != 'arm') && (matrix.goos != 'windows' || matrix.goarch != 'arm64')
run: |
sudo apt-get update
sudo apt-get install -y upx-ucl
upx --best zurg-v${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}
# Zip the binary
- name: Zip Binary
run: |
zip zurg-v${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}.zip zurg-v${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}
# List files (for debugging)
- name: List files
run: ls -alh
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: zurg-v${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}.zip
path: zurg-v${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}.zip