Browse Source

test release_arm64.yml

ljw 1 year ago
parent
commit
90311536a7
1 changed files with 84 additions and 0 deletions
  1. 84 0
      .github/workflows/release_arm64.yml

+ 84 - 0
.github/workflows/release_arm64.yml

@@ -0,0 +1,84 @@
1
+name: Build and Release
2
+
3
+#on:
4
+#  push:
5
+#    tags:
6
+#      - 'v*.*.*'  # 当推送带有版本号的 tag(例如 v1.0.0)时触发工作流
7
+on:
8
+  push:
9
+    branches: [ "master" ]
10
+#  pull_request:
11
+#    branches: [ "master" ]
12
+
13
+jobs:
14
+  build:
15
+    runs-on: ubuntu-latest
16
+
17
+    strategy:
18
+      matrix:
19
+        goos: [ linux ] # 指定要构建的操作系统
20
+        goarch: [ arm64 ]         # 指定架构
21
+
22
+    steps:
23
+      - name: Checkout code
24
+        uses: actions/checkout@v4
25
+
26
+      - name: Set up Go environment
27
+        uses: actions/setup-go@v4
28
+        with:
29
+          go-version: '1.22'  # 选择 Go 版本
30
+
31
+      - name: Set up npm
32
+        uses: actions/setup-node@v2
33
+        with:
34
+          node-version: '20'
35
+
36
+      - name: install gcc zip musl
37
+        run: |
38
+          sudo apt-get install gcc-aarch64-linux-gnu -y
39
+
40
+
41
+      - name: build rustdesk-api-web
42
+        run: |
43
+          git clone https://github.com/lejianwen/rustdesk-api-web
44
+          cd rustdesk-api-web
45
+          npm install
46
+          npm run build
47
+          mkdir ../resources/admin/ -p
48
+          cp -ar dist/* ../resources/admin/
49
+
50
+      - name: tidy
51
+        run: go mod tidy
52
+
53
+
54
+      - name: swag
55
+        run: |
56
+          go install github.com/swaggo/swag/cmd/swag@latest
57
+          swag init -g cmd/apimain.go --output docs/api --instanceName api --exclude http/controller/admin
58
+          swag init -g cmd/apimain.go --output docs/admin --instanceName admin --exclude http/controller/api
59
+
60
+      - name: Build for ${{ matrix.goos }}-${{ matrix.goarch }}
61
+        run: |
62
+          mkdir release -p
63
+          cp -ar resources release/
64
+          cp -ar docs release/
65
+          cp -ar conf release/
66
+          mkdir -p release/data
67
+          mkdir -p release/runtime
68
+          GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} CC=aarch64-linux-gnu-gcc CGO_LDFLAGS="-static" CGO_ENABLED=1 go build -ldflags "-s -w" -o ./release/apimain ./cmd/apimain.go
69
+          tar -czf ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz ./release 
70
+
71
+      - name: Upload artifact
72
+        uses: actions/upload-artifact@v4
73
+        with:
74
+          name: myapp-${{ matrix.goos }}-${{ matrix.goarch }}
75
+          path: |
76
+            ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz
77
+
78
+      - name: Upload to GitHub Release
79
+        uses: softprops/action-gh-release@v2
80
+        with:
81
+          files: |
82
+            ${{ matrix.goos}}-${{ matrix.goarch }}.tar.gz
83
+        env:
84
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}