fix(ci): upload built binaries to GitHub Releases on tag creation

This commit is contained in:
Robert Sturla 2024-08-16 23:45:20 +01:00
parent 8bf32b1894
commit 845b4003e7
No known key found for this signature in database

View File

@ -2,14 +2,18 @@ name: Go Build and Release
on:
push:
branches: [ "main" ]
branches: ["main"]
tags:
- "v*"
pull_request:
branches: [ "main" ]
branches: ["main"]
jobs:
build:
name: Build binaries for Windows, macOS, and Linux
runs-on: ${{ matrix.os }}
permissions:
contents: write
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
@ -20,12 +24,12 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.22.1'
go-version-file: ./go.mod
- name: Build binary on Linux and macOS
if: matrix.os != 'windows-latest'
@ -56,3 +60,12 @@ jobs:
path: |
fabric-${{ matrix.os }}-${{ matrix.arch }}-${{ github.ref_name }}
fabric-macos-${{ matrix.arch }}-${{ github.ref_name }}.dmg
- name: Upload release artifact
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
run: |
if [[ "${{ matrix.os }}" == "macos-latest" ]]; then
gh release upload ${{ github.ref_name }} fabric-macos-${{ matrix.arch }}-${{ github.ref_name }}.dmg
else
gh release upload ${{ github.ref_name }} fabric-${{ matrix.os }}-${{ matrix.arch }}-${{ github.ref_name }}*
fi