use build outputs
This commit is contained in:
32
.github/workflows/binary-build.yml
vendored
32
.github/workflows/binary-build.yml
vendored
@@ -9,9 +9,23 @@ on:
|
||||
- latest
|
||||
|
||||
jobs:
|
||||
determine_version:
|
||||
runs-on: ubuntu-latest
|
||||
outputs:
|
||||
build_version: ${{ steps.set_version.outputs.version }}
|
||||
steps:
|
||||
- id: set_version
|
||||
run: |
|
||||
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
||||
echo "::set-output name=version::${GITHUB_REF#refs/tags/}"
|
||||
else
|
||||
echo "::set-output name=version::latest"
|
||||
fi
|
||||
|
||||
build:
|
||||
name: Build
|
||||
runs-on: ubuntu-latest
|
||||
needs: determine_version
|
||||
strategy:
|
||||
matrix:
|
||||
goos: [windows, darwin, linux]
|
||||
@@ -31,17 +45,9 @@ jobs:
|
||||
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-${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }} cmd/zurg/main.go
|
||||
CGO_ENABLED=0 GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -ldflags="-s -w" -o zurg-${{ needs.determine_version.outputs.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
|
||||
@@ -49,12 +55,12 @@ jobs:
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y upx-ucl
|
||||
upx --best zurg-${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
upx --best zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
|
||||
# Zip the binary
|
||||
- name: Zip Binary
|
||||
run: |
|
||||
zip zurg-${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}.zip zurg-${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
zip zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}
|
||||
|
||||
# List files (for debugging)
|
||||
- name: List files
|
||||
@@ -63,5 +69,5 @@ jobs:
|
||||
- name: Upload Artifacts
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: zurg-${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}.zip
|
||||
path: zurg-${BUILD_VERSION}-${{ matrix.goos }}-${{ matrix.goarch }}.zip
|
||||
name: zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip
|
||||
path: zurg-${{ needs.determine_version.outputs.build_version }}-${{ matrix.goos }}-${{ matrix.goarch }}.zip
|
||||
|
||||
Reference in New Issue
Block a user