sq/.github/workflows/go.yml
Neil O'Toole 32d0896164
Multiplatform goreleaser (#106)
This PR moves `sq` to using GitHub workflows for publishing.
2022-11-06 22:49:05 -07:00

222 lines
5.6 KiB
YAML

name: Main pipeline
on: push
env:
GO_VERSION: 1.19.3
GORELEASER_VERSION: 1.12.3
jobs:
go-test:
strategy:
matrix:
os: [ macos-12, ubuntu-22.04, windows-2022]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Build
run: go build -v ./...
- name: Test
run: go test -v ./...
goreleaser-gate:
needs: go-test
runs-on: ubuntu-22.04
steps:
- name: Gate
run: echo "GoReleaser gate"
build-binaries-darwin:
needs: goreleaser-gate
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: GoReleaser (build darwin binaries)
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: ${{ env.GORELEASER_VERSION }}
args: build --skip-validate --rm-dist -f .goreleaser-darwin.yml
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Upload assets (darwin)
uses: actions/upload-artifact@v3
with:
name: dist-darwin
path: dist-darwin
build-binaries-linux-amd64:
needs: goreleaser-gate
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: GoReleaser (build linux-amd64 binaries)
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: ${{ env.GORELEASER_VERSION }}
args: build --skip-validate --rm-dist -f .goreleaser-linux-amd64.yml
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Upload assets (linux-amd64)
uses: actions/upload-artifact@v3
with:
name: dist-linux-amd64
path: dist-linux
build-binaries-linux-arm64:
needs: goreleaser-gate
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Install toolchain dependencies
run: |
sudo apt update
sudo apt install -y gcc-aarch64-linux-gnu
- name: GoReleaser (build linux-arm64 binaries)
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: ${{ env.GORELEASER_VERSION }}
args: build --skip-validate --rm-dist -f .goreleaser-linux-arm64.yml
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Upload assets (linux-arm64)
uses: actions/upload-artifact@v3
with:
name: dist-linux-arm64
path: dist-linux
build-binaries-windows:
needs: goreleaser-gate
runs-on: windows-2022
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: GoReleaser (build windows binaries)
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: ${{ env.GORELEASER_VERSION }}
args: build --skip-validate --rm-dist -f .goreleaser-windows.yml
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
- name: Upload assets (windows)
uses: actions/upload-artifact@v3
with:
name: dist-windows
path: dist-windows
publish:
if: startsWith(github.ref, 'refs/tags/v') # Only run this if it's a tag, e.g. v1.0.1
needs: [ build-binaries-darwin, build-binaries-linux-amd64, build-binaries-linux-arm64, build-binaries-windows ]
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Download darwin artifacts
uses: actions/download-artifact@v3
with:
name: dist-darwin
path: dist-darwin
- name: Download linux-amd64 artifacts
uses: actions/download-artifact@v3
with:
name: dist-linux-amd64
path: dist-linux
- name: Download linux-arm64 artifacts
uses: actions/download-artifact@v3
with:
name: dist-linux-arm64
path: dist-linux
- name: Download windows artifacts
uses: actions/download-artifact@v3
with:
name: dist-windows
path: dist-windows
- name: GoReleaser (publish)
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: ${{ env.GORELEASER_VERSION }}
args: release -f .goreleaser.yml
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
FURY_TOKEN: ${{ secrets.FURY_TOKEN }}