From 845b4003e781122acf64aace5b86406ea23711ae Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Fri, 16 Aug 2024 23:45:20 +0100 Subject: [PATCH 1/3] fix(ci): upload built binaries to GitHub Releases on tag creation --- .github/workflows/go.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 230a333e3..30059bceb 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -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 From 01169cf71da32d07f2da9177c2aacea49f70d904 Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Fri, 16 Aug 2024 23:50:23 +0100 Subject: [PATCH 2/3] fix(ci): standardise binary names --- .github/workflows/go.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 30059bceb..666266b40 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -33,17 +33,21 @@ jobs: - name: Build binary on Linux and macOS if: matrix.os != 'windows-latest' + env: + OS: ${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }} + GOOS: ${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }} + GOARCH: ${{ matrix.arch }} run: | - GOOS=${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }} \ - GOARCH=${{ matrix.arch }} \ - go build -o fabric-${{ matrix.os }}-${{ matrix.arch }}-${{ github.ref_name }} . + go build -o fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }} . - name: Build binary on Windows if: matrix.os == 'windows-latest' + env: + OS: windows + GOOS: windows + GOARCH: ${{ matrix.arch }} run: | - $env:GOOS = 'windows' - $env:GOARCH = '${{ matrix.arch }}' - go build -o fabric-${{ matrix.os }}-${{ matrix.arch }}-${{ github.ref_name }} . + go build -o fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }} . - name: Create DMG for macOS if: matrix.os == 'macos-latest' @@ -64,8 +68,4 @@ jobs: - 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 + gh release upload ${{ github.ref_name }} fabric-*-${{ matrix.arch }}-${{ github.ref_name }}* From 3b35d88611d8bfae01476c0e2a833db1e2300d0e Mon Sep 17 00:00:00 2001 From: Robert Sturla Date: Sat, 17 Aug 2024 00:27:55 +0100 Subject: [PATCH 3/3] chore(ci): keep macos binary around in release assets --- .github/workflows/go.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 666266b40..25cefd781 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -53,7 +53,7 @@ jobs: if: matrix.os == 'macos-latest' run: | mkdir dist - mv fabric-macos-latest-${{ matrix.arch }}-${{ github.ref_name }} dist/fabric + cp fabric-macos-latest-${{ matrix.arch }}-${{ github.ref_name }} dist/fabric hdiutil create dist/fabric-${{ matrix.arch }}.dmg -volname "fabric" -srcfolder dist/fabric mv dist/fabric-${{ matrix.arch }}.dmg fabric-macos-${{ matrix.arch }}-${{ github.ref_name }}.dmg