Files
prometheus-exporters/.gitea/workflows/varnish-exporter.yml
Ludovic Cartier b3a868de26
Some checks failed
build & package varnish exporter / validate (push) Failing after 4s
build & package varnish exporter / build (push) Has been skipped
remove tab
2025-07-21 16:00:45 +02:00

97 lines
3.3 KiB
YAML

name: build & package varnish exporter
on:
schedule:
- cron: '0 5 * * *'
push:
tags:
- '*'
jobs:
validate:
runs-on: ubuntu-latest
outputs:
status: ${{ steps.new_version.outputs.status }}
steps:
- uses: actions/checkout@v4
- name: Get latest release version
id: new_version
run: |
CURRENT=`cat .version`
LATEST=`curl --silent https://api.github.com/repos/jonnenauha/prometheus_varnish_exporter/releases/latest | jq -r .tag_name | sed "s/v//"`
if [[ $LATEST -gt $CURRENT ]]; then echo $LATEST > .version; echo "status=build" >> $GITEA_OUTPUT; done
- uses: stefanzweifel/git-auto-commit-action@v6
with:
branch: main
file_pattern: '.version'
commit_user_name: gitea-actions[bot]
commit_user_email: no-replay@brainsys.io
commit_message: gitea-actions auto commit - update version
push_options: '--force'
build:
if: steps.validate.output.status == build
runs-on: ubuntu-latest
needs: validate
steps:
- uses: actions/checkout@v4
- name: Get version
run: VERSION=`cat .version`
- name: Setup go
uses: actions/setup-go@v4
with:
go-version: '>=1.20'
- name: Checkout varnish exporter
run: git clone https://github.com/jonnenauha/prometheus_varnish_exporter varnish
- name: Build varnish exporter for GNU/Linux / amd64
run: GOOS=linux GOARCH=amd64 go build -o ../bin/prometheus-varnish-exporter-amd64
working-directory: varnish
- name: Create deb dir tree
run: |
mkdir -p varnish-exporter-amd64/usr/bin
mkdir -p varnish-exporter-amd64/DEBIAN
- name: Copy binaries
run: |
cp bin/prometheus-varnish-exporter-amd64 varnish-exporter-amd64/usr/bin/prometheus-varnish-exporter
- name: Prepare amd64 control file
run: |
echo "Package: varnish-exporter" > varnish-exporter-amd64/DEBIAN/control
echo "Version: $VERSION" >> varnish-exporter-amd64/DEBIAN/control
echo "Maintainer: Ludovic Cartier <ludovic.cartier@alterway.fr>" >> varnish-exporter-amd64/DEBIAN/control
echo "Architecture: amd64" >> varnish-exporter-amd64/DEBIAN/control
echo "Homepage: https://git.brainsys.io/packages/prometheus-exporters" >> varnish-exporter-amd64/DEBIAN/control
echo "Description: Prometheus Exporters package for GNU/Linux Debian" >> varnish-exporter-amd64/DEBIAN/control
- name: Build deb files
run: |
dpkg -b varnish-exporter-amd64 bin/prometheus-varnish-exporter-amd64.deb
- name: Prepare apt repo upload
run: |
mv bin/prometheus-varnish-exporter-amd64.deb prometheus-varnish-exporter_$VERSION-1_amd64.deb
- name: Release packages
run: |
curl -s -u "${{ secrets.PACKAGE_TOKEN }}" --upload-file prometheus-varnish-exporter_$VERSION-1_amd64.deb \
https://git.brainsys.io/api/packages/packages/debian/pool/stable/main/upload
- name: Create release
uses: https://gitea.com/actions/release-action@main
with:
draft: false
prerelease: false
files: |-
bin/**
api_key: "${{ secrets.RELEASE_TOKEN }}"
continue-on-error: true