Skip to content

Commit

Permalink
Merge pull request #39 from hikhvar/add-nfpm
Browse files Browse the repository at this point in the history
Add debian packages
  • Loading branch information
hikhvar authored Feb 22, 2021
2 parents 24df81e + 252a63e commit 3e65257
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 38 deletions.
32 changes: 0 additions & 32 deletions .github/workflows/release_test.yml

This file was deleted.

32 changes: 27 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
test:
strategy:
matrix:
go-version: [1.14.x, 1.15.x]
go-version: [1.14.x, 1.15.x, 1.16.x]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand All @@ -28,9 +28,31 @@ jobs:
uses: actions/checkout@v2
- name: Run golangci-lint
uses: actions-contrib/golangci-lint@v1
image-build:

goreleaser:
needs:
- test
- linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag mqtt2prometheus:${GITHUB_REF##*/}
- name: Checkout
uses: actions/checkout@v2
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v1
with:
go-version: 1.15.x
- name: Test
run: go test -cover ./...
- name: Vet
run: go vet ./...
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v1
with:
version: latest
args: release --rm-dist --skip-publish
25 changes: 25 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,31 @@ changelog:
exclude:
- '^docs:'
- '^test:'
- '^ci:'

nfpms:
- id: default
vendor: Christoph Petrausch
homepage: https://github.com/hikhvar/mqtt2prometheus
description: This exporter translates from MQTT topics to prometheus metrics.
license: MIT License
formats:
- deb
- rpm
- apk
conflicts:
- prometheus-mqtt-exporter
scripts:
postinstall: systemd/postinstall.sh
contents:
# Simple config file
- src: config.yaml.dist
dst: /etc/mqtt2prometheus/config.yaml
type: config
- src: ./systemd/mqtt2prometheus.service
dst: /etc/systemd/system/mqtt2prometheus.service
type: config


dockers:

Expand Down
8 changes: 7 additions & 1 deletion systemd/mqtt2prometheus.service
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
[Unit]
Description=Simple translator from mqtt messages to prometheus. Analog to pushgateway
Documentation=https://github.com/hikhvar/mqtt2prometheus
Before=prometheus.service

[Service]
ExecStart=/opt/mqtt2prometheus/mqtt2prometheus -config /etc/mqtt2prometheus/config.yaml -port 8002
Restart=always
User=mqtt2prometheus
EnvironmentFile=/etc/default/prometheus-mqtt-exporter
ExecStart=/opt/mqtt2prometheus/mqtt2prometheus -config /etc/mqtt2prometheus/config.yaml $ARGS
TimeoutStopSec=20s


[Install]
WantedBy=multi-user.target
6 changes: 6 additions & 0 deletions systemd/postinstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh

user=mqtt2prometheus
if ! getent passwd "${user}" > /dev/null; then
useradd --system --home-dir /var/lib/${user} --no-create-home || true
fi

0 comments on commit 3e65257

Please sign in to comment.