forked from MaaAssistantArknights/MaaAssistantArknights
-
Notifications
You must be signed in to change notification settings - Fork 0
190 lines (163 loc) · 7.03 KB
/
Copy pathrelease-ota.yml
File metadata and controls
190 lines (163 loc) · 7.03 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
name: release-ota
on:
release:
types:
- published
workflow_dispatch:
inputs:
limit:
description: Number of releases to fetch from MaaAssistantArknights, 2 at least
required: false
default: "31"
type: number
limit_2:
description: Number of releases to fetch from MaaRelease
required: false
default: "30"
type: number
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
create-tag:
runs-on: ubuntu-latest
steps:
- name: Fetch MaaRelease
uses: actions/checkout@v4
with:
show-progress: false
repository: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
path: MaaRelease
fetch-depth: 0
token: ${{ secrets.MAARELEASE_RELEASE }}
- name: Fetch release info
id: fetchReleaseInfo
run: |
mkdir -pv build-ota && cd build-ota
# Convert inputs to integers
limit=${{ inputs.limit || 31 }}
limit=${limit%.*}
echo "Parsed limit: $limit"
limit_2=${{ inputs.limit_2 || 30 }}
limit_2=${limit_2%.*}
echo "Parsed limit_2: $limit_2"
gh release list --repo 'MaaAssistantArknights/MaaAssistantArknights' --limit $limit | tee ./release_maa.txt
gh release list --repo "MaaAssistantArknights/MaaRelease" --limit $limit_2 | tee ./release_mr.txt
head -n 1 ./release_maa.txt | awk '{ print $1 }' > ./config
tail -n +1 ./release_maa.txt | awk '{ print $1 }' > ./tags_maa.txt
cat ./release_mr.txt | awk '{ print $1 }' > ./tags_mr.txt
comm <(sort ./tags_maa.txt) <(sort ./tags_mr.txt) | awk '{ print $1 }' >> ./config
echo "config:"
cat ./config
echo "prerelease=$([ $(head -n 1 release_maa.txt | awk '{ print $2}') = 'Pre-release' ] && echo true || echo false)" >> $GITHUB_OUTPUT
echo "release_tag=$(head -n 1 ./config)" >> $GITHUB_OUTPUT
- name: Commit and setup tag
run: |
cd MaaRelease
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git checkout --orphan __temp
git rm -rf .
git commit --allow-empty --message ${{ steps.fetchReleaseInfo.outputs.release_tag }}
git tag ${{ steps.fetchReleaseInfo.outputs.release_tag }} || exit 0 # do nothing if the tag already exists
git push --tags
env:
PUSH_REMOTE: https://github-actions[bot]:${{ secrets.MAARELEASE_RELEASE }}@github.com/${{ github.repository_owner }}/MaaRelease
- name: Upload release config to GitHub
uses: actions/upload-artifact@v4
with:
name: MaaReleaseConfig
path: ./build-ota/config
outputs:
prerelease: ${{ steps.fetchReleaseInfo.outputs.prerelease }}
release_tag: ${{ steps.fetchReleaseInfo.outputs.release_tag }}
make-ota:
needs: create-tag
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x64
steps:
- name: Download release config
uses: actions/download-artifact@v4
- name: Fetch MaaRelease
uses: actions/checkout@v4
with:
show-progress: false
repository: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
path: MaaRelease
fetch-depth: 0
token: ${{ secrets.MAARELEASE_RELEASE }}
- name: Checkout code
uses: actions/checkout@v4
with:
show-progress: false
path: MaaAssistantArknights
- name: Download latest version for server
run: |
mkdir -pv build-ota/${{ needs.create-tag.outputs.release_tag }}
cd build-ota/${{ needs.create-tag.outputs.release_tag }}
gh release download ${{ needs.create-tag.outputs.release_tag }} --repo 'MaaAssistantArknights/MaaAssistantArknights' --pattern "MAA-${{ needs.create-tag.outputs.release_tag }}-win-${{ matrix.target }}.zip" --clobber
cp *.zip ..
- name: Build OTA
run: |
cd build-ota
$GITHUB_WORKSPACE/MaaAssistantArknights/tools/OTAPacker/build.sh 'MaaAssistantArknights/MaaAssistantArknights' ../MaaReleaseConfig/config ${{ matrix.target }} 'MaaAssistantArknights/MaaRelease'
- name: Upload to MaaRelease
uses: svenstaro/upload-release-action@v2
with:
repo_name: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
repo_token: ${{ secrets.MAARELEASE_RELEASE }}
file_glob: true
file: build-ota/*.zip
tag: ${{ needs.create-tag.outputs.release_tag }}
prerelease: ${{ fromJSON(needs.create-tag.outputs.prerelease) }}
overwrite: true
make-ota-mac:
needs: create-tag
runs-on: macos-14
steps:
- name: Fetch release info
run: gh release list --repo 'MaaAssistantArknights/MaaAssistantArknights' --limit ${{ inputs.limit || 31 }} | tee ./release_maa.txt
- name: Download release packages
run: |
cat ./release_maa.txt | awk '{ print $1 }' | while read tag; do
gh release download "$tag" --repo 'MaaAssistantArknights/MaaAssistantArknights' --clobber -D packages -p 'MAA-*-macos-universal.dmg' || true
RELEASE_NOTES=$(gh release view "$tag" --repo 'MaaAssistantArknights/MaaAssistantArknights' --json body --jq .body)
gh api /markdown -f text="$RELEASE_NOTES" | tee ./packages/MAA-"$tag"-macos-universal.html
done
curl -fsSL -o packages/appcast.xml https://maa-release.hguandl.com/macos/appcast.xml
- name: Setup Sparkle
run: |
gh release download --repo 'sparkle-project/Sparkle' --clobber -O - -p 'Sparkle-*.tar.xz' | tar xf -
- name: Generate Update Packages
run: |
if [ $(head -n 1 release_maa.txt | awk '{ print $2 }') = 'Pre-release' ]; then
echo ${{ secrets.SPARKLE_PRIV_KEY }} | ./bin/generate_appcast --channel beta --ed-key-file - ./packages
else
echo ${{ secrets.SPARKLE_PRIV_KEY }} | ./bin/generate_appcast --ed-key-file - ./packages
fi
- name: Cleanup files
run: |
find ./packages -type f ! \( -name 'MAA-${{ needs.create-tag.outputs.release_tag }}-macos-universal.dmg' -o -name '*.delta' -o -name '*.xml' \) -print -delete
- name: Upload to MaaRelease
uses: svenstaro/upload-release-action@v2
with:
repo_name: ${{ format('{0}/{1}', github.repository_owner, 'MaaRelease') }}
repo_token: ${{ secrets.MAARELEASE_RELEASE }}
file_glob: true
file: packages/*
tag: ${{ needs.create-tag.outputs.release_tag }}
prerelease: ${{ fromJSON(needs.create-tag.outputs.prerelease) }}
overwrite: true
release:
needs:
- make-ota
- make-ota-mac
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.MISTEOWORKFLOW }}
steps:
- name: Setup release mirror
run: |
gh workflow --repo MaaAssistantArknights/MaaRelease run release-mirrors.yml