-
Notifications
You must be signed in to change notification settings - Fork 4
183 lines (154 loc) · 6.21 KB
/
Copy pathmain.yml
File metadata and controls
183 lines (154 loc) · 6.21 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
name: Build and Release EXE
permissions:
contents: write
pull-requests: write
on:
push:
branches:
- main
jobs:
build:
environment: DISCORD_WEBHOOK
if: contains(github.event.head_commit.message, 'release v')
runs-on: windows-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Extract tag and body from commit message
id: extract_tag
shell: bash
run: |
echo "Commit message: ${{ github.event.head_commit.message }}"
TAG=$(echo "${{ github.event.head_commit.message }}" | sed -n 's/.*release[[:space:]]\+\(v[0-9.]\+\).*/\1/p')
BODY=$(echo "${{ github.event.head_commit.message }}" | sed -n 's/^\(.*\)[[:space:]]release[[:space:]]\+v[0-9.]\+.*$/\1/p')
if [ -z "$TAG" ]; then
echo "❌ No tag found in commit message. Expected format: 'something release vX.Y.Z'"
exit 1
fi
echo "✅ Extracted tag: $TAG"
echo "✅ Extracted body: $BODY"
echo "tag_name=$TAG" >> $GITHUB_OUTPUT
echo "release_body=$BODY" >> $GITHUB_OUTPUT
- name: Generate update.json with version
id: update_json
shell: bash
run: |
# Write JSON
cat <<EOF > update.json
{
"version": "${{ steps.extract_tag.outputs.tag_name }}",
"build_time": "$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
}
EOF
echo "✅ update.json created:"
cat update.json
- name: Install Base dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_noupscale.txt
pip install pyinstaller
- name: Build EXE with PyInstaller No Upscaling
shell: pwsh
run: |
pyinstaller --noconfirm --onefile --console `
--icon "swaplogo.ico" `
--name "MTGA_Swapper_NoUpscale" `
--add-data "C:/hostedtoolcache/windows/Python/3.11.9/x64/Lib/site-packages/archspec/json/cpu;archspec/json/cpu" `
--add-data "C:/hostedtoolcache/windows/Python/3.11.9/x64/Lib/site-packages/UnityPy;UnityPy/" `
--add-data "config.json;." `
--add-data "changes.json;." `
--add-data "update.json;." `
--add-data "TempLocalizations.csv;." `
main.py
- name: Install Upscaling dependencies
run: |
pip install -r requirements.txt
- name: Build EXE with PyInstaller Upscaling
shell: pwsh
run: |
pyinstaller --noconfirm --onefile --console `
--icon "swaplogo.ico" `
--name "MTGA_Swapper" `
--add-data "modelscsr.onnx;." `
--add-data "modelesrgan2.onnx;." `
--add-data "C:/hostedtoolcache/windows/Python/3.11.9/x64/Lib/site-packages/archspec/json/cpu;archspec/json/cpu" `
--add-data "C:/hostedtoolcache/windows/Python/3.11.9/x64/Lib/site-packages/UnityPy;UnityPy/" `
--add-data "config.json;." `
--add-data "changes.json;." `
--add-data "update.json;." `
--add-data "TempLocalizations.csv;." `
main.py
- name: Add checksums to update.json
id: add_checksums
shell: bash
run: |
# Calculate SHA256 checksums
SHA_MAIN=$(sha256sum dist/MTGA_Swapper.exe | cut -d ' ' -f1)
SHA_NOUPSCALE=$(sha256sum dist/MTGA_Swapper_NoUpscale.exe | cut -d ' ' -f1)
# Update JSON with downloads structure
jq --arg sha_main "$SHA_MAIN" \
--arg sha_noupscale "$SHA_NOUPSCALE" \
--arg tag "${{ steps.extract_tag.outputs.tag_name }}" \
--arg repo "${{ github.repository }}" \
'.downloads = {
"upscale": {
"url": ("https://github.com/" + $repo + "/releases/download/" + $tag + "/MTGA_Swapper.exe"),
"checksum": $sha_main
},
"no_upscale": {
"url": ("https://github.com/" + $repo + "/releases/download/" + $tag + "/MTGA_Swapper_NoUpscale.exe"),
"checksum": $sha_noupscale
}
}' update.json > update_tmp.json && mv update_tmp.json update.json
echo "✅ update.json updated with checksums and download URLs:"
cat update.json
- name: Commit update.json
run: |
git config user.name "github-actions"
git config user.email "github-actions@github.com"
git add update.json
git commit -m "Update update.json for ${{ steps.extract_tag.outputs.tag_name }}"
git push origin main
- name: Build changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v5
with:
configuration: .github/changelog-config.json
mode: "COMMIT"
toTag: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
- name: Create GitHub Release and Upload Files
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.extract_tag.outputs.tag_name }}
name: Release ${{ steps.extract_tag.outputs.tag_name }}
body: |
# Changelog Generated by Github Actions
${{ steps.build_changelog.outputs.changelog }}
files: |
dist/MTGA_Swapper.exe
dist/MTGA_Swapper_NoUpscale.exe
modelscsr.onnx
modelesrgan2.onnx
update.json
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
- name: Discord Notification
uses: sarisia/actions-status-discord@v1
if: always()
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
nodetail: true
title: "New version of `MTGA Swapper` is ready!"
description: |
Version `${{ steps.extract_tag.outputs.tag_name }}` has been released.
Click [here](https://github.com/BobJr23/MTGA_Swapper/releases/latest) to download!
Changes:
${{ steps.build_changelog.outputs.changelog }}
content: "<@&1430206703244148860>"
color: 0xff91a4