Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 39 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ on:
permissions:
id-token: write
attestations: write
artifact-metadata: write
contents: write
issues: write

Expand All @@ -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 }}
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
/internal/core/VERSION
/internal/servers/hls/hls.min.js
/internal/staticsources/rpicamera/mtxrpicam_*/
/dist
12 changes: 12 additions & 0 deletions debian/mediamtx.service
Original file line number Diff line number Diff line change
@@ -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
60 changes: 60 additions & 0 deletions debian/package.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

set -e

VERSION="$1"
ARCH="$2"

if [ -z "$VERSION" ] || [ -z "$ARCH" ]; then
echo "Usage: $0 <version> <arch>"
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" <<EOF
Package: mediamtx
Version: $VERSION
Section: base
Priority: optional
Architecture: ${ARCH}
Maintainer: Effective Range <info@effective-range.com>
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"