From 25548d5226d9b7f4ef9f73400e0984075f10d9f6 Mon Sep 17 00:00:00 2001 From: a-wing <1@233.email> Date: Sun, 10 Nov 2024 20:42:29 +0800 Subject: [PATCH] add nfpm build package deb --- .github/workflows/release.yml | 108 +++++++++++++++++++++------------- Cargo.toml | 45 -------------- nfpm/live777.yaml | 22 +++++++ nfpm/liveman.yaml | 22 +++++++ nfpm/net4mqtt.yaml | 17 ++++++ nfpm/whepfrom.yaml | 17 ++++++ nfpm/whipinto.yaml | 17 ++++++ 7 files changed, 162 insertions(+), 86 deletions(-) create mode 100644 nfpm/live777.yaml create mode 100644 nfpm/liveman.yaml create mode 100644 nfpm/net4mqtt.yaml create mode 100644 nfpm/whepfrom.yaml create mode 100644 nfpm/whipinto.yaml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0e80621..13105f2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -17,23 +17,22 @@ jobs: matrix: job: # https://doc.rust-lang.org/nightly/rustc/platform-support.html - - { target: aarch64-apple-darwin , os: macos-13 } + - { target: aarch64-apple-darwin , os: macos-14 } - { target: aarch64-pc-windows-msvc , os: windows-2022 } - - { target: aarch64-linux-android , os: ubuntu-22.04, use-cross: true } - - { target: aarch64-unknown-linux-gnu , os: ubuntu-22.04, use-cross: true } - - { target: aarch64-unknown-linux-musl , os: ubuntu-22.04, use-cross: true } - - { target: arm-unknown-linux-gnueabihf , os: ubuntu-22.04, use-cross: true } - - { target: arm-unknown-linux-musleabihf, os: ubuntu-22.04, use-cross: true } + - { target: aarch64-linux-android , os: ubuntu-24.04, use-cross: true } + - { target: aarch64-unknown-linux-gnu , os: ubuntu-24.04, use-cross: true } + - { target: aarch64-unknown-linux-musl , os: ubuntu-24.04, use-cross: true, nfpm: arm64 } + - { target: arm-unknown-linux-gnueabihf , os: ubuntu-24.04, use-cross: true } + - { target: arm-unknown-linux-musleabihf, os: ubuntu-24.04, use-cross: true } - { target: i686-pc-windows-msvc , os: windows-2022 } - - { target: i686-unknown-linux-gnu , os: ubuntu-22.04, use-cross: true } - - { target: i686-unknown-linux-musl , os: ubuntu-22.04, use-cross: true } - - { target: x86_64-apple-darwin , os: macos-13 } + - { target: i686-unknown-linux-gnu , os: ubuntu-24.04, use-cross: true } + - { target: i686-unknown-linux-musl , os: ubuntu-24.04, use-cross: true } + - { target: x86_64-apple-darwin , os: macos-14 } - { target: x86_64-pc-windows-gnu , os: windows-2022 } - { target: x86_64-pc-windows-msvc , os: windows-2022 } - - { target: x86_64-unknown-linux-gnu , os: ubuntu-22.04, use-cross: true } - - { target: x86_64-unknown-linux-musl , os: ubuntu-22.04, use-cross: true } + - { target: x86_64-unknown-linux-gnu , os: ubuntu-24.04, use-cross: true } + - { target: x86_64-unknown-linux-musl , os: ubuntu-24.04, use-cross: true, nfpm: amd64 } env: - VERSION: $GITHUB_REF_NAME BUILD_CMD: cargo EXE_SUFFIX: "" PKG_LIVE777_NAME: "" @@ -55,8 +54,14 @@ jobs: run: npm run build - name: Get the release version from the tag + shell: bash run: | - echo "version is: ${{ env.VERSION }}" + VERSION=${GITHUB_REF_NAME} + if expr "${VERSION}" : '[^0-9]*$' > /dev/null; then + VERSION=v0.0.0 + fi + echo "VERSION=${VERSION}" >> $GITHUB_ENV + echo "version is: ${VERSION}" - name: Install Rust toolchain uses: dtolnay/rust-toolchain@stable @@ -147,35 +152,37 @@ jobs: # Let subsequent steps know where to find the compressed package echo "TAR_LIVEMAN_NAME=${TAR_NAME}" >> $GITHUB_ENV - - name: Artifact Upload Live777 - uses: actions/upload-artifact@v4 - with: - name: ${{ env.TAR_LIVE777_NAME }} - path: ${{ env.TAR_LIVE777_NAME }} - - - name: Artifact Upload LiveMan - uses: actions/upload-artifact@v4 - with: - name: ${{ env.TAR_LIVEMAN_NAME }} - path: ${{ env.TAR_LIVEMAN_NAME }} - - - name: Artifact Upload Whepfrom - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PKG_WHEPFROM_NAME }} - path: ${{ env.BUILD_PATH }}/whepfrom${{ env.EXE_SUFFIX }} + - name: Install nFPM + if: ${{ matrix.job.nfpm }} + run: | + echo 'deb [trusted=yes] https://repo.goreleaser.com/apt/ /' | sudo tee /etc/apt/sources.list.d/goreleaser.list + sudo apt update + sudo apt install nfpm - - name: Artifact Upload Whipinto - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PKG_WHIPINTO_NAME }} - path: ${{ env.BUILD_PATH }}/whipinto${{ env.EXE_SUFFIX }} + - name: Set nFPM environment + if: ${{ matrix.job.nfpm }} + run: | + echo "NFPM_ARCH=${{ matrix.job.nfpm }}" >> $GITHUB_ENV + echo "NFPM_TARGET=${{ matrix.job.target }}" >> $GITHUB_ENV + echo "NFPM_VERSION=${{ env.VERSION }}" >> $GITHUB_ENV - - name: Artifact Upload Net4mqtt - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PKG_NET4MQTT_NAME }} - path: ${{ env.BUILD_PATH }}/net4mqtt${{ env.EXE_SUFFIX }} + - name: Build nFPM config + if: ${{ matrix.job.nfpm }} + run: | + envsubst < nfpm/live777.yaml > live777.yaml + envsubst < nfpm/liveman.yaml > liveman.yaml + envsubst < nfpm/net4mqtt.yaml > net4mqtt.yaml + envsubst < nfpm/whipinto.yaml > whipinto.yaml + envsubst < nfpm/whepfrom.yaml > whepfrom.yaml + + - name: Use nFPM + if: ${{ matrix.job.nfpm }} + run: | + nfpm pkg --packager deb --config live777.yaml + nfpm pkg --packager deb --config liveman.yaml + nfpm pkg --packager deb --config net4mqtt.yaml + nfpm pkg --packager deb --config whipinto.yaml + nfpm pkg --packager deb --config whepfrom.yaml - name: Rename binary shell: bash @@ -184,10 +191,29 @@ jobs: mv ${{ env.BUILD_PATH }}/whipinto${{ env.EXE_SUFFIX }} ${{ env.PKG_WHIPINTO_NAME }} mv ${{ env.BUILD_PATH }}/net4mqtt${{ env.EXE_SUFFIX }} ${{ env.PKG_NET4MQTT_NAME }} + - name: Artifact Upload Binary + uses: actions/upload-artifact@v4 + with: + name: ${{ env.VERSION }}_${{ matrix.job.target }}_binary + path: | + ${{ env.TAR_LIVE777_NAME }} + ${{ env.TAR_LIVEMAN_NAME }} + ${{ env.PKG_WHEPFROM_NAME }} + ${{ env.PKG_WHIPINTO_NAME }} + ${{ env.PKG_NET4MQTT_NAME }} + + - name: Artifact Upload debian + uses: actions/upload-artifact@v4 + if: ${{ matrix.job.nfpm }} + with: + name: ${{ env.VERSION }}_${{ matrix.job.target }}_debian + path: | + *.deb + - name: Upload release archive shell: bash if: github.ref_type == 'tag' - run: gh release upload ${{ env.VERSION }} ${{ env.TAR_LIVE777_NAME }} ${{ env.TAR_LIVEMAN_NAME }} ${{ env.PKG_WHEPFROM_NAME }} ${{ env.PKG_WHIPINTO_NAME }} ${{ env.PKG_NET4MQTT_NAME }} + run: gh release upload ${{ env.VERSION }} ${{ env.TAR_LIVE777_NAME }} ${{ env.TAR_LIVEMAN_NAME }} ${{ env.PKG_WHEPFROM_NAME }} ${{ env.PKG_WHIPINTO_NAME }} ${{ env.PKG_NET4MQTT_NAME }} *.deb env: GH_TOKEN: ${{ github.token }} diff --git a/Cargo.toml b/Cargo.toml index 2fa60f9..de0441b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -96,48 +96,3 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] } webui = ["liveion/webui", "liveman/webui"] net4mqtt = ["liveion/net4mqtt", "liveman/net4mqtt"] -# cargo install cargo-deb -# Reference: https://github.com/kornelski/cargo-deb -[package.metadata.deb] -maintainer = "Metal A-Wing <1@233.email>" -copyright = "BinBat LTD " -license-file = ["LICENSE"] -extended-description = """\ -A very simple, high performance, edge WebRTC SFU.\ -Real-time video streaming for the `WHIP`/`WHEP` as first protocol.\ -""" -depends = "libc6 systemd" -section = "utility" -priority = "optional" -assets = [ - [ - "target/release/live777", - "usr/bin/", - "755", - ], - [ - "target/release/whipinto", - "usr/bin/", - "755", - ], - [ - "target/release/whepfrom", - "usr/bin/", - "755", - ], - [ - "config-dist.toml", - "etc/live777/config.toml", - "644", - ], - [ - "live777.service", - "usr/lib/systemd/system/live777.service", - "644", - ], - [ - "README.md", - "usr/share/doc/live777/README", - "644", - ], -] diff --git a/nfpm/live777.yaml b/nfpm/live777.yaml new file mode 100644 index 0000000..ef95a07 --- /dev/null +++ b/nfpm/live777.yaml @@ -0,0 +1,22 @@ +name: "live777" +arch: "${NFPM_ARCH}" +platform: "linux" +version: "${NFPM_VERSION}" +section: "utility" +priority: "optional" +maintainer: "Max A-wing <1@233.email>" +description: | + A very simple, high performance, edge WebRTC SFU. + Real-time video streaming for the `WHIP`/`WHEP` as first protocol. +vendor: "BinBat" +homepage: "http://live777.binbat.com" +license: "MPL-2.0" +contents: + - src: ./target/${NFPM_TARGET}/release/live777 + dst: /usr/bin/live777 + - src: ./conf/live777.service + dst: /usr/lib/systemd/system/live777.service + - src: ./conf/live777.toml + dst: /etc/live777/live777.toml + type: config + diff --git a/nfpm/liveman.yaml b/nfpm/liveman.yaml new file mode 100644 index 0000000..f7bf737 --- /dev/null +++ b/nfpm/liveman.yaml @@ -0,0 +1,22 @@ +name: "liveman" +arch: "${NFPM_ARCH}" +platform: "linux" +version: "${NFPM_VERSION}" +section: "utility" +priority: "optional" +maintainer: "Max A-wing <1@233.email>" +description: | + A very simple, high performance, edge WebRTC SFU. + Live777 cluster manager controller +vendor: "BinBat" +homepage: "http://live777.binbat.com" +license: "MPL-2.0" +contents: + - src: ./target/${NFPM_TARGET}/release/liveman + dst: /usr/bin/liveman + - src: ./conf/liveman.service + dst: /usr/lib/systemd/system/liveman.service + - src: ./conf/liveman.toml + dst: /etc/live777/liveman.toml + type: config + diff --git a/nfpm/net4mqtt.yaml b/nfpm/net4mqtt.yaml new file mode 100644 index 0000000..3404321 --- /dev/null +++ b/nfpm/net4mqtt.yaml @@ -0,0 +1,17 @@ +name: "net4mqtt" +arch: "${NFPM_ARCH}" +platform: "linux" +version: "${NFPM_VERSION}" +section: "utility" +priority: "optional" +maintainer: "Max A-wing <1@233.email>" +description: | + A very simple, high performance, edge WebRTC SFU. + RTP/RTSP to WHIP tool +vendor: "BinBat" +homepage: "http://live777.binbat.com" +license: "MPL-2.0" +contents: + - src: ./target/${NFPM_TARGET}/release/net4mqtt + dst: /usr/bin/net4mqtt + diff --git a/nfpm/whepfrom.yaml b/nfpm/whepfrom.yaml new file mode 100644 index 0000000..c665c01 --- /dev/null +++ b/nfpm/whepfrom.yaml @@ -0,0 +1,17 @@ +name: "whepfrom" +arch: "${NFPM_ARCH}" +platform: "linux" +version: "${NFPM_VERSION}" +section: "utility" +priority: "optional" +maintainer: "Max A-wing <1@233.email>" +description: | + A very simple, high performance, edge WebRTC SFU. + WHEP to RTP/RTSP tool +vendor: "BinBat" +homepage: "http://live777.binbat.com" +license: "MPL-2.0" +contents: + - src: ./target/${NFPM_TARGET}/release/whepfrom + dst: /usr/bin/whepfrom + diff --git a/nfpm/whipinto.yaml b/nfpm/whipinto.yaml new file mode 100644 index 0000000..be3f84b --- /dev/null +++ b/nfpm/whipinto.yaml @@ -0,0 +1,17 @@ +name: "whipinto" +arch: "${NFPM_ARCH}" +platform: "linux" +version: "${NFPM_VERSION}" +section: "utility" +priority: "optional" +maintainer: "Max A-wing <1@233.email>" +description: | + A very simple, high performance, edge WebRTC SFU. + RTP/RTSP to WHIP tool +vendor: "BinBat" +homepage: "http://live777.binbat.com" +license: "MPL-2.0" +contents: + - src: ./target/${NFPM_TARGET}/release/whipinto + dst: /usr/bin/whipinto +