fix: release workflow #5
Workflow file for this run
This file contains hidden or 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: | |
branches: [ main ] | |
jobs: | |
test: | |
name: Test | |
runs-on: ubuntu-latest | |
# Required permissions for golangci-lint-action | |
permissions: | |
contents: read | |
pull-requests: read # Required for only-new-issues option | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v5.0.0 | |
- name: Set up Go | |
uses: actions/setup-go@v6.0.0 | |
with: | |
go-version: '1.25' | |
- name: Cache Go modules | |
uses: actions/cache@v4.3.0 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: Download dependencies | |
run: go mod download | |
- name: Verify dependencies | |
run: go mod verify | |
- name: Run go mod tidy | |
run: | | |
go mod tidy | |
if [ ! -z "$(git status --porcelain)" ]; then | |
echo "go mod tidy resulted in changes" | |
git status --porcelain | |
exit 1 | |
fi | |
- name: Run go vet | |
run: go vet ./... | |
- name: Run golangci-lint | |
uses: golangci/golangci-lint-action@v8.0.0 | |
with: | |
version: v2.5.0 # Use latest golangci-lint version | |
args: --timeout=5m --allow-parallel-runners | |
only-new-issues: true # Only show new issues in PRs | |
problem-matchers: true # Enable GitHub problem matchers for better annotations | |
- name: Run unit tests | |
run: go test -v -short -race -coverprofile=coverage.out ./... | |
- name: Install gosec | |
run: go install github.com/securego/gosec/v2/cmd/gosec@latest | |
- name: Run security scan | |
run: gosec -no-fail -fmt sarif -out gosec.sarif ./... | |
continue-on-error: true | |
- name: Upload security scan results | |
uses: github/codeql-action/upload-sarif@v3 | |
with: | |
sarif_file: gosec.sarif | |
continue-on-error: true | |
- name: Generate coverage report | |
run: go tool cover -html=coverage.out -o coverage.html | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v5.5.1 | |
with: | |
files: ./coverage.out | |
flags: unittests | |
name: codecov-umbrella | |
- name: Upload coverage reports as artifacts | |
uses: actions/upload-artifact@v4.6.2 | |
with: | |
name: coverage-reports | |
path: | | |
coverage.out | |
coverage.html | |
gosec.sarif | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
needs: test | |
permissions: | |
contents: read | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v5.0.0 | |
- name: Set up Go | |
uses: actions/setup-go@v6.0.0 | |
with: | |
go-version: '1.25' | |
- name: Build binary | |
run: go build -ldflags="-s -w" -o kubectx-manager | |
- name: Test binary | |
run: | | |
./kubectx-manager --help | |
./kubectx-manager version | |
- name: Upload binary as artifact | |
uses: actions/upload-artifact@v4.6.2 | |
with: | |
name: kubectx-manager-binary | |
path: kubectx-manager | |
cross-compile: | |
name: Cross-compile | |
runs-on: ubuntu-latest | |
needs: test | |
permissions: | |
contents: read | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v5.0.0 | |
- name: Set up Go | |
uses: actions/setup-go@v6.0.0 | |
with: | |
go-version: '1.25' | |
- name: Build for multiple platforms | |
run: | | |
# Linux | |
GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o kubectx-manager-linux-amd64 | |
GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o kubectx-manager-linux-arm64 | |
# macOS | |
GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o kubectx-manager-darwin-amd64 | |
GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o kubectx-manager-darwin-arm64 | |
# Windows | |
GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o kubectx-manager-windows-amd64.exe | |
- name: Upload cross-compiled binaries | |
uses: actions/upload-artifact@v4.6.2 | |
with: | |
name: kubectx-manager-cross-compiled | |
path: kubectx-manager-* |