Skip to content

Commit

Permalink
build deb package
Browse files Browse the repository at this point in the history
  • Loading branch information
mobileoverlord committed Jul 31, 2024
1 parent d65c919 commit 7a9e360
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/build_push_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,76 @@ jobs:
else
echo "Skipping latest tag update for pre-release tag ${{ env.RELEASE_TAG }}"
fi
build_packages:
runs-on: "${{ matrix.os }}"
needs: create_release_artifacts

strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest-4-cores-arm64
target: arm64
- os: ubuntu-latest
target: amd64

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set Env
run: |
echo "RELEASE_TAG=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Cache Debian packages
uses: actions/cache@v3
with:
path: ~/.cache/deb
key: ${{ runner.os }}-deb-cache
restore-keys: |
${{ runner.os }}-deb-cache
- name: Install build dependencies
run: |
sudo apt-get update
sudo apt-get install -y dpkg-dev debhelper fakeroot
- name: Download build artifact
uses: actions/download-artifact@v3
with:
with:
name: peridiod-${{ matrix.target }}.tar.gz
path: peridiod-${{ matrix.target }}.tar.gz

- name: Build DEB package
run: |
source release/package_info.sh
PERIDIOD_ARCH=${{ matrix.target }}
PERIDIOD_VERSION=$(echo "${GITHUB_REF#refs/*/}" | sed 's/^v//')
PERIDIOD_DEB_PACKAGE_DIR=$(pwd)/package/peridiod_${PERIDIOD_VERSION}_${PERIDIOD_ARCH}
PERIDIOD_RELEASE_NOTES=$(sed -e "/^## ${RELEASE_TAG}/,/^## / ! d" CHANGELOG.md | tail -n +2 | head -n -1)
export PERIDIOD_RELEASE_NOTES
export PERIDIOD_VERSION
export PERIDIOD_ARCH
mkdir -p $PERIDIOD_DEB_PACKAGE_DIR/DEBIAN $PERIDIOD_DEB_PACKAGE_DIR/opt/peridiod $PERIDIOD_DEB_PACKAGE_DIR/etc/systemd/system/
envsubst < release/deb/control > $PERIDIOD_DEB_PACKAGE_DIR/DEBIAN/control
envsubst < release/deb/changelog > $PERIDIOD_DEB_PACKAGE_DIR/DEBIAN/changelog
cp release/deb/postinit $PERIDIOD_DEB_PACKAGE_DIR/DEBIAN
cp release/deb/orerm $PERIDIOD_DEB_PACKAGE_DIR/DEBIAN
tar -xvf peridiod-${{ matrix.target }}.tar.gz -C $PERIDIOD_DEB_PACKAGE_DIR/DEBIAN/opt/peridiod
cp release/deb/peridiod.service $PERIDIOD_DEB_PACKAGE_DIR/etc/systemd/system/
dpkg-deb --build $PERIDIOD_DEB_PACKAGE_DIR
mv "${PERIDIOD_DEB_PACKAGE_DIR}.deb" .
echo "PERIDIOD_DEB_PACKAGE=peridiod_${PERIDIOD_VERSION}_${PERIDIOD_ARCH}.deb" >> $GITHUB_ENV
- name: Upload Release Asset
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload $RELEASE_TAG ${PERIDIOD_DEB_PACKAGE} --clobber
5 changes: 5 additions & 0 deletions release/deb/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
peridiod ($PERIDIOD_VERSION) ; urgency=medium

$PERIDIOD_RELEASE_NOTES

-- $PERIDIOD_MAINTAINER $(date -R)
11 changes: 11 additions & 0 deletions release/deb/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Package: peridiod
Version: $PERIDIOD_VERSION
License: $PERIDIOD_LICENSE
Vendor: $PERIDIOD_VENDOR
Architecture: $PERIDIOD_ARCH
Maintainer: $PERIDIOD_MAINTAINER
Depends: libc6, libncurses5 | libncurses6, libssl1.1 | libssl3, zlib1g
Section: devel
Priority: optional
Homepage: $PERIDIOD_HOMEPAGE
Description: $PERIDIOD_DESCRIPTION
11 changes: 11 additions & 0 deletions release/deb/peridiod.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=Peridio Daemon
[Service]
Restart=on-failure
RestartSec=5s

ExecStart=/opt/peridiod/bin/peridiod start
User=root

[Install]
WantedBy=multi-user.target
8 changes: 8 additions & 0 deletions release/deb/postinstall
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e

# Enable and start the systemd service
if [ "$1" = "configure" ]; then
systemctl enable peridiod.service
systemctl start peridiod.service
fi
8 changes: 8 additions & 0 deletions release/deb/prerm
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -e

# Stop and disable the systemd service
if [ "$1" = "remove" ]; then
systemctl stop peridiod.service
systemctl disable peridiod.service
fi
13 changes: 13 additions & 0 deletions release/package-info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env sh

PERIDIOD_LICENSE="Apache 2.0"
PERIDIOD_VENDOR="[email protected]"
PERIDIOD_MAINTAINER="Peridio <[email protected]>"
PERIDIOD_HOMEPAGE="https://www.peridio.com"
PERIDIOD_DESCRIPTION="Peridio Daemon for Managing Embedded Linux Products"

export PERIDIOD_LICENSE
export PERIDIOD_VENDOR
export PERIDIOD_MAINTAINER
export PERIDIOD_HOMEPAGE
export PERIDIOD_DESCRIPTION

0 comments on commit 7a9e360

Please sign in to comment.