39 lines
1 KiB
Bash
39 lines
1 KiB
Bash
|
# 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
|