Skip to content

Build Go binaries and upload release #26

Build Go binaries and upload release

Build Go binaries and upload release #26

Workflow file for this run

name: Build Go binaries and upload to weave-binaries release
on:
release:
types:
- published
jobs:
build:
name: Build Go binaries
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin]
goarch: [amd64, arm64]
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.22.6"
- name: Build binary
run: |
mkdir -p build/${{ matrix.goos }}_${{ matrix.goarch }}
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o build/${{ matrix.goos }}_${{ matrix.goarch }}/weave
- name: List files in build directory (optional for debugging)
run: ls -R build/
# tar.gz
- name: Create tar.gz
run: |
tar -czvf weave_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz -C build/${{ matrix.goos }}_${{ matrix.goarch }} weave
- name: Upload binaries as artifacts
uses: actions/upload-artifact@v3
with:
name: weave_${{ matrix.goos }}_${{ matrix.goarch }}
path: weave_${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz
if-no-files-found: error
upload-to-weave-binaries:
name: Upload to weave-binaries release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download binaries
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Create a release in weave-binaries
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
repository: initia-labs/weave-binaries
draft: false
prerelease: true
token: ${{ secrets.WEAVE_BINARIES_GITHUB_TOKEN }}
files: |
artifacts/weave_linux_amd64.tar.gz
artifacts/weave_linux_arm64.tar.gz
artifacts/weave_darwin_amd64.tar.gz
artifacts/weave_darwin_arm64.tar.gz