Skip to content

Commit

Permalink
ci: use goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjadr committed Jul 18, 2024
1 parent 5852138 commit e76466a
Showing 3 changed files with 55 additions and 27 deletions.
47 changes: 20 additions & 27 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,44 +1,37 @@
name: Release
name: release

on:
workflow_run:
workflows: ["Test"]
types:
- completed
create:
push:
# run only against tags
tags:
- "v*.*.*"

permissions:
contents: write
packages: write

jobs:
build-and-release:
if: github.event.workflow_run.conclusion == 'success'
goreleaser:
runs-on: ubuntu-latest

permissions:
contents: write

steps:
- uses: actions/checkout@v4

- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"

- name: Build
run: go build -v -o ./bin/ ./...

- name: Create Release
if: startsWith(github.ref, 'refs/tags/')
uses: softprops/action-gh-release@v2
with:
files: |
Release.txt
LICENSE
./bin/prometheus-cve-exporter
- name: Upload to GitHub Packages
uses: actions/upload-artifact@v4
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
name: prometheus-cve-exporter
path: ./bin/prometheus-cve-exporter
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: "~> v1"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32 changes: 32 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
project_name: prometheus-cve-exporter
builds:
- env: [CGO_ENABLED=0]
main: ./cmd/prometheus-cve-exporter
goos:
- linux
- windows
- darwin
goarch:
- amd64
- arm64
dockers:
- image_templates: ["ghcr.io/zadjadr/prometheus-cve-exporter:{{ .Version }}"]
dockerfile: Dockerfile
build_flag_templates:
- --label=org.opencontainers.image.title={{ .ProjectName }}
- --label=org.opencontainers.image.description="Prometheus CVE Exporter is a Golang application that scans your system for all installed packages and compares them with the recent NVD JSON feed. It exports metrics that provide insights into the security status of your packages."
- --label=org.opencontainers.image.url=https://github.com/zadjadr/prometheus-cve-exporter
- --label=org.opencontainers.image.source=https://github.com/zadjadr/prometheus-cve-exporter
- --label=org.opencontainers.image.version={{ .Version }}
- --label=org.opencontainers.image.created={{ time "2006-01-02T15:04:05Z07:00" }}
- --label=org.opencontainers.image.revision={{ .FullCommit }}
- --label=org.opencontainers.image.licenses=MIT
nfpms:
- maintainer: Zadjad Rezai <me@zops.top>
description: Prometheus CVE Exporter is a Golang application that scans your system for all installed packages and compares them with the recent NVD JSON feed. It exports metrics that provide insights into the security status of your packages.
homepage: https://github.com/zadjadr/prometheus-cve-exporter
license: MIT
formats:
- deb
- rpm
- apk
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM scratch
COPY prometheus-cve-exporter /usr/bin/prometheus-cve-exporter
ENTRYPOINT ["/usr/bin/prometheus-cve-exporter"]

0 comments on commit e76466a

Please sign in to comment.