2024-08-16 20:15:00 +00:00
|
|
|
name: Go Build and Release
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2024-08-16 22:45:20 +00:00
|
|
|
branches: ["main"]
|
|
|
|
tags:
|
|
|
|
- "v*"
|
2024-08-16 20:15:00 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-08-20 22:50:19 +00:00
|
|
|
test:
|
|
|
|
name: Run tests
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v4
|
|
|
|
with:
|
|
|
|
go-version-file: ./go.mod
|
|
|
|
|
|
|
|
- name: Run tests
|
|
|
|
run: go test -v ./...
|
|
|
|
|
2024-08-16 20:15:00 +00:00
|
|
|
build:
|
|
|
|
name: Build binaries for Windows, macOS, and Linux
|
|
|
|
runs-on: ${{ matrix.os }}
|
2024-08-16 22:45:20 +00:00
|
|
|
permissions:
|
|
|
|
contents: write
|
2024-08-16 20:15:00 +00:00
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
|
|
arch: [amd64, arm64]
|
|
|
|
exclude:
|
|
|
|
- os: windows-latest
|
|
|
|
arch: arm64
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout code
|
2024-08-16 22:45:20 +00:00
|
|
|
uses: actions/checkout@v4
|
2024-08-16 20:15:00 +00:00
|
|
|
|
|
|
|
- name: Set up Go
|
|
|
|
uses: actions/setup-go@v4
|
|
|
|
with:
|
2024-08-16 22:45:20 +00:00
|
|
|
go-version-file: ./go.mod
|
2024-08-16 20:15:00 +00:00
|
|
|
|
2024-08-17 11:00:45 +00:00
|
|
|
- name: Determine OS Name
|
|
|
|
id: os-name
|
|
|
|
run: |
|
2024-08-17 11:04:56 +00:00
|
|
|
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
|
2024-08-17 11:00:45 +00:00
|
|
|
echo "OS=linux" >> $GITHUB_ENV
|
2024-08-17 11:04:56 +00:00
|
|
|
elif [ "${{ matrix.os }}" == "macos-latest" ]; then
|
2024-08-17 11:00:45 +00:00
|
|
|
echo "OS=darwin" >> $GITHUB_ENV
|
|
|
|
else
|
|
|
|
echo "OS=windows" >> $GITHUB_ENV
|
|
|
|
fi
|
2024-08-17 11:04:56 +00:00
|
|
|
shell: bash
|
2024-08-17 11:00:45 +00:00
|
|
|
|
2024-08-16 20:15:00 +00:00
|
|
|
- name: Build binary on Linux and macOS
|
|
|
|
if: matrix.os != 'windows-latest'
|
2024-08-16 22:50:23 +00:00
|
|
|
env:
|
2024-08-17 11:00:45 +00:00
|
|
|
GOOS: ${{ env.OS }}
|
2024-08-16 22:50:23 +00:00
|
|
|
GOARCH: ${{ matrix.arch }}
|
2024-08-16 20:15:00 +00:00
|
|
|
run: |
|
2024-08-16 22:50:23 +00:00
|
|
|
go build -o fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }} .
|
2024-08-16 20:15:00 +00:00
|
|
|
|
|
|
|
- name: Build binary on Windows
|
|
|
|
if: matrix.os == 'windows-latest'
|
2024-08-16 22:50:23 +00:00
|
|
|
env:
|
|
|
|
GOOS: windows
|
|
|
|
GOARCH: ${{ matrix.arch }}
|
2024-08-16 20:15:00 +00:00
|
|
|
run: |
|
2024-08-16 22:50:23 +00:00
|
|
|
go build -o fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }} .
|
2024-08-16 20:15:00 +00:00
|
|
|
|
|
|
|
- name: Upload build artifact
|
|
|
|
uses: actions/upload-artifact@v3
|
|
|
|
with:
|
2024-08-17 10:55:53 +00:00
|
|
|
name: fabric-${{ env.OS }}-${{ matrix.arch }}-${{ github.ref_name }}
|
|
|
|
path: fabric-${{ env.OS }}-${{ matrix.arch }}-${{ github.ref_name }}
|
2024-08-16 22:45:20 +00:00
|
|
|
|
|
|
|
- name: Upload release artifact
|
|
|
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
|
|
|
|
run: |
|
2024-08-17 11:00:45 +00:00
|
|
|
gh release upload ${{ github.ref_name }} fabric-${{ env.OS }}-${{ matrix.arch }}-${{ github.ref_name }}
|