From 53901de63179a8c96320a3f0f35d77c0f911acd7 Mon Sep 17 00:00:00 2001 From: "maximilian.schubert@telekom.de" Date: Thu, 30 Nov 2023 13:16:51 +0100 Subject: [PATCH] ci: test go releaser --- .github/workflows/artifacts.yml | 30 +++++++++--------------------- .github/workflows/go-releaser.yml | 29 +++++++++++++++++++++++++++++ .goreleaser.yaml | 30 ++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/go-releaser.yml create mode 100644 .goreleaser.yaml diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index dc358b8a..10b63eec 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -13,27 +13,6 @@ permissions: contents: read jobs: - binary: - name: Binary - runs-on: ubuntu-latest - - permissions: - contents: read - - steps: - - uses: actions/checkout@v4 - - - name: Setup Go - uses: actions/setup-go@v4 - with: - go-version-file: "go.mod" - - - name: Install dependencies - run: go get . - - - name: Build - run: VERSION=${{ github.ref_name }} CGO_ENABLED=0 go build -ldflags "-s -w -X main.version=${VERSION}" -o sparrow . - container-image: name: Container image runs-on: ubuntu-latest @@ -127,3 +106,12 @@ jobs: GO_VERSION=${{ steps.go-version.outputs.value }} VERSION=${{ github.ref_name }} if: inputs.push + + - uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release + env: | + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + if: success() && inputs.releaseS + \ No newline at end of file diff --git a/.github/workflows/go-releaser.yml b/.github/workflows/go-releaser.yml new file mode 100644 index 00000000..52d36b8b --- /dev/null +++ b/.github/workflows/go-releaser.yml @@ -0,0 +1,29 @@ +name: Release (Test) + +on: [push] + +permissions: + contents: read + +jobs: + rel: + name: Release + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + id-token: write + security-events: write + + steps: + + - name: Checkout repository + uses: actions/checkout@v4 + + - uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release + env: | + GITHUB_TOKEN: ${{ secrets.GH_PAT }} \ No newline at end of file diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 00000000..3504c4ce --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,30 @@ +project_name: example +builds: + - env: [CGO_ENABLED=0] + goos: + - linux + goarch: + - amd64 + - arm64 +dockers: + - image_templates: ["ghcr.io/caas-team/sparrow:{{ .Version }}"] + dockerfile: Dockerfile + build_flag_templates: + - --label=org.opencontainers.image.title={{ .ProjectName }} + - --label=org.opencontainers.image.description={{ .ProjectName }} + - --label=org.opencontainers.image.url=https://caas.telekom.de + - --label=org.opencontainers.image.source=https://github.com/caas-team/sparrow + - --label=org.opencontainers.image.version={{ .Version }} + - --label=org.opencontainers.image.created={{ time.RFC3339 }} + - --label=org.opencontainers.image.revision={{ .FullCommit }} + - --label=org.opencontainers.image.licenses="Apache 2.0" +nfpms: + - maintainer: CaaS + description: |- + Monitoring tool to gather infrastructure network information + homepage: https://github.com/caas-team + license: Apache 2.0 + formats: + - deb + - rpm + - apk