app-exporter/deb/build.sh
Valentin Doreau 4e8830a711
All checks were successful
Build package / typos (push) Successful in 1m20s
chore: copy the service with the package's name
2024-11-01 19:57:59 +01:00

38 lines
1 KiB
Bash
Executable file

# 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/${package_name}.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