-
Notifications
You must be signed in to change notification settings - Fork 27
270 lines (231 loc) · 10.4 KB
/
python-app.yml
File metadata and controls
270 lines (231 loc) · 10.4 KB
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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
# <StarRailAssistant:An automated program that helps you complete daily tasks of StarRail.>
# Copyright © <2024> <Shasnow>
# This file is part of StarRailAssistant.
# StarRailAssistant is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free Software Foundation,
# either version 3 of the License, or (at your option) any later version.
# StarRailAssistant is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the GNU General Public License for more details.
# You should have received a copy of the GNU General Public License along with StarRailAssistant.
# If not, see <https://www.gnu.org/licenses/>.
# yukikage@qq.com
name: Build StarRailAssistant
on:
workflow_dispatch:
permissions:
contents: write
actions: write
jobs:
pre_check:
name: Pre Checks
runs-on: ubuntu-latest
steps:
- name: Repo Check
run: |
if [[ "$GITHUB_REPOSITORY" != "Shasnow/StarRailAssistant" ]]; then
echo "When forking this repository to make your own builds, you have to adjust this check."
exit 1
fi
exit 0
build:
runs-on: windows-latest
needs: pre_check
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install .NET 8.0 Core
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'
- name: Publish win-x64
run: |
dotnet publish -c Release -r win-x64 .\SRAFrontend\SRAFrontend.sln
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
pip install -r requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Built with package.py
run: |
python package.py
- name: Read version
id: read_version
run: |
$VERSION=(Get-Content -Path "version_info.txt" -TotalCount 1).Trim()
$CHANNEL=$VERSION.Contains("-beta") ? "beta" : "stable"
"version=$VERSION" | Out-File -FilePath $env:GITHUB_ENV -Append
"channel=$CHANNEL" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Install Inno Setup
run: |
choco install innosetup --no-progress --yes
- name: Prepare for Inno Setup
run: |
Expand-Archive -Path StarRailAssistant_${{ env.version }}.zip -DestinationPath StarRailAssistant
Copy-Item version_info.txt -Destination setup\install_info.txt -Force
- name: Build Installer
run: |
New-Item -ItemType Directory -Path setup\SRA -Force
Copy-Item -Path StarRailAssistant\* -Destination setup\SRA -Force -Recurse
New-Item -ItemType Directory -Path setup\output -Force
python setup/version_modifier.py --version "${{ env.version }}"
iscc setup\srasetup.iss
Copy-Item -Path setup\output\* -Destination . -Force
- name: Upload Setup Artifact
uses: actions/upload-artifact@v4
with:
name: StarRailAssistant_${{ env.version }}_setup
path: StarRailAssistant_${{ env.version }}_Setup.exe
- name: Upload Full zip Artifact
uses: actions/upload-artifact@v4
with:
name: StarRailAssistant_${{ env.version }}
path: StarRailAssistant_${{ env.version }}.zip
- name: Upload Lite zip Artifact
uses: actions/upload-artifact@v4
with:
name: StarRailAssistant_Lite_${{ env.version }}
path: StarRailAssistant_Lite_${{ env.version }}.zip
- name: Upload Core zip Artifact
uses: actions/upload-artifact@v4
with:
name: StarRailAssistant_Core_${{ env.version }}
path: StarRailAssistant_Core_${{ env.version }}.zip
- name: Upload Version_Info Artifact
uses: actions/upload-artifact@v4
with:
name: version_info
path: version_info.txt
- name: Upload to R2
env:
AWS_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
run: |
aws s3 cp StarRailAssistant_${{ env.version }}.zip s3://sra/ --endpoint-url=https://955e419b52a8b9fa05c04e29cfb0b17f.r2.cloudflarestorage.com --checksum-algorithm CRC32 --force
publish_release:
name: Publish release
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
pattern: StarRailAssistant_*
merge-multiple: true
path: artifacts
- name: Download Version_Info
uses: actions/download-artifact@v4
with:
name: version_info
path: ./
- name: Check if release exists
id: check_if_release_exists
run: |
release_id=$(gh release view $(sed 's/\r$//g' <(head -n 1 version_info.txt)) --json id --jq .id || true)
if [[ -z $release_id ]]; then
echo "release_exists=false" >> $GITHUB_OUTPUT
else
echo "release_exists=true" >> $GITHUB_OUTPUT
fi
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
- name: Create release
id: create_release
if: steps.check_if_release_exists.outputs.release_exists == 'false'
run: |
set -xe
shopt -s nullglob
NAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
TAGNAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
NOTES_MAIN="$(sed 's/\r$//g' <(tail -n +3 version_info.txt))"
NOTES="$NOTES_MAIN
[已有 Mirror酱 CDK ?前往 Mirror酱 高速下载](https://mirrorchyan.com/zh/projects?rid=StarRailAssistant&source=sra-release)
下载说明:
- StarRailAssistant_Core*.zip - 核心包、无gui、可运行、需手写配置文件
- StarRailAssistant_Lite*.zip - 轻量包、需额外下载核心包才有实际功能
- StarRailAssistant_vX.X.X.zip - 全量压缩包、免安装
- StarRailAssistant_vX.X.X_Setup.exe - 全量安装包
除了核心包以外的包都需要安装 [.NET Desktop Runtime 8](https://dotnet.microsoft.com/zh-cn/download/dotnet/8.0) 才能运行
首次使用建议下载全量压缩包或全量安装包
**看准文件名再下载!**
\`\`\`本release通过GitHub Actions自动构建\`\`\`"
gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" --prerelease artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
- name: Update release
if: steps.check_if_release_exists.outputs.release_exists == 'true'
run: |
set -xe
shopt -s nullglob
NAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
TAGNAME="$(sed 's/\r$//g' <(head -n 1 version_info.txt))"
NOTES_MAIN="$(sed 's/\r$//g' <(tail -n +3 version_info.txt))"
NOTES="$NOTES_MAIN
[已有 Mirror酱 CDK ?前往 Mirror酱 高速下载](https://mirrorchyan.com/zh/projects?rid=StarRailAssistant&source=sra-release)
下载说明:
- StarRailAssistant_Core*.zip - 核心包、无gui、可运行、需手写配置文件
- StarRailAssistant_Lite*.zip - 轻量包、需额外下载核心包才有实际功能
- StarRailAssistant_vX.X.X.zip - 全量压缩包、免安装
- StarRailAssistant_vX.X.X_Setup.exe - 全量安装包
除了核心包以外的包都需要安装 [.NET Desktop Runtime 8](https://dotnet.microsoft.com/zh-cn/download/dotnet/8.0) 才能运行
首次使用建议下载全量压缩包或全量安装包
**看准文件名再下载!**
\`\`\`本release通过GitHub Actions自动构建\`\`\`"
gh release delete "$TAGNAME" --yes
gh release create "$TAGNAME" --target "main" --title "$NAME" --notes "$NOTES" --prerelease artifacts/*
env:
GITHUB_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
# - name: Trigger MirrorChyanUploading
# shell: bash
# run: |
# gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan
# gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
mirrorchyan:
needs: publish_release
runs-on: macos-latest
if: ${{ github.repository_owner == 'Shasnow' }}
steps:
- name: upload
uses: MirrorChyan/uploading-action@v1
with:
filetype: latest-release
filename: "StarRailAssistant_v*.zip"
mirrorchyan_rid: StarRailAssistant
github_token: ${{ secrets.GITHUB_TOKEN }}
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
upload_token: ${{ secrets.MirrorChyanUploadToken }}
- name: release note
uses: MirrorChyan/release-note-action@v1
with:
mirrorchyan_rid: StarRailAssistant
upload_token: ${{ secrets.MirrorChyanUploadToken }}
github_token: ${{ secrets.GITHUB_TOKEN }}
auto_mas:
runs-on: ubuntu-latest
needs: mirrorchyan
steps:
- name: Download Version_Info
uses: actions/download-artifact@v4
with:
name: version_info
path: ./version_info
- name: Update Auto-MAS
run: |
VERSION=$(sed 's/\r$//g' <(head -n 1 version_info/version_info.txt))
CHANNEL=$([[ "$VERSION" == *"-beta"* ]] && echo "beta" || echo "stable")
curl -X POST -H "Content-Type: application/json" -d '{"version": "'"$VERSION"'", "res_id": "StarRailAssistant", "channel": "'"$CHANNEL"'"}' "${{ secrets.UPDATE_URL }}"