diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index c26f37a..0a8a8fa 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -1,4 +1,4 @@ -name: Exporter Release +name: Release on: push: tags: @@ -28,12 +28,18 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_CLI_TOKEN }} - - name: Generate goreleaser release - uses: goreleaser/goreleaser-action@v4 + - name: Get Image Tags + id: tags + run: | + version=$(sed 's/^v//' <<< ${{ github.ref_name }}) + echo tags="latest,${version}" >> $GITHUB_OUTPUT + + - name: Build and Push + uses: docker/bake-action@v2 env: - IMAGE_REGISTRY: "natsio" - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + TAGS: "${{ steps.tags.outputs.tags }}" + REGISTRY: "natsio" with: - distribution: goreleaser - version: latest - args: release --rm-dist + push: true + set: + goreleaser.args.GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml index 21cb408..f04a439 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -70,71 +70,3 @@ nfpms: license: Apache 2.0 formats: - deb - -dockers: - - use: buildx - ids: - - prometheus-nats-exporter - dockerfile: docker/linux/Dockerfile - goos: linux - goarch: amd64 - image_templates: - - "{{ .Env.IMAGE_REPOSITORY }}:{{ if .IsSnapshot }}{{ .Version }}{{ else }}{{ .Tag }}{{ end }}-amd64" - build_flag_templates: - - "--platform=linux/amd64" - - "--label=org.opencontainers.image.created={{ .Date }}" - - "--label=org.opencontainers.image.title={{ .ProjectName }}" - - "--label=org.opencontainers.image.revision={{ .FullCommit }}" - - "--label=org.opencontainers.image.version={{ .Version }}" - - use: buildx - ids: - - prometheus-nats-exporter - dockerfile: docker/linux/Dockerfile - goos: linux - goarch: arm64 - image_templates: - - "{{ .Env.IMAGE_REPOSITORY }}:{{ if .IsSnapshot }}{{ .Version }}{{ else }}{{ .Tag }}{{ end }}-arm64" - build_flag_templates: - - "--platform=linux/arm64" - - "--label=org.opencontainers.image.created={{ .Date }}" - - "--label=org.opencontainers.image.title={{ .ProjectName }}" - - "--label=org.opencontainers.image.revision={{ .FullCommit }}" - - "--label=org.opencontainers.image.version={{ .Version }}" - - use: buildx - ids: - - prometheus-nats-exporter - dockerfile: docker/linux/Dockerfile - goos: linux - goarch: arm - goarm: 6 - image_templates: - - "{{ .Env.IMAGE_REPOSITORY }}:{{ if .IsSnapshot }}{{ .Version }}{{ else }}{{ .Tag }}{{ end }}-armv6" - build_flag_templates: - - "--platform=linux/arm/v6" - - "--label=org.opencontainers.image.created={{ .Date }}" - - "--label=org.opencontainers.image.title={{ .ProjectName }}" - - "--label=org.opencontainers.image.revision={{ .FullCommit }}" - - "--label=org.opencontainers.image.version={{ .Version }}" - - use: buildx - ids: - - prometheus-nats-exporter - dockerfile: docker/linux/Dockerfile - goos: linux - goarch: arm - goarm: 7 - image_templates: - - "{{ .Env.IMAGE_REPOSITORY }}:{{ if .IsSnapshot }}{{ .Version }}{{ else }}{{ .Tag }}{{ end }}-armv7" - build_flag_templates: - - "--platform=linux/arm/v7" - - "--label=org.opencontainers.image.created={{ .Date }}" - - "--label=org.opencontainers.image.title={{ .ProjectName }}" - - "--label=org.opencontainers.image.revision={{ .FullCommit }}" - - "--label=org.opencontainers.image.version={{ .Version }}" - -docker_manifests: - - name_template: "{{ .Env.IMAGE_REPOSITORY }}:{{ if .IsSnapshot }}{{ .Version }}{{ else }}{{ .Tag }}{{ end }}" - image_templates: - - "{{ .Env.IMAGE_REPOSITORY }}:{{ if .IsSnapshot }}{{ .Version }}{{ else }}{{ .Tag }}{{ end }}-amd64" - - "{{ .Env.IMAGE_REPOSITORY }}:{{ if .IsSnapshot }}{{ .Version }}{{ else }}{{ .Tag }}{{ end }}-arm64" - - "{{ .Env.IMAGE_REPOSITORY }}:{{ if .IsSnapshot }}{{ .Version }}{{ else }}{{ .Tag }}{{ end }}-armv6" - - "{{ .Env.IMAGE_REPOSITORY }}:{{ if .IsSnapshot }}{{ .Version }}{{ else }}{{ .Tag }}{{ end }}-armv7" diff --git a/cicd/Dockerfile b/cicd/Dockerfile new file mode 100644 index 0000000..3b3b1d6 --- /dev/null +++ b/cicd/Dockerfile @@ -0,0 +1,38 @@ +#syntax=docker/dockerfile-upstream:1.4 +ARG GO_APP + +FROM base as deps + +ARG GO_APP + +ARG TARGETOS +ARG TARGETARCH +ARG TARGETVARIANT + +RUN mkdir -p /go/bin /go/src + +COPY --from=build /go/src/dist /go/src/dist + +RUN <