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@v7 - uses: actions/setup-go@v7 with: go-version: "1.25" 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@v7 - uses: actions/setup-go@v7 with: go-version: "1.25" 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 -X main.version=${GITHUB_REF_NAME}" ./cmd/kctl-tui echo "Built $out" - name: Upload artifact uses: actions/upload-artifact@v7 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/checkout@v7 with: fetch-depth: 0 - name: Extract release notes from commit message id: release run: | MSG=$(git log -1 --pretty=format:"%B" "${{ github.sha }}") { echo 'body<> "$GITHUB_OUTPUT" - uses: actions/download-artifact@v8 with: path: dist merge-multiple: true - name: Create release and upload binaries uses: softprops/action-gh-release@v3 with: body: ${{ steps.release.outputs.body }} files: dist/*