Improve workflow speed & build binaries #381
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: ci | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
jobs: | |
lint: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@v6 | |
with: | |
args: --timeout=5m | |
build-test: | |
name: test | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install just | |
uses: taiki-e/install-action@just | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Build and run tests with race detector enabled | |
run: just test-race | |
build: | |
name: Build and Publish | |
runs-on: ubuntu-latest | |
# if: github.event_name != 'pull_request' | |
strategy: | |
matrix: | |
goos: [linux, darwin] | |
goarch: [amd64] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Setup Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: go.mod | |
- name: Build | |
run: | | |
mkdir -p dist | |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o dist/cofidectl-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/cofidectl/main.go | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: cofidectl-${{ matrix.goos }}-${{ matrix.goarch }} | |
path: dist/cofidectl-${{ matrix.goos }}-${{ matrix.goarch }} |