From d6c6051a6ca7fd629225579dccceb2c69d1c13ea Mon Sep 17 00:00:00 2001 From: Follow the wind <36281137+wy414012@users.noreply.github.com> Date: Wed, 25 Dec 2024 12:28:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(build):=20=E6=B7=BB=E5=8A=A0=E6=9E=84?= =?UTF-8?q?=E5=BB=BAdeb=E5=8C=85=E7=9B=B8=E5=85=B3=E5=9F=BA=E7=A1=80=20(#8?= =?UTF-8?q?7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 添加构建deb包相关基础 * 补齐工作流,等待验证 * 修复构建时没有创建的data目录保障deb包构建 * 修复其余架构deb包构建中的依赖错误 * 修复:由于小改工作流导致写错架构的问题 * 修复拼写错误导致的目录错误 * 添加上传工件,和发布rel工作流,完成相关事务 --------- Co-authored-by: ymwl --- .github/workflows/build.yml | 86 ++++++++++++++++++++++++----- debian/changelog | 5 ++ debian/compat | 1 + debian/control.tpl | 13 +++++ debian/copyright | 21 +++++++ debian/rules | 6 ++ debian/rustdesk-api-server.install | 6 ++ debian/rustdesk-api-server.postinst | 28 ++++++++++ debian/rustdesk-api-server.postrm | 18 ++++++ debian/rustdesk-api-server.prerm | 13 +++++ debian/source/format | 1 + systemd/rustdesk-api.service | 18 ++++++ 12 files changed, 202 insertions(+), 14 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control.tpl create mode 100644 debian/copyright create mode 100644 debian/rules create mode 100644 debian/rustdesk-api-server.install create mode 100644 debian/rustdesk-api-server.postinst create mode 100644 debian/rustdesk-api-server.postrm create mode 100644 debian/rustdesk-api-server.prerm create mode 100644 debian/source/format create mode 100644 systemd/rustdesk-api.service diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9a43996..c09c516 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -43,7 +43,6 @@ env: jobs: build: runs-on: ubuntu-latest - strategy: fail-fast: false matrix: @@ -57,6 +56,11 @@ jobs: uses: actions/checkout@v4 with: fetch-depth: 0 + - uses: actions/checkout@v4 + with: + repository: lejianwen/rustdesk-api-web + path: rustdesk-api-web + ref: master - name: Set up Go environment uses: actions/setup-go@v4 @@ -68,14 +72,12 @@ jobs: with: node-version: '20' - - name: build rustdesk-api-web + working-directory: rustdesk-api-web run: | - git clone ${{ env.WEBCLIENT_SOURCE_LOCATION }} - cd rustdesk-api-web npm install npm run build - mkdir ../resources/admin/ -p + mkdir -p ../resources/admin/ cp -ar dist/* ../resources/admin/ - name: tidy @@ -97,24 +99,22 @@ jobs: mkdir -p release/runtime if [ "${{ matrix.job.goos }}" = "windows" ]; then sudo apt-get install gcc-mingw-w64-x86-64 zip -y - GOOS=${{ matrix.job.goos }} GOARCH=${{ matrix.job.platform }} CC=x86_64-w64-mingw32-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain.exe ./cmd/apimain.go - zip -r ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}} ./release + GOOS=${{ matrix.job.goos }} GOARCH=${{ matrix.job.platform }} CC=x86_64-w64-mingw32-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/rustdesk-api.exe ./cmd/apimain.go else if [ "${{ matrix.job.platform }}" = "arm64" ]; then wget https://musl.cc/aarch64-linux-musl-cross.tgz tar -xf aarch64-linux-musl-cross.tgz export PATH=$PATH:$PWD/aarch64-linux-musl-cross/bin - GOOS=${{ matrix.job.goos }} GOARCH=${{ matrix.job.platform }} CC=aarch64-linux-musl-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go + GOOS=${{ matrix.job.goos }} GOARCH=${{ matrix.job.platform }} CC=aarch64-linux-musl-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/rustdesk-api ./cmd/apimain.go elif [ "${{ matrix.job.platform }}" = "armv7l" ]; then wget https://musl.cc/armv7l-linux-musleabihf-cross.tgz tar -xf armv7l-linux-musleabihf-cross.tgz export PATH=$PATH:$PWD/armv7l-linux-musleabihf-cross/bin - GOOS=${{ matrix.job.goos }} GOARCH=arm GOARM=7 CC=armv7l-linux-musleabihf-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go + GOOS=${{ matrix.job.goos }} GOARCH=arm GOARM=7 CC=armv7l-linux-musleabihf-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/rustdesk-api ./cmd/apimain.go else sudo apt-get install musl musl-dev musl-tools -y - GOOS=${{ matrix.job.goos }} GOARCH=${{ matrix.job.platform }} CC=musl-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go + GOOS=${{ matrix.job.goos }} GOARCH=${{ matrix.job.platform }} CC=musl-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/rustdesk-api ./cmd/apimain.go fi - tar -czf ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}} ./release fi - name: Upload artifact @@ -122,23 +122,80 @@ jobs: with: name: rustdesk-api-${{ matrix.job.goos }}-${{ matrix.job.platform }} path: | - ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}} + ./release/* - name: Upload to GitHub Release + if: github.event_name == 'release' uses: softprops/action-gh-release@v2 with: files: | - ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}} - # tag_name: ${{ env.LATEST_TAG }} + ${{ matrix.job.goos}}-${{ matrix.job.platform }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Generate Changelog + if: github.event_name == 'release' run: npx changelogithub # or changelogithub@0.12 if ensure the stable result env: GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + deb-package: + name: debian package - ${{ matrix.job.platform }} + needs: build + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + job: + - { platform: "amd64", goos: "linux", debian_platform: "amd64", crossbuild_package: ""} + - { platform: "arm64", goos: "linux", debian_platform: "arm64", crossbuild_package: "crossbuild-essential-arm64" } + - { platform: "armv7l", goos: "linux", debian_platform: "armhf", crossbuild_package: "crossbuild-essential-armhf" } + steps: + + - name: Checkout + uses: actions/checkout@v3 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Create packaging env + run: | + sudo apt update + DEBIAN_FRONTEND=noninteractive sudo apt install -y devscripts build-essential debhelper pkg-config ${{ matrix.job.crossbuild_package }} + mkdir -p debian-build/${{ matrix.job.platform }}/bin + + - name: Download binaries + uses: actions/download-artifact@v4 + with: + name: rustdesk-api-${{ matrix.job.goos }}-${{ matrix.job.platform }} + path: . + + - name: Build package for ${{ matrix.job.platform }} arch + run: | + mv rustdesk-api debian-build/${{ matrix.job.platform }}/bin/ + chmod -v a+x debian-build/${{ matrix.job.platform }}/bin/* + mkdir -p data + cp -vr debian systemd conf data resources runtime debian-build/${{ matrix.job.platform }}/ + cat debian/control.tpl | sed 's/{{ ARCH }}/${{ matrix.job.debian_platform }}/' > debian-build/${{ matrix.job.platform }}/debian/control + cd debian-build/${{ matrix.job.platform }}/ + debuild -i -us -uc -b -a${{ matrix.job.debian_platform}} + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: rustdesk-api-${{ matrix.job.debian_platform }} + path: | + debian-build/*.deb + + - name: Create Release + if: github.event_name == 'release' + uses: softprops/action-gh-release@v2 + with: + draft: true + files: | + debian-build/rustdesk-api-server_*_${{ matrix.job.debian_platform }}.deb docker: + if: false name: Push Docker Image needs: build runs-on: ubuntu-latest @@ -235,6 +292,7 @@ jobs: # docker-manifest: + if: false name: Push Docker Manifest needs: docker runs-on: ubuntu-latest diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..44f77b8 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +rustdesk-api-server (1.3.6) UNRELEASED; urgency=medium + + * Update the version to 1.3.6 to match the client. + + -- rustdesk-api Tue, 24 Dec 2024 13:48:34 +0800 \ No newline at end of file diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..f599e28 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +10 diff --git a/debian/control.tpl b/debian/control.tpl new file mode 100644 index 0000000..31fd14b --- /dev/null +++ b/debian/control.tpl @@ -0,0 +1,13 @@ +Source: rustdesk-api-server +Section: net +Priority: optional +Maintainer: ymwl +Build-Depends: debhelper (>= 10), pkg-config +Standards-Version: 4.5.0 +Homepage: https://github.com/lejianwen/rustdesk-api/ + +Package: rustdesk-api-server +Architecture: {{ ARCH }} +Depends: systemd ${misc:Depends} +Description: RustDesk api server + RustDesk api server, it is free and open source. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..59687ab --- /dev/null +++ b/debian/copyright @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2024-present Lejianwen and contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/debian/rules b/debian/rules new file mode 100644 index 0000000..483d681 --- /dev/null +++ b/debian/rules @@ -0,0 +1,6 @@ +#!/usr/bin/make -f +%: + dh $@ + +override_dh_builddeb: + dh_builddeb -- -Zgzip diff --git a/debian/rustdesk-api-server.install b/debian/rustdesk-api-server.install new file mode 100644 index 0000000..b440226 --- /dev/null +++ b/debian/rustdesk-api-server.install @@ -0,0 +1,6 @@ +bin/rustdesk-api usr/bin +systemd/rustdesk-api.service lib/systemd/system +conf var/lib/rustdesk-api +data var/lib/rustdesk-api +resources var/lib/rustdesk-api +runtime var/lib/rustdesk-api \ No newline at end of file diff --git a/debian/rustdesk-api-server.postinst b/debian/rustdesk-api-server.postinst new file mode 100644 index 0000000..a37a5a8 --- /dev/null +++ b/debian/rustdesk-api-server.postinst @@ -0,0 +1,28 @@ +#!/bin/sh +set -e + +SERVICE=rustdesk-api.service + +if [ "$1" = "configure" ]; then + mkdir -p /var/log/rustdesk-api +fi + +case "$1" in + configure|abort-upgrade|abort-deconfigure|abort-remove) + mkdir -p /var/lib/rustdesk-api/ + deb-systemd-helper unmask "${SERVICE}" >/dev/null || true + if deb-systemd-helper --quiet was-enabled "${SERVICE}"; then + deb-systemd-invoke enable "${SERVICE}" >/dev/null || true + else + deb-systemd-invoke update-state "${SERVICE}" >/dev/null || true + fi + systemctl --system daemon-reload >/dev/null || true + if [ -n "$2" ]; then + deb-systemd-invoke restart "${SERVICE}" >/dev/null || true + else + deb-systemd-invoke start "${SERVICE}" >/dev/null || true + fi + ;; +esac + +exit 0 diff --git a/debian/rustdesk-api-server.postrm b/debian/rustdesk-api-server.postrm new file mode 100644 index 0000000..dd89f97 --- /dev/null +++ b/debian/rustdesk-api-server.postrm @@ -0,0 +1,18 @@ +#!/bin/sh +set -e + +SERVICE=rustdesk-api.service + +systemctl --system daemon-reload >/dev/null || true + +if [ "$1" = "purge" ]; then + rm -rf /var/log/rustdesk-api/rustdesk-api.* + deb-systemd-helper purge "${SERVICE}" >/dev/null || true + deb-systemd-helper unmask "${SERVICE}" >/dev/null || true +fi + +if [ "$1" = "remove" ]; then + deb-systemd-helper mask "${SERVICE}" >/dev/null || true +fi + +exit 0 diff --git a/debian/rustdesk-api-server.prerm b/debian/rustdesk-api-server.prerm new file mode 100644 index 0000000..0e986b8 --- /dev/null +++ b/debian/rustdesk-api-server.prerm @@ -0,0 +1,13 @@ +#!/bin/sh +set -e + +SERVICE=rustdesk-api.service + +case "$1" in + remove|deconfigure) + deb-systemd-invoke stop "${SERVICE}" >/dev/null || true + deb-systemd-invoke disable "${SERVICE}" >/dev/null || true + ;; +esac + +exit 0 diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..9f67427 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) \ No newline at end of file diff --git a/systemd/rustdesk-api.service b/systemd/rustdesk-api.service new file mode 100644 index 0000000..3f3ab9c --- /dev/null +++ b/systemd/rustdesk-api.service @@ -0,0 +1,18 @@ +[Unit] +Description=Rustdesk api Server + +[Service] +Type=simple +LimitNOFILE=1000000 +ExecStart=/usr/bin/rustdesk-api +WorkingDirectory=/var/lib/rustdesk-api/ +User= +Group= +Restart=always +StandardOutput=append:/var/log/rustdesk-api/rustdesk-api.log +StandardError=append:/var/log/rustdesk-api/rustdesk-api.error +# Restart service after 10 seconds if node service crashes +RestartSec=10 + +[Install] +WantedBy=multi-user.target