From ce40e759369e3d162b021e090b365f9cf38f2d40 Mon Sep 17 00:00:00 2001 From: zadjadr Date: Sun, 14 Jul 2024 18:38:30 +0200 Subject: [PATCH] ci: add package ci pipeline --- .github/workflows/package.yaml | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 .github/workflows/package.yaml diff --git a/.github/workflows/package.yaml b/.github/workflows/package.yaml new file mode 100644 index 0000000..0b7265e --- /dev/null +++ b/.github/workflows/package.yaml @@ -0,0 +1,63 @@ +name: Package + +on: + push: + branches: [main] + pull_request: + branches: [main] + create: + tags: + - "v*.*.*" + +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + + - name: Install dependencies + run: go mod download + + - name: Run linter + uses: golangci/golangci-lint-action@v6 + with: + version: latest + + - name: Run tests + run: go test -v ./... + + build-and-release: + needs: test + if: startsWith(github.ref, 'refs/tags/v') + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version-file: "go.mod" + + - name: Build + run: go build -v ./... + + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: | + Release.txt + LICENSE + prometheus-cve-exporter + + - name: Upload to GitHub Packages + uses: actions/upload-artifact@v4 + with: + name: prometheus-cve-exporter + path: ./prometheus-cve-exporter