mirror of
https://github.com/neilotoole/sq.git
synced 2024-12-18 13:41:49 +03:00
336 lines
8.8 KiB
YAML
336 lines
8.8 KiB
YAML
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.21.0
|
|
GORELEASER_VERSION: 1.20.0
|
|
GOLANGCI_LINT_VERSION: v1.55.2
|
|
TPARSE_VERSION: v0.13.2
|
|
BUILD_TAGS: 'sqlite_vtable sqlite_stat4 sqlite_fts5 sqlite_introspect sqlite_json sqlite_math_functions'
|
|
|
|
jobs:
|
|
test-nix:
|
|
strategy:
|
|
matrix:
|
|
os: [ ubuntu-22.04, macos-12]
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
|
|
- name: Build
|
|
run: go build -tags '${{ env.BUILD_TAGS }}' -v ./...
|
|
|
|
- name: 'Go tests'
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
|
|
# We tee the go test output to a file, so that "tparse" can
|
|
# render pretty output below.
|
|
go test -tags '${{ env.BUILD_TAGS }}' -timeout 20m -v -json -cover ./... | tee gotest.out.json
|
|
|
|
- name: 'Test output'
|
|
if: always()
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
go install github.com/mfridman/tparse@${{ env.TPARSE_VERSION }}
|
|
tparse -all -sort=elapsed -file gotest.out.json
|
|
|
|
|
|
test-windows:
|
|
runs-on: windows-2022
|
|
steps:
|
|
# Copied from https://github.com/mattn/go-sqlite3/blob/master/.github/workflows/go.yaml#L73
|
|
# - uses: msys2/setup-msys2@v2
|
|
# with:
|
|
# update: true
|
|
# install: mingw-w64-x86_64-toolchain mingw-w64-x86_64-sqlite3
|
|
# msystem: MINGW64
|
|
# path-type: inherit
|
|
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: Build
|
|
run: go build -tags '${{ env.BUILD_TAGS }}' -v ./...
|
|
# shell: msys2 {0}
|
|
|
|
# - name: Run tests
|
|
# run: |
|
|
# go test -tags '${{ env.BUILD_TAGS }}' -v ./...
|
|
## shell: msys2 {0}
|
|
|
|
- name: 'Go tests'
|
|
shell: bash
|
|
run: |
|
|
# set -e
|
|
|
|
# We send the Go test output to a file, so that "tparse" can
|
|
# render pretty output below.
|
|
go test -tags '${{ env.BUILD_TAGS }}' -timeout 20m -v -json -cover ./... > gotest.out.json
|
|
|
|
- name: 'Test output'
|
|
if: always()
|
|
shell: bash
|
|
run: |
|
|
set -e
|
|
go install github.com/mfridman/tparse@${{ env.TPARSE_VERSION }}
|
|
tparse -all -sort=elapsed -file gotest.out.json
|
|
|
|
lint:
|
|
runs-on: ubuntu-22.04
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Lint GH workflow files
|
|
run: |
|
|
# From https://github.com/rhysd/actionlint
|
|
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
|
./actionlint -color
|
|
|
|
- name: shellcheck
|
|
run: |
|
|
shellcheck ./install.sh
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: golangci-lint
|
|
uses: golangci/golangci-lint-action@v3
|
|
with:
|
|
skip-cache: true
|
|
version: ${{ env.GOLANGCI_LINT_VERSION }}
|
|
|
|
|
|
binaries-darwin:
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
runs-on: macos-12
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: GoReleaser (build darwin binaries)
|
|
uses: goreleaser/goreleaser-action@v3
|
|
with:
|
|
distribution: goreleaser-pro
|
|
version: ${{ env.GORELEASER_VERSION }}
|
|
args: build --skip-validate --clean -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@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: GoReleaser (build linux-amd64 binaries)
|
|
uses: goreleaser/goreleaser-action@v3
|
|
with:
|
|
distribution: goreleaser-pro
|
|
version: ${{ env.GORELEASER_VERSION }}
|
|
args: build --skip-validate --clean -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@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- 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 --clean -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@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- name: GoReleaser (build windows binaries)
|
|
uses: goreleaser/goreleaser-action@v3
|
|
with:
|
|
distribution: goreleaser-pro
|
|
version: ${{ env.GORELEASER_VERSION }}
|
|
args: build --skip-validate --clean -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:
|
|
- lint
|
|
- test-nix
|
|
- test-windows
|
|
- binaries-darwin
|
|
- binaries-linux-amd64
|
|
- binaries-linux-arm64
|
|
- binaries-windows
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v4
|
|
with:
|
|
go-version-file: go.mod
|
|
|
|
- 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
|