Skip to content

Build

Build #660

Workflow file for this run

name: Build
on:
push:
pull_request:
schedule:
- cron: '0 17 * * 2'
jobs:
golangci-lint:
name: golangci-lint
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v2
generate:
name: go generate
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Check go generate
run: ./.github/scripts/gogenerate.sh
test:
name: go test
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Set up gotestfmt
uses: GoTestTools/gotestfmt-action@v2
- uses: actions/cache@v2
with:
path: |
~/go/pkg/mod
~/.cache/go-build
key: go-test-${{ hashFiles('**/go.sum') }}
restore-keys: go-test-
- name: Run go test
run: |
set -euo pipefail
go test -v ./... -json 2>&1 | tee /tmp/gotest.log | gotestfmt
- name: Upload test log
uses: actions/upload-artifact@v2
if: always()
with:
name: test-log
path: /tmp/gotest.log
if-no-files-found: error
goreleaser:
name: Release
needs:
- test
- golangci-lint
- generate
runs-on: ubuntu-latest
if: ${{ github.event_name != 'schedule' }}
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Import GPG key
id: import_gpg
if: startsWith(github.ref, 'refs/tags/')
run: |
echo -e "${GPG_PRIVATE_KEY}" | gpg --import --batch --no-tty
if [ -n "${PASSPHRASE}" ]; then
echo "" > /tmp/test.txt
gpg --detach-sig --yes -v --output=/dev/null --pinentry-mode loopback --passphrase "${PASSPHRASE}" /tmp/test.txt
rm /tmp/test.txt
fi
echo "::set-output name=fingerprint::$(gpg --with-colons --list-keys | awk -F: '/^pub/ { print $5 }')"
env:
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
- name: Run GoReleaser
if: startsWith(github.ref, 'refs/tags/')
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: release --rm-dist
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GPG_PASSWORD: ${{ secrets.PASSPHRASE }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
if: "!startsWith(github.ref, 'refs/tags/')"
uses: goreleaser/goreleaser-action@v3
with:
version: latest
args: build --snapshot