chore: added debian package build script
This commit is contained in:
parent
bd8537a334
commit
0de48f7479
6 changed files with 73 additions and 0 deletions
12
.forgejo/workflows/ci.yml
Normal file
12
.forgejo/workflows/ci.yml
Normal file
|
@ -0,0 +1,12 @@
|
|||
name: Build package
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- '[0-9]+.[0-9]+.[0-9]+'
|
||||
|
||||
jobs:
|
||||
typos:
|
||||
runs-on: alpine
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: deb/build.sh ${{ env.GITHUB_REF_NAME }} ${{ secrets.TOKEN }}
|
11
deb/app-exporter.service
Normal file
11
deb/app-exporter.service
Normal file
|
@ -0,0 +1,11 @@
|
|||
[Unit]
|
||||
Description=Prometheus Application version exporter for the Recycled Cloud
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=root
|
||||
ExecStart=/usr/local/bin/app-exporter
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
38
deb/build.sh
Executable file
38
deb/build.sh
Executable file
|
@ -0,0 +1,38 @@
|
|||
# Variables
|
||||
package_name=$(head -n1 go.mod | cut -d'/' -f2)
|
||||
version=$1
|
||||
|
||||
# deps
|
||||
apk add dpkg make go curl
|
||||
|
||||
# Structure
|
||||
deb_folder="${package_name}_${version}-1_amd64"
|
||||
mkdir -vp \
|
||||
"${deb_folder}/usr/local/bin" \
|
||||
"${deb_folder}/lib/systemd/system" \
|
||||
"${deb_folder}/DEBIAN"
|
||||
|
||||
# Package content
|
||||
VERSION=$version make build
|
||||
cp -v "$package_name" "${deb_folder}/usr/local/bin/"
|
||||
cp -v deb/printer.service "${deb_folder}/lib/systemd/system/"
|
||||
|
||||
# DEBIAN
|
||||
cat - > "${deb_folder}/DEBIAN/control" <<EOF
|
||||
Package: ${package_name}
|
||||
Version: ${version}
|
||||
Architecture: amd64
|
||||
Maintainer: Valentin Doreau <valentin@recycled.cloud>
|
||||
Description: A Prometheus Application version exporter for the Recycled Cloud
|
||||
EOF
|
||||
cp deb/postinst "${deb_folder}/DEBIAN/"
|
||||
cp deb/prerm "${deb_folder}/DEBIAN/"
|
||||
cp deb/postrm "${deb_folder}/DEBIAN/"
|
||||
|
||||
# Package
|
||||
dpkg-deb --build --root-owner-group "$deb_folder"
|
||||
|
||||
curl --fail \
|
||||
-H "Authorization: token $2" \
|
||||
--upload-file "${deb_folder}.deb" \
|
||||
https://code.recycled.cloud/api/packages/RecycledCloud/debian/pool/bookworm/main/upload
|
5
deb/postinst
Executable file
5
deb/postinst
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable app-exporter
|
||||
systemctl start app-exporter
|
3
deb/postrm
Executable file
3
deb/postrm
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
systemctl daemon-reload
|
4
deb/prerm
Executable file
4
deb/prerm
Executable file
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
systemctl stop app-exporter
|
||||
systemctl disable app-exporter
|
Loading…
Reference in a new issue