Просмотр исходного кода

feat(build): 添加构建deb包相关基础 (#87)

* 添加构建deb包相关基础

* 补齐工作流,等待验证

* 修复构建时没有创建的data目录保障deb包构建

* 修复其余架构deb包构建中的依赖错误

* 修复:由于小改工作流导致写错架构的问题

* 修复拼写错误导致的目录错误

* 添加上传工件,和发布rel工作流,完成相关事务

---------

Co-authored-by: ymwl <ymwlpoolc@qq.com>
Follow the wind 1 год назад
Родитель
Сommit
c778990cf9

+ 72 - 14
.github/workflows/build.yml

@@ -43,7 +43,6 @@ env:
43 43
 jobs:
44 44
   build:
45 45
     runs-on: ubuntu-latest
46
-
47 46
     strategy:
48 47
       fail-fast: false
49 48
       matrix:
@@ -57,6 +56,11 @@ jobs:
57 56
         uses: actions/checkout@v4
58 57
         with:
59 58
           fetch-depth: 0
59
+      - uses: actions/checkout@v4
60
+        with:
61
+          repository: lejianwen/rustdesk-api-web
62
+          path: rustdesk-api-web
63
+          ref: master
60 64
 
61 65
       - name: Set up Go environment
62 66
         uses: actions/setup-go@v4
@@ -68,14 +72,12 @@ jobs:
68 72
         with:
69 73
           node-version: '20'
70 74
 
71
-
72 75
       - name: build rustdesk-api-web
76
+        working-directory: rustdesk-api-web
73 77
         run: |
74
-          git clone ${{ env.WEBCLIENT_SOURCE_LOCATION }}
75
-          cd rustdesk-api-web
76 78
           npm install
77 79
           npm run build
78
-          mkdir ../resources/admin/ -p
80
+          mkdir -p ../resources/admin/
79 81
           cp -ar dist/* ../resources/admin/
80 82
 
81 83
       - name: tidy
@@ -97,24 +99,22 @@ jobs:
97 99
           mkdir -p release/runtime
98 100
           if [ "${{ matrix.job.goos }}" = "windows" ]; then
99 101
             sudo apt-get install gcc-mingw-w64-x86-64 zip -y
100
-            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
101
-            zip -r ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}} ./release
102
+            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
102 103
           else
103 104
             if [ "${{ matrix.job.platform }}" = "arm64" ]; then
104 105
                 wget https://musl.cc/aarch64-linux-musl-cross.tgz
105 106
                 tar -xf aarch64-linux-musl-cross.tgz
106 107
                 export PATH=$PATH:$PWD/aarch64-linux-musl-cross/bin
107
-                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
108
+                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
108 109
             elif [ "${{ matrix.job.platform }}" = "armv7l" ]; then
109 110
                 wget https://musl.cc/armv7l-linux-musleabihf-cross.tgz
110 111
                 tar -xf armv7l-linux-musleabihf-cross.tgz
111 112
                 export PATH=$PATH:$PWD/armv7l-linux-musleabihf-cross/bin
112
-                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
113
+                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
113 114
             else
114 115
               sudo apt-get install musl musl-dev musl-tools -y
115
-              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
116
+              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
116 117
             fi
117
-            tar -czf ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}} ./release
118 118
           fi
119 119
 
120 120
       - name: Upload artifact
@@ -122,23 +122,80 @@ jobs:
122 122
         with:
123 123
           name: rustdesk-api-${{ matrix.job.goos }}-${{ matrix.job.platform }}
124 124
           path: |
125
-            ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}}
125
+            ./release/*
126 126
 
127 127
       - name: Upload to GitHub Release
128
+        if: github.event_name == 'release'
128 129
         uses: softprops/action-gh-release@v2
129 130
         with:
130 131
           files: |
131
-            ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}}
132
-        #          tag_name: ${{ env.LATEST_TAG }}
132
+            ${{ matrix.job.goos}}-${{ matrix.job.platform }}
133 133
         env:
134 134
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135 135
 
136 136
       - name: Generate Changelog
137
+        if: github.event_name == 'release'
137 138
         run: npx changelogithub # or changelogithub@0.12 if ensure the stable result
138 139
         env:
139 140
           GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
140 141
 
142
+  deb-package:
143
+    name: debian package - ${{ matrix.job.platform }}
144
+    needs: build
145
+    runs-on: ubuntu-latest
146
+    strategy:
147
+      fail-fast: false
148
+      matrix:
149
+        job:
150
+          - { platform: "amd64", goos: "linux", debian_platform: "amd64", crossbuild_package: ""}
151
+          - { platform: "arm64", goos: "linux", debian_platform: "arm64", crossbuild_package: "crossbuild-essential-arm64" }
152
+          - { platform: "armv7l", goos: "linux", debian_platform: "armhf", crossbuild_package: "crossbuild-essential-armhf" }
153
+    steps:
154
+
155
+      - name: Checkout
156
+        uses: actions/checkout@v3
157
+        
158
+      - name: Set up QEMU
159
+        uses: docker/setup-qemu-action@v2
160
+
161
+      - name: Create packaging env
162
+        run: |
163
+          sudo apt update
164
+          DEBIAN_FRONTEND=noninteractive sudo apt install -y devscripts build-essential debhelper pkg-config ${{ matrix.job.crossbuild_package }}
165
+          mkdir -p debian-build/${{ matrix.job.platform }}/bin
166
+
167
+      - name: Download binaries
168
+        uses: actions/download-artifact@v4
169
+        with:
170
+          name: rustdesk-api-${{ matrix.job.goos }}-${{ matrix.job.platform }}
171
+          path: .
172
+
173
+      - name: Build package for ${{ matrix.job.platform }} arch
174
+        run: |
175
+           mv rustdesk-api debian-build/${{ matrix.job.platform }}/bin/
176
+           chmod -v a+x debian-build/${{ matrix.job.platform }}/bin/*
177
+           mkdir -p data
178
+           cp -vr debian systemd conf data resources runtime debian-build/${{ matrix.job.platform }}/
179
+           cat debian/control.tpl | sed 's/{{ ARCH }}/${{ matrix.job.debian_platform }}/' > debian-build/${{ matrix.job.platform }}/debian/control
180
+           cd debian-build/${{ matrix.job.platform }}/
181
+           debuild -i -us -uc -b -a${{ matrix.job.debian_platform}}
182
+
183
+      - name: Upload artifact
184
+        uses: actions/upload-artifact@v4
185
+        with:
186
+          name: rustdesk-api-${{ matrix.job.debian_platform }}
187
+          path: |
188
+            debian-build/*.deb
189
+
190
+      - name: Create Release
191
+        if: github.event_name == 'release'
192
+        uses: softprops/action-gh-release@v2
193
+        with:
194
+          draft: true
195
+          files: |
196
+            debian-build/rustdesk-api-server_*_${{ matrix.job.debian_platform }}.deb
141 197
   docker:
198
+    if: false
142 199
     name: Push Docker Image
143 200
     needs: build
144 201
     runs-on: ubuntu-latest
@@ -235,6 +292,7 @@ jobs:
235 292
 
236 293
   #
237 294
   docker-manifest:
295
+    if: false
238 296
     name: Push Docker Manifest
239 297
     needs: docker
240 298
     runs-on: ubuntu-latest

+ 5 - 0
debian/changelog

@@ -0,0 +1,5 @@
1
+rustdesk-api-server (1.3.6) UNRELEASED; urgency=medium
2
+ 
3
+  * Update the version to 1.3.6 to match the client.
4
+ 
5
+ -- rustdesk-api <ymwlpoolc@qq.com>  Tue, 24 Dec 2024 13:48:34 +0800

+ 1 - 0
debian/compat

@@ -0,0 +1 @@
1
+10

+ 13 - 0
debian/control.tpl

@@ -0,0 +1,13 @@
1
+Source: rustdesk-api-server
2
+Section: net
3
+Priority: optional
4
+Maintainer: ymwl <ymwlpoolc@qq.com>
5
+Build-Depends: debhelper (>= 10), pkg-config
6
+Standards-Version: 4.5.0
7
+Homepage: https://github.com/lejianwen/rustdesk-api/
8
+
9
+Package: rustdesk-api-server
10
+Architecture: {{ ARCH }}
11
+Depends: systemd ${misc:Depends}
12
+Description: RustDesk api server
13
+ RustDesk api server, it is free and open source.

+ 21 - 0
debian/copyright

@@ -0,0 +1,21 @@
1
+MIT License
2
+
3
+Copyright (c) 2024-present Lejianwen and contributors
4
+
5
+Permission is hereby granted, free of charge, to any person obtaining a copy
6
+of this software and associated documentation files (the "Software"), to deal
7
+in the Software without restriction, including without limitation the rights
8
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+copies of the Software, and to permit persons to whom the Software is
10
+furnished to do so, subject to the following conditions:
11
+
12
+The above copyright notice and this permission notice shall be included in all
13
+copies or substantial portions of the Software.
14
+
15
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+SOFTWARE.

+ 6 - 0
debian/rules

@@ -0,0 +1,6 @@
1
+#!/usr/bin/make -f
2
+%:
3
+	dh $@
4
+
5
+override_dh_builddeb:
6
+	dh_builddeb -- -Zgzip

+ 6 - 0
debian/rustdesk-api-server.install

@@ -0,0 +1,6 @@
1
+bin/rustdesk-api usr/bin
2
+systemd/rustdesk-api.service lib/systemd/system
3
+conf var/lib/rustdesk-api
4
+data var/lib/rustdesk-api
5
+resources var/lib/rustdesk-api
6
+runtime var/lib/rustdesk-api

+ 28 - 0
debian/rustdesk-api-server.postinst

@@ -0,0 +1,28 @@
1
+#!/bin/sh
2
+set -e
3
+
4
+SERVICE=rustdesk-api.service
5
+
6
+if [ "$1" = "configure" ]; then
7
+    mkdir -p /var/log/rustdesk-api
8
+fi
9
+
10
+case "$1" in
11
+    configure|abort-upgrade|abort-deconfigure|abort-remove)
12
+      mkdir -p /var/lib/rustdesk-api/
13
+	  deb-systemd-helper unmask "${SERVICE}" >/dev/null || true
14
+	  if deb-systemd-helper --quiet was-enabled "${SERVICE}"; then
15
+		deb-systemd-invoke enable "${SERVICE}" >/dev/null || true
16
+	  else
17
+		deb-systemd-invoke update-state "${SERVICE}" >/dev/null || true
18
+	  fi
19
+	  systemctl --system daemon-reload >/dev/null || true
20
+	  if [ -n "$2" ]; then
21
+		deb-systemd-invoke restart "${SERVICE}" >/dev/null || true
22
+	  else
23
+		deb-systemd-invoke start "${SERVICE}" >/dev/null || true
24
+	  fi
25
+    ;;
26
+esac
27
+
28
+exit 0

+ 18 - 0
debian/rustdesk-api-server.postrm

@@ -0,0 +1,18 @@
1
+#!/bin/sh
2
+set -e
3
+
4
+SERVICE=rustdesk-api.service
5
+
6
+systemctl --system daemon-reload >/dev/null || true
7
+
8
+if [ "$1" = "purge" ]; then
9
+	rm -rf /var/log/rustdesk-api/rustdesk-api.*
10
+	deb-systemd-helper purge "${SERVICE}" >/dev/null || true
11
+	deb-systemd-helper unmask "${SERVICE}" >/dev/null || true
12
+fi
13
+
14
+if [ "$1" = "remove" ]; then
15
+	deb-systemd-helper mask "${SERVICE}" >/dev/null || true
16
+fi
17
+
18
+exit 0

+ 13 - 0
debian/rustdesk-api-server.prerm

@@ -0,0 +1,13 @@
1
+#!/bin/sh
2
+set -e
3
+
4
+SERVICE=rustdesk-api.service
5
+
6
+case "$1" in
7
+    remove|deconfigure)
8
+	  deb-systemd-invoke stop "${SERVICE}" >/dev/null || true
9
+	  deb-systemd-invoke disable "${SERVICE}" >/dev/null || true
10
+	;;
11
+esac
12
+
13
+exit 0

+ 1 - 0
debian/source/format

@@ -0,0 +1 @@
1
+3.0 (native)

+ 18 - 0
systemd/rustdesk-api.service

@@ -0,0 +1,18 @@
1
+[Unit]
2
+Description=Rustdesk api Server
3
+
4
+[Service]
5
+Type=simple
6
+LimitNOFILE=1000000
7
+ExecStart=/usr/bin/rustdesk-api
8
+WorkingDirectory=/var/lib/rustdesk-api/
9
+User=
10
+Group=
11
+Restart=always
12
+StandardOutput=append:/var/log/rustdesk-api/rustdesk-api.log
13
+StandardError=append:/var/log/rustdesk-api/rustdesk-api.error
14
+# Restart service after 10 seconds if node service crashes
15
+RestartSec=10
16
+
17
+[Install]
18
+WantedBy=multi-user.target