diff --git a/.github/workflows/docker.yml b/.github/workflows/ci.yml similarity index 70% rename from .github/workflows/docker.yml rename to .github/workflows/ci.yml index 0e7da4b..3a040c3 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -name: Create and publish a container image +name: Create and publish artifacts on: push: @@ -15,7 +15,36 @@ concurrency: cancel-in-progress: true jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + + - name: Go Format + run: gofmt -s -w . && git diff --exit-code + + - name: Go Vet + run: go vet + + - name: Go Tidy + run: go mod tidy && git diff --exit-code + + - name: Go Mod + run: go mod download + + - name: Go Mod Verify + run: go mod verify + + - name: Install govulncheck + run: go install golang.org/x/vuln/cmd/govulncheck@latest + + - name: Run govulncheck + run: govulncheck + build-and-push-image: + needs: lint runs-on: ubuntu-latest timeout-minutes: 10 permissions: @@ -51,6 +80,7 @@ jobs: annotations: ${{ steps.meta.outputs.annotations }} releases-matrix: + needs: lint permissions: contents: write name: Release Go Binaries @@ -63,8 +93,11 @@ jobs: - uses: actions/checkout@v4 - uses: actions/setup-go@v5 - name: Build - run: | - GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CGO_ENABLED=0 go build -ldflags="-s -w" -trimpath -o pvpc_exporter main.go + run: go build -ldflags="-s -w" -trimpath -o pvpc_exporter main.go + env: + CGO_ENABLED: 0 + GOOS: ${{ matrix.goos }} + GOARCH: ${{ matrix.goarch }} - name: Compress run: zip pvpc_exporter-${{ matrix.goos }}-${{ matrix.goarch }}.zip pvpc_exporter - name: Create Release diff --git a/go.mod b/go.mod index 75462b7..5e16e54 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module pvpc_exporter -go 1.22.7 +go 1.23