-
Notifications
You must be signed in to change notification settings - Fork 96
232 lines (206 loc) · 8.2 KB
/
workflow_dispatch.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
name: SpeedShare Repository Dispatch
on:
workflow_dispatch:
inputs:
custom_runner:
description: '是否使用自定义Runner'
required: true
ref:
description: '分支'
default: 'main'
repository_dispatch:
types:
- api
jobs:
# build-linux:
# runs-on: ubuntu-20.04
# environment: default
# steps:
# - name: Checkout the code
# uses: actions/checkout@v3
# with:
# ref: ${{ github.event.client_payload.ref }}
# - name: Checkout speed_share_extension code
# uses: actions/checkout@v3
# with:
# repository: 'mengyanshou/speed_share_extension'
# token: ${{ secrets.GH_PAT }}
# ref: 'main'
# path: "${{ github.workspace }}/speed_share_extension"
# - name: Checkout behavior_api code
# uses: actions/checkout@v3
# with:
# repository: 'mengyanshou/behavior_api'
# token: ${{ secrets.GH_PAT }}
# ref: 'main'
# path: "${{ github.workspace }}/behavior_api"
# - name: Checkout user_center_frontend code
# uses: actions/checkout@v3
# with:
# repository: 'mengyanshou/user_center_frontend'
# token: ${{ secrets.GH_PAT }}
# ref: 'main'
# path: "${{ github.workspace }}/user_center_frontend"
# - name: move file
# run: |
# mv "${{ github.workspace }}/user_center_frontend" "${{ github.workspace }}/../user_center_frontend"
# mv "${{ github.workspace }}/speed_share_extension" "${{ github.workspace }}/../speed_share_extension"
# mv "${{ github.workspace }}/behavior_api/behavior.dart" ./lib/global/behavior.dart
# mv "${{ github.workspace }}/behavior_api/behavior.g.dart" ./lib/global/behavior.g.dart
# - name: Install and set Flutter version
# uses: subosito/flutter-action@v2
# with:
# channel: 'stable'
# - name: Setup other environment
# run: |
# sudo apt-get update -y
# sudo apt-get install -y ninja-build libgtk-3-dev
# # tray manager need
# sudo apt-get install libayatana-appindicator3-dev
# - name: Building...
# run: |
# flutter config --enable-linux-desktop
# ./scripts/build/linux/build_linux.sh
# - name: Packaging...
# run: ./scripts/build/linux/generate_linux.sh
# - name: Upload..
# run: |
# ni default -u
# # curl -X POST -F "file=@${{ env.ZIP_NAME }}.deb" http://nightmare.press:444/api/v1/file/uploadfile/
# # curl --upload-file "${{ env.ZIP_NAME }}.deb" https://transfersh.com/${{ env.APP_NAME }}.deb
clone-code:
strategy:
matrix:
os: ["${{ github.event.inputs.custom_runner == 'true' && 'self-hosted-mac' || 'macos-latest' }}", "${{ github.event.inputs.custom_runner == 'true' && 'self-hosted-windows' || 'windows-latest' }}"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout current code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.ref }}
- name: Checkout speed_share_extension code
uses: actions/checkout@v3
with:
repository: 'mengyanshou/speed_share_extension'
token: ${{ secrets.GH_PAT }}
ref: 'main'
path: "${{ github.workspace }}/speed_share_extension"
- name: Checkout behavior_api code
uses: actions/checkout@v3
with:
repository: 'mengyanshou/behavior_api'
token: ${{ secrets.GH_PAT }}
ref: 'main'
path: "${{ github.workspace }}/behavior_api"
- name: Checkout user_center_frontend code
uses: actions/checkout@v3
with:
repository: 'mengyanshou/user_center_frontend'
token: ${{ secrets.GH_PAT }}
ref: 'main'
path: "${{ github.workspace }}/user_center_frontend"
- name: Checkout ni CLI code
uses: actions/checkout@v3
with:
repository: 'mengyanshou/ni'
token: ${{ secrets.GH_PAT }}
ref: 'main'
path: "${{ github.workspace }}/ni"
- name: Cache Primes
id: cache-primes
uses: actions/cache@v3
with:
path: ${{ github.workspace }}
key: ${{ runner.os }}-primes
build-mac:
# runs-on: macos-latest
runs-on: ${{ github.event.inputs.custom_runner == 'true' && 'self-hosted-mac' || 'macos-latest' }}
needs: clone-code
environment: default
steps:
- name: Run on ${{ github.job.runs-on }}
run: echo "This job runs on ${{ github.job.runs-on }}"
# - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
# - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
# - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
# - name: Check out repository code
# uses: actions/checkout@v3
# - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
# - run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: Restore cached Primes
id: cache-primes-restore
uses: actions/cache/restore@v3
with:
path: |
${{ github.workspace }}
key: ${{ runner.os }}-primes
- name: move file
run: |
mv "${{ github.workspace }}/user_center_frontend" "${{ github.workspace }}/../user_center_frontend"
mv "${{ github.workspace }}/speed_share_extension" "${{ github.workspace }}/../speed_share_extension"
mv "${{ github.workspace }}/behavior_api/behavior.dart" ./lib/global/behavior.dart
mv "${{ github.workspace }}/behavior_api/behavior.g.dart" ./lib/global/behavior.g.dart
- name: List files in the repository
run: |
ls ${{ github.workspace }}/..
- name: Setup node environment
uses: actions/setup-node@v2
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Setup CLI environment
run: |
cd ${{ github.workspace }}/ni
dart pub get
- name: Setup other environment
run: npm install -g appdmg
- name: Building&&Packaging
run: |
export PATH=$PATH:${{ github.workspace }}/ni
ni release --build-mac-dmg
- name: Upload
run: |
export PATH=$PATH:${{ github.workspace }}/ni
ni default -u
build-windows:
# The type of runner that the job will run on
runs-on: ${{ github.event.inputs.custom_runner == 'true' && 'self-hosted-windows' || 'windows-latest' }}
environment: default
needs: clone-code
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Restore cached Primes
id: cache-primes-restore
uses: actions/cache/restore@v3
with:
path: |
${{ github.workspace }}
key: ${{ runner.os }}-primes
- name: move file
run: |
Move-Item -Path "${{ github.workspace }}/user_center_frontend" -Destination "${{ github.workspace }}/../"
Move-Item -Path "${{ github.workspace }}/speed_share_extension" -Destination "${{ github.workspace }}/../"
Move-Item -Path "${{ github.workspace }}/behavior_api/behavior.dart" -Destination ./lib/global/behavior.dart
Move-Item -Path "${{ github.workspace }}/behavior_api/behavior.g.dart" -Destination ./lib/global/behavior.g.dart
- name: Install and set Flutter version
uses: subosito/flutter-action@v2
with:
channel: 'stable'
- name: Setup CLI environment
if: always()
run: |
cd ${{ github.workspace }}\ni
dart pub get
- name: Building...
if: always()
run: |
set PATH=%PATH%:${{ github.workspace }}\ni
ni release --build-win-zip
shell: cmd
- name: Upload
if: always()
run: |
set PATH=%PATH%:${{ github.workspace }}\ni
ni default -u
shell: cmd