1
+ name : Build and Release
2
+
3
+ on :
4
+ push :
5
+ tags :
6
+ - ' v*'
7
+ workflow_dispatch :
8
+
9
+ permissions :
10
+ contents : write
11
+ packages : write
12
+ actions : read
13
+
14
+ jobs :
15
+ build-and-release :
16
+ runs-on : ubuntu-latest
17
+
18
+ strategy :
19
+ matrix :
20
+ runtime : [win-x64, linux-x64, osx-x64, linux-arm64, osx-arm64]
21
+
22
+ steps :
23
+ - name : Checkout code
24
+ uses : actions/checkout@v4
25
+
26
+ - name : Setup .NET
27
+ uses : actions/setup-dotnet@v4
28
+ with :
29
+ dotnet-version : ' 9.0.x'
30
+
31
+ - name : Setup Node.js
32
+ uses : actions/setup-node@v4
33
+ with :
34
+ node-version : ' 20'
35
+
36
+ - name : Install Yarn
37
+ run : npm install -g yarn
38
+
39
+ - name : Cache node modules
40
+ uses : actions/cache@v4
41
+ with :
42
+ path : web/node_modules
43
+ key : ${{ runner.os }}-node-${{ hashFiles('web/yarn.lock') }}
44
+ restore-keys : |
45
+ ${{ runner.os }}-node-
46
+
47
+ - name : Install frontend dependencies
48
+ working-directory : web
49
+ run : |
50
+ yarn install
51
+ npm install --force
52
+
53
+ - name : Build frontend
54
+ working-directory : web
55
+ run : yarn run build
56
+
57
+ - name : Restore .NET dependencies
58
+ run : dotnet restore src/Console.Service/Console.Service.csproj
59
+
60
+ - name : Build .NET application
61
+ run : dotnet build src/Console.Service/Console.Service.csproj -c Release --no-restore
62
+
63
+ - name : Publish .NET application
64
+ run : |
65
+ dotnet publish src/Console.Service/Console.Service.csproj \
66
+ -c Release \
67
+ -r ${{ matrix.runtime }} \
68
+ --self-contained true \
69
+ -p:PublishSingleFile=true \
70
+ -p:PublishTrimmed=true \
71
+ -o ./publish/${{ matrix.runtime }}
72
+
73
+ - name : Copy frontend to wwwroot
74
+ run : |
75
+ mkdir -p ./publish/${{ matrix.runtime }}/wwwroot
76
+ cp -r web/dist/* ./publish/${{ matrix.runtime }}/wwwroot/
77
+
78
+ - name : Create archive
79
+ run : |
80
+ cd publish
81
+ if [[ "${{ matrix.runtime }}" == win-* ]]; then
82
+ zip -r ../Console-${{ matrix.runtime }}.zip ${{ matrix.runtime }}
83
+ else
84
+ tar -czf ../Console-${{ matrix.runtime }}.tar.gz ${{ matrix.runtime }}
85
+ fi
86
+
87
+ - name : Upload artifacts
88
+ uses : actions/upload-artifact@v4
89
+ with :
90
+ name : Console-${{ matrix.runtime }}
91
+ path : |
92
+ Console-${{ matrix.runtime }}.zip
93
+ Console-${{ matrix.runtime }}.tar.gz
94
+ retention-days : 30
95
+
96
+ create-release :
97
+ needs : build-and-release
98
+ runs-on : ubuntu-latest
99
+ if : startsWith(github.ref, 'refs/tags/')
100
+
101
+ steps :
102
+ - name : Download all artifacts
103
+ uses : actions/download-artifact@v4
104
+ with :
105
+ path : ./artifacts
106
+
107
+ - name : Create Release
108
+ uses : softprops/action-gh-release@v1
109
+ with :
110
+ files : |
111
+ artifacts/Console-win-x64/Console-win-x64.zip
112
+ artifacts/Console-linux-x64/Console-linux-x64.tar.gz
113
+ artifacts/Console-osx-x64/Console-osx-x64.tar.gz
114
+ artifacts/Console-linux-arm64/Console-linux-arm64.tar.gz
115
+ artifacts/Console-osx-arm64/Console-osx-arm64.tar.gz
116
+ draft : false
117
+ prerelease : false
118
+ generate_release_notes : true
119
+ env :
120
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments