-
Notifications
You must be signed in to change notification settings - Fork 52
248 lines (214 loc) · 7.74 KB
/
Copy pathRelease.yml
File metadata and controls
248 lines (214 loc) · 7.74 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
name: Cross-Platform Release
on:
push:
tags:
- 'v*'
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: write
actions: write
checks: write
deployments: write
jobs:
changelog:
name: Generate Changelog
runs-on: ubuntu-latest
outputs:
release_body: ${{ steps.git-cliff.outputs.content }}
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- name: Generate Changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: -vv --latest --strip header
env:
OUTPUT: CHANGES.md
GITHUB_REPO: ${{ github.repository }}
meta:
name: Determine Release Metadata
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.set_tag.outputs.tag }}
is_release: ${{ steps.set_tag.outputs.is_release }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: set_tag
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
tag="v$(date +%Y%m%d)-manual"
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "is_release=false" >> $GITHUB_OUTPUT
exit 0
fi
is_release=${{ startsWith(github.ref, 'refs/tags/v') }}
if $is_release; then
tag="${GITHUB_REF#refs/tags/}"
else
latest_tag=$(git describe --tags --match "v*" --abbrev=0 2>/dev/null || echo "v0.0.0")
commit_short=$(git rev-parse --short HEAD)
tag="${latest_tag}-${commit_short}-$(date +%Y%m%d)"
fi
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "is_release=$is_release" >> $GITHUB_OUTPUT
build:
name: Build (${{ matrix.platform }}-${{ matrix.arch }})
runs-on: ${{ matrix.os }}
needs: [ changelog, meta ]
strategy:
matrix:
include:
- os: ubuntu-latest
platform: linux
arch: x64
compress_cmd: "zip -r -9"
ext: zip
- os: ubuntu-latest
platform: linux
arch: arm64
compress_cmd: "zip -r -9"
ext: zip
- os: macos-latest
platform: osx
arch: x64
compress_cmd: "zip -r -9"
ext: zip
is_macos: true
- os: macos-latest
platform: osx
arch: arm64
compress_cmd: "zip -r -9"
ext: zip
is_macos: true
- os: windows-latest
platform: win
arch: x64
compress_cmd: "7z a -tzip"
ext: zip
- os: windows-latest
platform: win
arch: arm64
compress_cmd: "7z a -tzip"
ext: zip
fail-fast: false
steps:
- name: Checkout Code
uses: actions/checkout@v5
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: 10.0.x
config-file: NuGet.config
- name: Restore Dependencies
run: dotnet restore
env:
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
- name: Build Solution
run: dotnet publish -c Release -r ${{ matrix.platform }}-${{ matrix.arch }}
- name: Sign macOS App with Adhoc Certificate
if: ${{ matrix.is_macos == true }}
run: |
# 进入发布目录
PUBLISH_DIR="bin/AnyCPU/Release/${{ matrix.platform }}-${{ matrix.arch }}/publish"
cd $PUBLISH_DIR
# 对主程序和相关可执行文件进行adhoc签名(-s - 表示使用adhoc签名)
# 签名所有可执行文件(包括应用程序和更新器)
find . -type f -name "MFAAvalonia*" -exec codesign -s - --force --deep {} \;
find . -type f -name "MFAUpdater*" -exec codesign -s - --force --deep {} \;
# 验证签名是否成功
echo "验证签名结果:"
find . -type f -name "MFAAvalonia*" -exec codesign -v {} \;
shell: bash
- name: Unified ZIP Packaging
shell: bash
run: |
BUILD_DIR="bin/AnyCPU/Release/${{ matrix.platform }}-${{ matrix.arch }}/publish"
OUTPUT_FILE="MFAAvalonia-${{ needs.meta.outputs.tag }}-${{ matrix.platform }}-${{ matrix.arch }}.zip"
# 直接压缩构建目录
cd $BUILD_DIR
${{ matrix.compress_cmd }} ../$OUTPUT_FILE *
- name: Upload ZIP Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.platform }}-${{ matrix.arch }}
path: |
bin/AnyCPU/Release/${{ matrix.platform }}-${{ matrix.arch }}/*.zip
release:
name: Create Release
if: ${{ needs.meta.outputs.is_release == 'true' }}
runs-on: ubuntu-latest
needs: [ changelog, meta, build ]
steps:
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Process and package artifacts
run: |
cd artifacts
for f in *; do
if [[ $f == *"win"* ]]; then
# Windows artifacts: keep original zip files as they are already in correct format
echo "Processing Windows artifact: $f - keeping original zip format"
# Move zip files to root directory
cd $f
mv *.zip ../
cd ..
# Remove the original directory
rm -rf $f
else
# Unix artifacts: extract, set permissions, and repackage as tar.gz
echo "Processing Unix artifact: $f"
# Extract the original zip
cd $f
unzip -q *.zip
rm *.zip
# Set execute permissions for MFAAvalonia
find . -type f -name "MFAAvalonia*" -exec chmod +x {} \; 2>/dev/null || true
echo "Set execute permission for all MFAAvalonia files"
# Set execute permissions for MFAUpdater
find . -type f -name "MFAUpdater*" -exec chmod +x {} \; 2>/dev/null || true
echo "Set execute permission for all MFAUpdater files"
# Create tar.gz with preserved permissions
tar -cpzf ../MFAAvalonia-${{ needs.meta.outputs.tag }}-${f}.tar.gz .
echo "Created archive with preserved permissions: MFAAvalonia-${{ needs.meta.outputs.tag }}-${f}.tar.gz"
cd ..
# Remove the original directory to avoid duplicate files
rm -rf $f
fi
done
- name: Validate Artifacts
run: |
ls -R artifacts
echo "Total files: $(find artifacts -type f | wc -l)"
- name: Create Release
uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631
with:
tag_name: ${{ needs.meta.outputs.tag }}
body: |
${{ needs.changelog.outputs.release_body }}
[已有Mirror酱 CDk?前往Mirror酱 高速下载](https://mirrorchyan.com/zh/projects?rid=MFAAvalonia&source=mfaagh-release)
files: |
artifacts/*.zip
artifacts/*.tar.gz
draft: false
prerelease: ${{ contains(needs.meta.outputs.tag, '-') }}
generate_release_notes: true
env:
TOKEN: ${{ secrets.MFA_TOKEN }}
- name: Trigger MirrorChyanUploading
run: |
gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan
gh workflow run --repo $GITHUB_REPOSITORY mirrorchyan_release_note
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}