-
Notifications
You must be signed in to change notification settings - Fork 122
206 lines (185 loc) · 6.6 KB
/
install.yml
File metadata and controls
206 lines (185 loc) · 6.6 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
name: install
env:
# 版本控制:
# - 设置 VERSION 为空字符串时,下载 latest 版本
# - 设置 VERSION 为具体版本号时(如 v1.2.3),下载指定版本
MAAFW_VERSION: ""
MFAA_VERSION: ""
on:
push:
tags:
- "v*"
branches:
- "**"
paths:
- ".github/workflows/install.yml"
- "assets/**"
- "**.py"
pull_request:
branches:
- "**"
paths:
- ".github/workflows/install.yml"
- "assets/**"
- "**.py"
workflow_dispatch:
jobs:
meta:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: set_tag
run: |
# 检查标签格式
is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
tag=$(git describe --tags --match "v*" ${{ github.ref }} || true)
if [[ $tag != v* ]]; then
tag=$(curl -sX GET "https://api.github.com/repos/${{ github.repository }}/releases/latest" --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' | awk '/tag_name/{print $4}' FS='["]')
if [[ $tag != v* ]]; then
tag="v0.0.0"
fi
tag=$(date "+$tag-%y%m%d-$(git rev-parse --short HEAD)")
fi
if ! $($is_release) ; then
prefix=${tag%-*-*}
suffix=${tag#$prefix-}
tag="$prefix-ci.$suffix"
fi
# 检查是否为预发布版本
is_prerelease=false
if [[ $tag =~ .*alpha.* || $tag =~ .*beta.* || $tag =~ .*rc.* || $tag =~ .*dev.* || $tag =~ .*-ci.* ]]; then
is_prerelease=true
echo "This is a pre-release version"
fi
echo tag=$tag | tee -a $GITHUB_OUTPUT
echo is_release=$is_release | tee -a $GITHUB_OUTPUT
echo is_prerelease=$is_prerelease | tee -a $GITHUB_OUTPUT
outputs:
tag: ${{ steps.set_tag.outputs.tag }}
is_release: ${{ steps.set_tag.outputs.is_release }}
is_prerelease: ${{ steps.set_tag.outputs.is_prerelease }}
install:
needs: meta
runs-on: ubuntu-latest
strategy:
matrix:
os: [win, macos, linux, android]
arch: [aarch64, x86_64]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Download MaaFramework
uses: robinraju/release-downloader@v1
with:
repository: MaaXYZ/MaaFramework
fileName: "MAA-${{ matrix.os }}-${{ matrix.arch }}*"
latest: ${{ env.MAAFW_VERSION == '' }}
tag: ${{ env.MAAFW_VERSION }}
out-file-path: "deps"
extract: true
- name: Download MFAAvalonia
if: matrix.os != 'android'
id: download_mfa
uses: robinraju/release-downloader@v1
with:
repository: SweetSmellFox/MFAAvalonia
fileName: "MFAAvalonia-*-${{ (matrix.os == 'win' && 'win') || (matrix.os == 'macos' && 'osx') || (matrix.os == 'linux' && 'linux') }}-${{ (matrix.arch == 'x86_64' && 'x64') || (matrix.arch == 'aarch64' && 'arm64') }}*"
latest: ${{ env.MFAA_VERSION == '' }}
tag: ${{ env.MFAA_VERSION }}
out-file-path: "MFA"
extract: true
- name: Clean up MFAAvalonia archive
if: matrix.os != 'android'
shell: bash
run: |
ARCHIVE_FILE_PATH="${{ fromJson(steps.download_mfa.outputs.downloaded_files)[0] }}"
rm -f "${ARCHIVE_FILE_PATH}"
echo "Archive cleanup command executed for MFAAvalonia."
- name: Remove built-in runtime in MFA
if: matrix.os != 'android'
shell: bash
run: |
rm -rf MFA/runtimes
- name: Install
shell: bash
run: |
if [[ "${{ matrix.os }}" != "android" ]]; then
if [ -d "MFA" ]; then
echo "Copying MFA files to install directory..."
mkdir -p install
rsync -av --ignore-existing MFA/ install/
echo "MFA files copied successfully."
else
echo "MFA directory not found, skipping copy."
fi
else
echo "Skipping copy MFA for Android."
fi
cd tools/
python -m pip install -r ./requirements.txt
python ./install.py ${{ needs.meta.outputs.tag }} ${{ matrix.os }} ${{ matrix.arch }}
cd ..
- uses: actions/upload-artifact@v4
with:
name: MaaXXX-${{ matrix.os }}-${{ matrix.arch }}
path: "install"
changelog:
name: Generate changelog
needs: meta
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate a changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: .github/cliff.toml
# 正式版:使用 tag-pattern 只匹配正式版标签,包含所有从上一个正式版以来的提交
# 预发布版:正常生成,只包含从上一个标签以来的提交
args: >-
-vv --latest --strip header
${{ needs.meta.outputs.is_prerelease == 'false' && '--tag-pattern "^v[0-9]+\\.[0-9]+\\.[0-9]+$"' || '' }}
env:
OUTPUT: CHANGES.md
GITHUB_REPO: ${{ github.repository }}
release:
if: ${{ needs.meta.outputs.is_release == 'true' }}
needs: [meta, install, changelog]
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: assets
- run: |
cd assets
for f in *; do
(cd $f && zip -r ../$f-${{ needs.meta.outputs.tag }}.zip .)
done
- uses: softprops/action-gh-release@v2
with:
files: assets/*
tag_name: ${{ needs.meta.outputs.tag }}
body: ${{ needs.changelog.outputs.release_body }}
draft: false
prerelease: ${{ needs.meta.outputs.is_prerelease == 'true' }}
# Mirror酱为第三方分发服务,新项目默认关闭
# 若有需要请联系 Mirror酱 开通,直接自行开启是无法使用的
# https://mirrorchyan.com/
- name: Trigger MirrorChyanUploading
if: false
# if: ${{ github.repository_owner == 'MaaXYZ' }}
shell: bash
run: |
gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release.yml -f tag=${{ needs.meta.outputs.tag }}
gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note.yml -f tag=${{ needs.meta.outputs.tag }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}