refactor yaml config 4 #311
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Main pipeline | |
on: | |
push: | |
paths-ignore: | |
- '**.md' | |
- 'sq.json' # This is updated by scoop; no need to run a new build | |
# Allows this workflow to be manually triggered from the Actions tab | |
workflow_dispatch: | |
env: | |
GO_VERSION: 1.20.2 | |
GORELEASER_VERSION: 1.13.1 | |
GOLANGCI_LINT_VERSION: v1.52.2 | |
jobs: | |
test-linux-darwin: | |
strategy: | |
matrix: | |
os: [ ubuntu-22.04, macos-12] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
# Install gotestfmt on the VM running the action. | |
- name: Set up gotestfmt | |
uses: gotesttools/gotestfmt-action@v2 | |
with: | |
# Optional: pass GITHUB_TOKEN to avoid rate limiting. | |
token: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build | |
run: go build -v ./... | |
# Run tests with nice formatting. Save the original log in /tmp/gotest.log | |
# https://github.com/GoTestTools/gotestfmt#github-actions | |
- name: Run tests | |
run: | | |
set -euo pipefail | |
go test -json -v ./... 2>&1 | tee gotest.log | gotestfmt | |
# Upload the original go test log as an artifact for later review. | |
- name: Upload test log | |
uses: actions/upload-artifact@v3 | |
if: always() | |
with: | |
name: test-log | |
path: gotest.log | |
if-no-files-found: warn | |
test-windows: | |
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: Run tests | |
run: | | |
go test -v ./... | |
go-lint: | |
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: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: ${{ env.GOLANGCI_LINT_VERSION }} | |
coverage: | |
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: Test | |
run: go test -v ./... | |
# https://github.com/ncruces/go-coverage-report | |
- name: Update coverage report | |
uses: ncruces/go-coverage-report@v0 | |
with: | |
report: 'true' | |
chart: 'true' | |
amend: 'false' | |
if: | | |
github.event_name == 'push' | |
continue-on-error: true | |
binaries-darwin: | |
if: startsWith(github.ref, 'refs/tags/v') | |
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 | |
binaries-linux-amd64: | |
if: startsWith(github.ref, 'refs/tags/v') | |
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 | |
binaries-linux-arm64: | |
if: startsWith(github.ref, 'refs/tags/v') | |
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 | |
binaries-windows: | |
if: startsWith(github.ref, 'refs/tags/v') | |
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: | |
runs-on: ubuntu-22.04 | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: | |
- go-lint | |
- test-linux-darwin | |
- test-windows | |
- binaries-darwin | |
- binaries-linux-amd64 | |
- binaries-linux-arm64 | |
- binaries-windows | |
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: Generate CHANGELOG delta for Goreleaser to consume | |
run: ./.generate-changelog-delta.sh > ./.CHANGELOG.delta.md | |
- name: GoReleaser (publish) | |
uses: goreleaser/goreleaser-action@v3 | |
with: | |
distribution: goreleaser-pro | |
version: ${{ env.GORELEASER_VERSION }} | |
args: release --release-notes=./.CHANGELOG.delta.md -f .goreleaser.yml | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }} | |
FURY_TOKEN: ${{ secrets.FURY_TOKEN }} | |
AUR_PRIVATE_KEY: ${{ secrets.AUR_PRIVATE_KEY }} | |
install: | |
# Verify that install mechanisms are working on the various | |
# supported platforms. This workflow runs *after* the new release | |
# has been published. So, if this workflow fails, it means that | |
# users are experiencing those failures. Fix the problem ASAP! | |
needs: publish | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: ./.github/workflows/test-install.yml |