diff --git a/.github/workflows/integration.yaml b/.github/workflows/integration.yaml index 4e9adc7..a487c4c 100644 --- a/.github/workflows/integration.yaml +++ b/.github/workflows/integration.yaml @@ -10,31 +10,33 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2.3.4 + - name: Setup go uses: actions/setup-go@v2.1.4 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/checkout@v2.3.4 + - name: Setup go uses: actions/setup-go@v2.1.4 with: go-version: '1.16.x' - - name: Build - run: make build - docker: - name: Docker - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.3.4 + - name: Build + run: go build ./... + - name: Docker - run: make docker + run: docker build . diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 71f21d6..3668b22 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -10,62 +10,26 @@ jobs: name: Release runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.4 + - name: Checkout + uses: actions/checkout@v2.3.4 + with: + fetch-depth: 0 + - name: Setup go - uses: actions/setup-go@v2.1.4 + uses: actions/setup-go@v2 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/create-release@v1.1.4 + go-version: 1.16.x + + - name: Login to Docker Hub + uses: docker/login-action@v1.10.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Release + uses: goreleaser/goreleaser-action@v2.6.1 + with: + version: latest + args: release --rm-dist env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - 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/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - 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/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - 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/upload-release-asset@v1.0.2 - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - 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/upload-release-asset@v1.0.2 - 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 diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..4c6303d --- /dev/null +++ b/.goreleaser.yml @@ -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:' diff --git a/Dockerfile b/Dockerfile index 56ed9f5..127e727 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 @@ -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 diff --git a/Makefile b/Makefile deleted file mode 100644 index 999a7d1..0000000 --- a/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -GOCMD = go -GOBUILD = $(GOCMD) build -GOCLEAN = $(GOCMD) clean -GOTEST = $(GOCMD) test -GOVET = $(GOCMD) vet -GOGET = $(GOCMD) get -GOX = $(GOPATH)/bin/gox -GOGET = $(GOCMD) get - -GOX_ARGS = -output="$(BUILD_DIR)/{{.Dir}}-{{.OS}}-{{.Arch}}" -osarch="linux/amd64 darwin/amd64 freebsd/amd64" - -BUILD_DIR = build -BINARY_NAME = prometheus-jitsi-meet-exporter - -all: clean vet test build - -build: - $(GOBUILD) -o $(BUILD_DIR)/$(BINARY_NAME) -v - -vet: - ${GOVET} ./... - -test: - ${GOTEST} ./... - -coverage: - ${GOTEST} -coverprofile=coverage.txt -covermode=atomic ./... - -clean: - $(GOCLEAN) - rm -f $(BUILD_DIR)/* - -run: build - ./$(BUILD_DIR)/$(BINARY_NAME) - -release: - ${GOGET} -u github.com/mitchellh/gox - ${GOX} -ldflags "${LD_FLAGS}" ${GOX_ARGS} - shasum -a 512 build/* > build/sha512sums.txt - -docker: - docker build --rm --force-rm --no-cache -t systemli/prometheus-jitsi-meet-exporter . - -.PHONY: all vet test coverage clean build run release docker