From bb4266bcba9b49895075f286865a4f95c8e4aef5 Mon Sep 17 00:00:00 2001 From: Alexandre Date: Thu, 30 Jan 2025 20:59:28 +0100 Subject: [PATCH] Changed the GitHub Build system to produce artifacts and build for macOS and Linux (arm64 and amd64) --- .github/workflows/go.yml | 56 +++++++++++++++++++++++++++++----------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 48400b2..9e009b2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,28 +1,54 @@ -# This workflow will build a golang project -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go - name: Go on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] jobs: - build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - name: Set up Go - uses: actions/setup-go@v4 - with: - go-version: '1.23.5' + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.23.5" - - name: Build - run: go build -v ./... + - name: Build + run: go build -v ./... - - name: Test - run: go test -v ./... + - name: Test + run: go test -v ./... + + build-multiarch: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: "1.23.5" + + - name: Build binaries for multiple architectures + run: | + mkdir -p dist + + # Linux + GOOS=linux GOARCH=amd64 go build -o dist/gosh-linux-amd64 + GOOS=linux GOARCH=arm64 go build -o dist/gosh-linux-arm64 + + # macOS + GOOS=darwin GOARCH=amd64 go build -o dist/gosh-mac-amd64 + GOOS=darwin GOARCH=arm64 go build -o dist/gosh-mac-arm64 + + ls -lh dist/ + + - name: Upload binaries + uses: actions/upload-artifact@v4 + with: + name: gosh-binaries + path: dist/