Skip to content

Commit

Permalink
Move CD to Goreleaser (#57)
Browse files Browse the repository at this point in the history
* move to goreleaser

* Apply suggestions from code review
  • Loading branch information
0x46616c6b authored Sep 14, 2021
1 parent f8d9d00 commit c2167be
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 116 deletions.
20 changes: 11 additions & 9 deletions .github/workflows/integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,33 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- name: Setup go
uses: actions/[email protected]
with:
go-version: '1.16.x'

- name: Vet
run: make vet
run: go vet

- name: Test
run: make coverage
run: go test ./...

build:
name: Build
runs-on: ubuntu-latest
needs:
- test
steps:
- uses: actions/[email protected]

- name: Setup go
uses: actions/[email protected]
with:
go-version: '1.16.x'

- name: Build
run: make build
run: go build ./...

docker:
name: Docker
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Docker
run: make docker
run: docker build .
70 changes: 17 additions & 53 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,62 +10,26 @@ jobs:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- name: Setup go
uses: actions/[email protected]
with:
go-version: '1.16.x'
- name: Create release artifacts
run: make release
env:
GOPATH: ${{ github.workspace }}/go
- name: Create Github Release
id: create_release
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/[email protected]
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload release artifacts (Mac OS amd64)
id: upload-release-asset-mac
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0

- name: Setup go
uses: actions/setup-go@v2
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/prometheus-jitsi-meet-exporter-darwin-amd64
asset_name: prometheus-jitsi-meet-exporter-darwin-amd64
asset_content_type: application/octet-stream
- name: Upload release artifacts (FreeBSD amd64)
id: upload-release-asset-freebsd
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
go-version: 1.16.x

- name: Login to Docker Hub
uses: docker/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/prometheus-jitsi-meet-exporter-freebsd-amd64
asset_name: prometheus-jitsi-meet-exporter-freebsd-amd64
asset_content_type: application/octet-stream
- name: Upload release artifacts (Linux amd64)
id: upload-release-asset-linux
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Release
uses: goreleaser/[email protected]
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/prometheus-jitsi-meet-exporter-linux-amd64
asset_name: prometheus-jitsi-meet-exporter-linux-amd64
asset_content_type: application/octet-stream
- name: Upload release artifacts (shasums)
id: upload-release-asset-sha512sums
uses: actions/[email protected]
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: build/sha512sums.txt
asset_name: sha512sums.txt
asset_content_type: application/octet-stream
34 changes: 34 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
before:
hooks:
- go mod tidy
builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin
goarm:
- 6
- 7
ldflags:
- -s -w
dockers:
-
goos: linux
goarch: amd64
image_templates:
- "systemli/prometheus-jitsi-meet-exporter:{{ .Tag }}"
- "systemli/prometheus-jitsi-meet-exporter:{{ .Major }}"
- "systemli/prometheus-jitsi-meet-exporter:{{ .Major }}.{{ .Minor }}"
- "systemli/prometheus-jitsi-meet-exporter:latest"
checksum:
name_template: 'checksums.txt'
snapshot:
name_template: "{{ .Tag }}-next"
changelog:
sort: asc
filters:
exclude:
- '^docs:'
- '^test:'
12 changes: 2 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.17.0-alpine as builder
FROM alpine:3.14.0 as builder

WORKDIR /go/src/github.com/systemli/prometheus-jitsi-meet-exporter

Expand All @@ -14,20 +14,12 @@ RUN adduser \
--uid "${UID}" \
"${USER}"

ADD . /go/src/github.com/systemli/prometheus-jitsi-meet-exporter
RUN apk --update add ca-certificates && \
go get -d -v && \
go mod download && \
go mod verify && \
CGO_ENABLED=0 go build -ldflags="-w -s" -o /prometheus-jitsi-meet-exporter


FROM scratch

COPY --from=builder /etc/passwd /etc/passwd
COPY --from=builder /etc/group /etc/group
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
COPY --from=builder /prometheus-jitsi-meet-exporter /prometheus-jitsi-meet-exporter
COPY prometheus-jitsi-meet-exporter /prometheus-jitsi-meet-exporter

USER appuser:appuser

Expand Down
44 changes: 0 additions & 44 deletions Makefile

This file was deleted.

0 comments on commit c2167be

Please sign in to comment.