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

chore(build): up build.yml to build deb

lejianwen 1 год назад
Родитель
Сommit
fa92529e9b
2 измененных файлов с 105 добавлено и 27 удалено
  1. 37 22
      .github/workflows/build.yml
  2. 68 5
      .github/workflows/build_test.yml

+ 37 - 22
.github/workflows/build.yml

@@ -43,6 +43,7 @@ env:
43 43
 jobs:
44 44
   build:
45 45
     runs-on: ubuntu-latest
46
+
46 47
     strategy:
47 48
       fail-fast: false
48 49
       matrix:
@@ -99,22 +100,24 @@ jobs:
99 100
           mkdir -p release/runtime
100 101
           if [ "${{ matrix.job.goos }}" = "windows" ]; then
101 102
             sudo apt-get install gcc-mingw-w64-x86-64 zip -y
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
103
+            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
104
+            zip -r ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}} ./release
103 105
           else
104 106
             if [ "${{ matrix.job.platform }}" = "arm64" ]; then
105 107
                 wget https://musl.cc/aarch64-linux-musl-cross.tgz
106 108
                 tar -xf aarch64-linux-musl-cross.tgz
107 109
                 export PATH=$PATH:$PWD/aarch64-linux-musl-cross/bin
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
110
+                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
109 111
             elif [ "${{ matrix.job.platform }}" = "armv7l" ]; then
110 112
                 wget https://musl.cc/armv7l-linux-musleabihf-cross.tgz
111 113
                 tar -xf armv7l-linux-musleabihf-cross.tgz
112 114
                 export PATH=$PATH:$PWD/armv7l-linux-musleabihf-cross/bin
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
115
+                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
114 116
             else
115 117
               sudo apt-get install musl musl-dev musl-tools -y
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
118
+              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
117 119
             fi
120
+            tar -czf ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}} ./release
118 121
           fi
119 122
 
120 123
       - name: Upload artifact
@@ -122,19 +125,17 @@ jobs:
122 125
         with:
123 126
           name: rustdesk-api-${{ matrix.job.goos }}-${{ matrix.job.platform }}
124 127
           path: |
125
-            ./release/*
128
+            ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}}
126 129
 
127 130
       - name: Upload to GitHub Release
128
-        if: github.event_name == 'release'
129 131
         uses: softprops/action-gh-release@v2
130 132
         with:
131 133
           files: |
132
-            ${{ matrix.job.goos}}-${{ matrix.job.platform }}
134
+            ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}}
133 135
         env:
134 136
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135 137
 
136 138
       - name: Generate Changelog
137
-        if: github.event_name == 'release'
138 139
         run: npx changelogithub # or changelogithub@0.12 if ensure the stable result
139 140
         env:
140 141
           GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -154,7 +155,7 @@ jobs:
154 155
 
155 156
       - name: Checkout
156 157
         uses: actions/checkout@v3
157
-        
158
+
158 159
       - name: Set up QEMU
159 160
         uses: docker/setup-qemu-action@v2
160 161
 
@@ -164,21 +165,39 @@ jobs:
164 165
           DEBIAN_FRONTEND=noninteractive sudo apt install -y devscripts build-essential debhelper pkg-config ${{ matrix.job.crossbuild_package }}
165 166
           mkdir -p debian-build/${{ matrix.job.platform }}/bin
166 167
 
168
+      - name: Get tag version
169
+        id: get_tag
170
+        run: |
171
+          TAG_VERSION="${GITHUB_REF##*/}"
172
+          VERSION="${TAG_VERSION#v}" 
173
+          echo "TAG_VERSION=$TAG_VERSION" >> $GITHUB_ENV
174
+          echo "VERSION=$VERSION" >> $GITHUB_ENV
175
+
176
+      - name: Update changelog
177
+        run: |
178
+          DATE=$(date -R)
179
+          sed -i "1i rustdesk-api-server (${VERSION}) stable; urgency=medium\n\n  * Automatically generated release for version ${VERSION}.\n\n -- GitHub Actions <actions@github.com>  ${DATE}\n" debian/changelog
180
+
167 181
       - name: Download binaries
168 182
         uses: actions/download-artifact@v4
169 183
         with:
170
-          name: rustdesk-api-${{ matrix.job.goos }}-${{ matrix.job.platform }}
184
+          name: rustdesk-api-${{ matrix.job.goos }}-${{ matrix.job.platform }}.tar.gz
171 185
           path: .
172 186
 
187
+      - name: Unzip binaries
188
+        run: |
189
+          mkdir -p ${{ matrix.job.platform }}
190
+          tar -xzf ${{ matrix.job.goos }}-${{ matrix.job.platform }}.tar.gz -C ${{ matrix.job.platform }}
191
+
173 192
       - name: Build package for ${{ matrix.job.platform }} arch
174 193
         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}}
194
+          mv ${{ matrix.job.platform }}/release/apimain debian-build/${{ matrix.job.platform }}/bin/rustdesk-api 
195
+          chmod -v a+x debian-build/${{ matrix.job.platform }}/bin/*
196
+          mkdir -p data
197
+          cp -vr debian systemd conf data resources runtime debian-build/${{ matrix.job.platform }}/
198
+          cat debian/control.tpl | sed 's/{{ ARCH }}/${{ matrix.job.debian_platform }}/' > debian-build/${{ matrix.job.platform }}/debian/control
199
+          cd debian-build/${{ matrix.job.platform }}/
200
+          debuild -i -us -uc -b -a${{ matrix.job.debian_platform}}
182 201
 
183 202
       - name: Upload artifact
184 203
         uses: actions/upload-artifact@v4
@@ -188,14 +207,12 @@ jobs:
188 207
             debian-build/*.deb
189 208
 
190 209
       - name: Create Release
191
-        if: github.event_name == 'release'
192 210
         uses: softprops/action-gh-release@v2
193 211
         with:
194
-          draft: true
195 212
           files: |
196 213
             debian-build/rustdesk-api-server_*_${{ matrix.job.debian_platform }}.deb
214
+
197 215
   docker:
198
-    if: false
199 216
     name: Push Docker Image
200 217
     needs: build
201 218
     runs-on: ubuntu-latest
@@ -256,7 +273,6 @@ jobs:
256 273
         run: |
257 274
           mkdir -p ${{ matrix.job.platform }}
258 275
           tar -xzf ${{ matrix.job.goos }}-${{ matrix.job.platform }}.tar.gz -C ${{ matrix.job.platform }}
259
-          file ${{ matrix.job.platform }}/apimain
260 276
 
261 277
       - name: Build and push Docker image to Docker Hub ${{ matrix.job.platform }}
262 278
         if: ${{ env.SKIP_DOCKER_HUB == 'false' }}  # Only run this step if SKIP_DOCKER_HUB is false
@@ -292,7 +308,6 @@ jobs:
292 308
 
293 309
   #
294 310
   docker-manifest:
295
-    if: false
296 311
     name: Push Docker Manifest
297 312
     needs: docker
298 313
     runs-on: ubuntu-latest

+ 68 - 5
.github/workflows/build_test.yml

@@ -52,6 +52,12 @@ jobs:
52 52
       - name: Checkout code
53 53
         uses: actions/checkout@v4
54 54
 
55
+      - uses: actions/checkout@v4
56
+        with:
57
+          repository: lejianwen/rustdesk-api-web
58
+          path: rustdesk-api-web
59
+          ref: master
60
+
55 61
       - name: Set up Go environment
56 62
         uses: actions/setup-go@v4
57 63
         with:
@@ -62,14 +68,12 @@ jobs:
62 68
         with:
63 69
           node-version: '20'
64 70
 
65
-
66 71
       - name: build rustdesk-api-web
72
+        working-directory: rustdesk-api-web
67 73
         run: |
68
-          git clone ${{ env.WEBCLIENT_SOURCE_LOCATION }}
69
-          cd rustdesk-api-web
70 74
           npm install
71 75
           npm run build
72
-          mkdir ../resources/admin/ -p
76
+          mkdir -p ../resources/admin/
73 77
           cp -ar dist/* ../resources/admin/
74 78
 
75 79
       - name: tidy
@@ -117,6 +121,7 @@ jobs:
117 121
           name: rustdesk-api-${{ matrix.job.goos }}-${{ matrix.job.platform }}
118 122
           path: |
119 123
             ${{ matrix.job.goos}}-${{ matrix.job.platform }}.${{matrix.job.file_ext}}
124
+
120 125
       - name: Upload to GitHub Release
121 126
         uses: softprops/action-gh-release@v2
122 127
         with:
@@ -126,6 +131,65 @@ jobs:
126 131
         env:
127 132
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
128 133
 
134
+  deb-package:
135
+    name: debian package - ${{ matrix.job.platform }}
136
+    needs: build
137
+    runs-on: ubuntu-latest
138
+    strategy:
139
+      fail-fast: false
140
+      matrix:
141
+        job:
142
+          - { platform: "amd64", goos: "linux", debian_platform: "amd64", crossbuild_package: ""}
143
+          - { platform: "arm64", goos: "linux", debian_platform: "arm64", crossbuild_package: "crossbuild-essential-arm64" }
144
+          - { platform: "armv7l", goos: "linux", debian_platform: "armhf", crossbuild_package: "crossbuild-essential-armhf" }
145
+    steps:
146
+
147
+      - name: Checkout
148
+        uses: actions/checkout@v3
149
+
150
+      - name: Set up QEMU
151
+        uses: docker/setup-qemu-action@v2
152
+
153
+      - name: Create packaging env
154
+        run: |
155
+          sudo apt update
156
+          DEBIAN_FRONTEND=noninteractive sudo apt install -y devscripts build-essential debhelper pkg-config ${{ matrix.job.crossbuild_package }}
157
+          mkdir -p debian-build/${{ matrix.job.platform }}/bin
158
+
159
+      - name: Download binaries
160
+        uses: actions/download-artifact@v4
161
+        with:
162
+          name: rustdesk-api-${{ matrix.job.goos }}-${{ matrix.job.platform }}.tar.gz
163
+          path: .
164
+
165
+      - name: Unzip binaries
166
+        run: |
167
+          mkdir -p ${{ matrix.job.platform }}
168
+          tar -xzf ${{ matrix.job.goos }}-${{ matrix.job.platform }}.tar.gz -C ${{ matrix.job.platform }}
169
+
170
+      - name: Build package for ${{ matrix.job.platform }} arch
171
+        run: |
172
+          mv ${{ matrix.job.platform }}/release/apimain debian-build/${{ matrix.job.platform }}/bin/rustdesk-api 
173
+          chmod -v a+x debian-build/${{ matrix.job.platform }}/bin/*
174
+          mkdir -p data
175
+          cp -vr debian systemd conf data resources runtime debian-build/${{ matrix.job.platform }}/
176
+          cat debian/control.tpl | sed 's/{{ ARCH }}/${{ matrix.job.debian_platform }}/' > debian-build/${{ matrix.job.platform }}/debian/control
177
+          cd debian-build/${{ matrix.job.platform }}/
178
+          debuild -i -us -uc -b -a${{ matrix.job.debian_platform}}
179
+
180
+      - name: Upload artifact
181
+        uses: actions/upload-artifact@v4
182
+        with:
183
+          name: rustdesk-api-${{ matrix.job.debian_platform }}
184
+          path: |
185
+            debian-build/*.deb
186
+
187
+      - name: Create Release
188
+        uses: softprops/action-gh-release@v2
189
+        with:
190
+          files: |
191
+            debian-build/rustdesk-api-server_*_${{ matrix.job.debian_platform }}.deb
192
+
129 193
   docker:
130 194
     name: Push Docker Image
131 195
     needs: build
@@ -187,7 +251,6 @@ jobs:
187 251
         run: |
188 252
           mkdir -p ${{ matrix.job.platform }}
189 253
           tar -xzf ${{ matrix.job.goos }}-${{ matrix.job.platform }}.tar.gz -C ${{ matrix.job.platform }}
190
-          file ${{ matrix.job.platform }}/apimain
191 254
 
192 255
       - name: Build and push Docker image to Docker Hub ${{ matrix.job.platform }}
193 256
         if: ${{ env.SKIP_DOCKER_HUB == 'false' }}  # Only run this step if SKIP_DOCKER_HUB is false