From 8bd8102cd105d0e7303b2f464ceb904c98349765 Mon Sep 17 00:00:00 2001 From: Attila Gombos Date: Mon, 6 Apr 2026 22:17:12 +0200 Subject: [PATCH] Add Debian packaging for amd64 and arm64 --- .github/workflows/release.yml | 49 ++++++++++++++++++++++------ .gitignore | 1 + debian/mediamtx.service | 12 +++++++ debian/package.sh | 60 +++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 10 deletions(-) create mode 100644 debian/mediamtx.service create mode 100644 debian/package.sh diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index dc91354cff5..cc5e3f7ba86 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -8,7 +8,6 @@ on: permissions: id-token: write attestations: write - artifact-metadata: write contents: write issues: write @@ -32,16 +31,44 @@ jobs: name: binaries path: binaries - github_release: + packages: needs: binaries runs-on: ubuntu-22.04 + strategy: + matrix: + arch: [amd64, arm64] steps: + - uses: actions/checkout@v6 + - uses: actions/download-artifact@v8 with: name: binaries path: binaries + - run: bash debian/package.sh "${GITHUB_REF_NAME#v}" "${{ matrix.arch }}" + + - uses: actions/upload-artifact@v7 + with: + name: packages-${{ matrix.arch }} + path: dist/*.deb + + github_release: + needs: packages + runs-on: ubuntu-22.04 + + steps: + - uses: actions/download-artifact@v8 + with: + name: binaries + path: binaries + + - uses: actions/download-artifact@v8 + with: + pattern: packages-* + path: packages + merge-multiple: true + - uses: actions/github-script@v8 with: github-token: ${{ secrets.GITHUB_TOKEN }} @@ -85,14 +112,16 @@ jobs: }); const release_id = res.data.id; - for (const name of await fs.readdir('./binaries/')) { - await github.rest.repos.uploadReleaseAsset({ - owner, - repo, - release_id, - name, - data: await fs.readFile(`./binaries/${name}`), - }); + for (const dir of ['./binaries', './packages']) { + for (const name of await fs.readdir(dir)) { + await github.rest.repos.uploadReleaseAsset({ + owner, + repo, + release_id, + name, + data: await fs.readFile(`${dir}/${name}`), + }); + } } dockerhub: diff --git a/.gitignore b/.gitignore index e2a09ccf297..412956363cd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ /internal/core/VERSION /internal/servers/hls/hls.min.js /internal/staticsources/rpicamera/mtxrpicam_*/ +/dist diff --git a/debian/mediamtx.service b/debian/mediamtx.service new file mode 100644 index 00000000000..a5d23c3f0e9 --- /dev/null +++ b/debian/mediamtx.service @@ -0,0 +1,12 @@ +[Unit] +Description=MediaMTX Service +After=network.target + +[Service] +Type=simple +Restart=always +RestartSec=30 +ExecStart=/usr/local/bin/mediamtx /etc/mediamtx/mediamtx.yml + +[Install] +WantedBy=multi-user.target diff --git a/debian/package.sh b/debian/package.sh new file mode 100644 index 00000000000..979196a29a1 --- /dev/null +++ b/debian/package.sh @@ -0,0 +1,60 @@ +#!/bin/bash + +set -e + +VERSION="$1" +ARCH="$2" + +if [ -z "$VERSION" ] || [ -z "$ARCH" ]; then + echo "Usage: $0 " + exit 1 +fi + +ARCHIVE="binaries/mediamtx_${VERSION}_linux_${ARCH}.tar.gz" +if [ ! -f "$ARCHIVE" ]; then + echo "Archive not found: $ARCHIVE" + exit 1 +fi + +PACKAGE_ROOT="dist" +DEBIAN_DIR="$PACKAGE_ROOT/DEBIAN" +BINARY_DIR="$PACKAGE_ROOT/usr/local/bin" +CONFIG_DIR="$PACKAGE_ROOT/etc/mediamtx" +SERVICE_DIR="$PACKAGE_ROOT/lib/systemd/system" + +rm -rf "$PACKAGE_ROOT" +mkdir -p "$DEBIAN_DIR" +mkdir -p "$BINARY_DIR" +mkdir -p "$CONFIG_DIR" +mkdir -p "$SERVICE_DIR" + +TMP_DIR="$(mktemp -d)" +trap 'rm -rf "$TMP_DIR"' EXIT + +tar -xzf "$ARCHIVE" -C "$TMP_DIR" + +if [ ! -f "$TMP_DIR/mediamtx" ]; then + echo "Extracted binary not found in archive: $ARCHIVE" + exit 1 +fi + +cp "$TMP_DIR/mediamtx" "$BINARY_DIR/mediamtx" +cp "$TMP_DIR/mediamtx.yml" "$CONFIG_DIR/mediamtx.yml" + +chmod 755 "$BINARY_DIR"/* + +cp debian/mediamtx.service "$SERVICE_DIR" + +cat > "$DEBIAN_DIR/control" < +Description: MediaMTX is a ready-to-use and zero-dependency live media server and media proxy. It has been conceived as a "media router" that routes media streams from one end to the other, with a focus on efficiency and portability. +EOF + +cd "$PACKAGE_ROOT" + +dpkg-deb --build . "mediamtx_${VERSION}_${ARCH}.deb"