Skip to content

Commit cd4009e

Browse files
committed
Add GitHub action to build Debian packages
1 parent 0f69669 commit cd4009e

6 files changed

Lines changed: 104 additions & 0 deletions

File tree

.github/workflows/build-release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,59 @@ jobs:
2222
GOOS=linux GOARCH=amd64 go build -o eldim-${{ steps.version.outputs.VERSION }}-linux-amd64 .
2323
GOOS=linux GOARCH=arm64 go build -o eldim-${{ steps.version.outputs.VERSION }}-linux-arm64 .
2424
GOOS=darwin GOARCH=arm64 go build -o eldim-${{ steps.version.outputs.VERSION }}-darwin-arm64 .
25+
- name: Build .deb packages
26+
run: |
27+
VERSION="${{ steps.version.outputs.VERSION }}"
28+
# Strip leading 'v' for the .deb version field
29+
DEB_VERSION="${VERSION#v}"
30+
31+
for ARCH in amd64 arm64; do
32+
PKG="eldim-${VERSION}-linux-${ARCH}-deb"
33+
34+
# Create directory structure
35+
mkdir -p "${PKG}/DEBIAN"
36+
mkdir -p "${PKG}/usr/bin"
37+
mkdir -p "${PKG}/etc/eldim"
38+
mkdir -p "${PKG}/lib/systemd/system"
39+
mkdir -p "${PKG}/usr/share/doc/eldim"
40+
41+
# Install binary
42+
cp "eldim-${VERSION}-linux-${ARCH}" "${PKG}/usr/bin/eldim"
43+
chmod 755 "${PKG}/usr/bin/eldim"
44+
45+
# Install config files
46+
cp eldim.yml "${PKG}/etc/eldim/eldim.yml"
47+
cp clients.yml "${PKG}/etc/eldim/clients.yml"
48+
49+
# Install systemd service
50+
cp eldim.service "${PKG}/lib/systemd/system/eldim.service"
51+
52+
# Install documentation
53+
cp README.md "${PKG}/usr/share/doc/eldim/"
54+
cp LICENSE "${PKG}/usr/share/doc/eldim/"
55+
cp docs/api.md "${PKG}/usr/share/doc/eldim/"
56+
cp docs/config.md "${PKG}/usr/share/doc/eldim/"
57+
cp docs/metrics.md "${PKG}/usr/share/doc/eldim/"
58+
59+
# DEBIAN control file
60+
sed -e "s/VERSION/${DEB_VERSION}/" -e "s/ARCHITECTURE/${ARCH}/" \
61+
debian/control.template > "${PKG}/DEBIAN/control"
62+
63+
# DEBIAN conffiles
64+
cp debian/conffiles "${PKG}/DEBIAN/conffiles"
65+
66+
# DEBIAN maintainer scripts
67+
cp debian/postinst "${PKG}/DEBIAN/postinst"
68+
cp debian/prerm "${PKG}/DEBIAN/prerm"
69+
cp debian/postrm "${PKG}/DEBIAN/postrm"
70+
chmod 755 "${PKG}/DEBIAN/postinst"
71+
chmod 755 "${PKG}/DEBIAN/prerm"
72+
chmod 755 "${PKG}/DEBIAN/postrm"
73+
74+
# Build the .deb and clean up the staging directory
75+
dpkg-deb --build "${PKG}" "eldim-${VERSION}-linux-${ARCH}.deb"
76+
rm -rf "${PKG}"
77+
done
2578
- name: Create Release
2679
uses: softprops/action-gh-release@v2
2780
with:

debian/conffiles

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/etc/eldim/eldim.yml
2+
/etc/eldim/clients.yml

debian/control.template

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
Package: eldim
2+
Version: VERSION
3+
Architecture: ARCHITECTURE
4+
Maintainer: Antonis Chariton <daknob@daknob.net>
5+
Homepage: https://github.com/daknob/eldim
6+
Section: utils
7+
Priority: optional
8+
Description: A secure log and backup storage proxy
9+
eldim is a web server that accepts file uploads from a particular set of
10+
hosts, encrypts them, and stores them in an Object Storage backend such as
11+
OpenStack Swift, Google Cloud Storage, or S3-compatible services.

debian/postinst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/sh
2+
set -e
3+
4+
case "$1" in
5+
configure)
6+
if ! id -u eldim >/dev/null 2>&1; then
7+
useradd -s /usr/sbin/nologin -r -M eldim
8+
fi
9+
chown -R eldim:eldim /etc/eldim
10+
chmod 700 /etc/eldim
11+
chmod 400 /etc/eldim/*.yml
12+
systemctl daemon-reload || true
13+
;;
14+
esac
15+
16+
exit 0

debian/postrm

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/sh
2+
set -e
3+
4+
case "$1" in
5+
purge)
6+
rm -rf /etc/eldim
7+
userdel eldim 2>/dev/null || true
8+
systemctl daemon-reload || true
9+
;;
10+
esac
11+
12+
exit 0

debian/prerm

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -e
3+
4+
case "$1" in
5+
remove|upgrade)
6+
systemctl stop eldim || true
7+
;;
8+
esac
9+
10+
exit 0

0 commit comments

Comments
 (0)