mirror of
https://github.com/skoelle/kctl-tui.git
synced 2026-09-17 20:10:24 +00:00
88 lines
1.9 KiB
YAML
88 lines
1.9 KiB
YAML
name: Build and Test
|
|
|
|
on:
|
|
push:
|
|
branches: [ "main" ]
|
|
tags: [ "v*" ]
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
test:
|
|
name: Test
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.22"
|
|
cache: false
|
|
|
|
- name: Tidy dependencies (generates/updates go.sum)
|
|
run: go mod tidy
|
|
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
- name: Run tests
|
|
run: go test ./... -v -cover
|
|
|
|
build:
|
|
name: Build binaries
|
|
needs: test
|
|
runs-on: ubuntu-latest
|
|
strategy:
|
|
matrix:
|
|
goos: [linux, windows, darwin]
|
|
goarch: [amd64, arm64]
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.22"
|
|
cache: false
|
|
|
|
- name: Tidy dependencies (generates/updates go.sum)
|
|
run: go mod tidy
|
|
|
|
- name: Build
|
|
env:
|
|
GOOS: ${{ matrix.goos }}
|
|
GOARCH: ${{ matrix.goarch }}
|
|
CGO_ENABLED: 0
|
|
run: |
|
|
mkdir -p dist
|
|
ext=""
|
|
if [ "${{ matrix.goos }}" = "windows" ]; then ext=".exe"; fi
|
|
out="dist/kctl-tui-${{ matrix.goos }}-${{ matrix.goarch }}${ext}"
|
|
go build -o "$out" -ldflags "-s -w" ./cmd/kctl-tui
|
|
echo "Built $out"
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: kctl-tui-${{ matrix.goos }}-${{ matrix.goarch }}
|
|
path: dist/*
|
|
|
|
release:
|
|
name: Attach binaries to GitHub Release
|
|
if: startsWith(github.ref, 'refs/tags/v')
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
path: dist
|
|
merge-multiple: true
|
|
|
|
- name: Create release and upload binaries
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: dist/*
|
|
generate_release_notes: true
|