-
Notifications
You must be signed in to change notification settings - Fork 121
213 lines (191 loc) · 7.51 KB
/
Copy pathbuild-and-release.yml
File metadata and controls
213 lines (191 loc) · 7.51 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
name: Build, Release, and Publish Updates
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build-cpu:
runs-on: windows-latest
name: Build CPU Version
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_cpu.txt
pip install pyinstaller
- name: Build CPU version
run: python build_packages.py ${{ github.ref_name }} --build cpu
- name: Upload CPU artifacts
uses: actions/upload-artifact@v4
with:
name: manga-translator-cpu
path: dist/manga-translator-cpu/
build-gpu:
runs-on: windows-latest
name: Build GPU Version
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements_gpu.txt
pip install pyinstaller
- name: Build GPU version
run: python build_packages.py ${{ github.ref_name }} --build gpu
- name: Upload GPU artifacts
uses: actions/upload-artifact@v4
with:
name: manga-translator-gpu
path: dist/manga-translator-gpu/
release-and-publish:
needs: [build-cpu, build-gpu]
runs-on: ubuntu-latest
name: Create Release and Publish Updates
permissions:
contents: write # Required to push to gh-pages branch
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch LFS files
run: |
git lfs fetch --all
git lfs pull
- name: Restore Previous TUF Assets
env:
GH_TOKEN: ${{ github.token }}
run: |
echo "Checking for previous release to restore assets for diffing..."
# Get the tag of the release before this one
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
if [ -z "$PREVIOUS_TAG" ]; then
echo "No previous tag found. Assuming this is the first release. Skipping asset restore."
exit 0
fi
echo "Found previous release tag: $PREVIOUS_TAG"
TUF_TARGETS_DIR="update_repository/targets"
mkdir -p $TUF_TARGETS_DIR
echo "Downloading assets from release $PREVIOUS_TAG..."
gh release download $PREVIOUS_TAG -D $TUF_TARGETS_DIR -p "*.tar.gz.7z.*" || true
echo "Merging split archives..."
for f in $(find $TUF_TARGETS_DIR -name '*.tar.gz.7z.001'); do
echo "Merging $f..."
# The `e` command extracts and automatically merges multi-part archives
7z e -o"$TUF_TARGETS_DIR" "$f"
# Clean up the downloaded split parts
rm $f*
done
echo "Asset restoration complete. Final files in $TUF_TARGETS_DIR:"
ls -l $TUF_TARGETS_DIR
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'
- name: Install tufup and 7-Zip
run: |
python -m pip install tufup
sudo apt-get update
sudo apt-get install -y p7zip-full
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist/
- name: Restore TUF Private Keys
env:
TUF_ROOT_KEY: ${{ secrets.TUF_ROOT_KEY }}
TUF_TARGETS_KEY: ${{ secrets.TUF_TARGETS_KEY }}
TUF_SNAPSHOT_KEY: ${{ secrets.TUF_SNAPSHOT_KEY }}
TUF_TIMESTAMP_KEY: ${{ secrets.TUF_TIMESTAMP_KEY }}
run: |
echo "Restoring TUF private keys from secrets..."
KEYS_DIR="keys"
mkdir -p $KEYS_DIR
echo "$TUF_ROOT_KEY" > "$KEYS_DIR/root"
echo "$TUF_TARGETS_KEY" > "$KEYS_DIR/targets"
echo "$TUF_SNAPSHOT_KEY" > "$KEYS_DIR/snapshot"
echo "$TUF_TIMESTAMP_KEY" > "$KEYS_DIR/timestamp"
echo "Private keys restored."
- name: Update TUF Repository
run: |
python build_packages.py ${{ github.ref_name }} --update-repo --skip-build
- name: Verify TUF metadata
run: |
echo "Verifying contents of update_repository before deployment:"
ls -lR update_repository/
- name: Deploy Repository to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
personal_token: ${{ secrets.GH_PAT }}
publish_dir: ./update_repository
publish_branch: gh-pages
user_name: 'github-actions[bot]'
user_email: 'github-actions[bot]@users.noreply.github.com'
commit_message: 'Deploy TUF repository for ${{ github.ref_name }}'
exclude_assets: '**/*.tar.gz'
- name: Bundle extra directories into _internal
run: |
echo "Bundling extra directories into _internal..."
mkdir -p dist/manga-translator-cpu/_internal/update_repository
mkdir -p dist/manga-translator-gpu/_internal/update_repository
cp -r examples dist/manga-translator-cpu/_internal/
cp -r fonts dist/manga-translator-cpu/_internal/
cp -r models dist/manga-translator-cpu/_internal/
cp -r dict dist/manga-translator-cpu/_internal/
cp -r update_repository/metadata dist/manga-translator-cpu/_internal/update_repository/
cp -r MangaStudio_Data dist/manga-translator-cpu/_internal/
cp VERSION dist/manga-translator-cpu/_internal/
cp -r examples dist/manga-translator-gpu/_internal/
cp -r fonts dist/manga-translator-gpu/_internal/
cp -r models dist/manga-translator-gpu/_internal/
cp -r dict dist/manga-translator-gpu/_internal/
cp -r update_repository/metadata dist/manga-translator-gpu/_internal/update_repository/
cp -r MangaStudio_Data dist/manga-translator-gpu/_internal/
cp VERSION dist/manga-translator-gpu/_internal/
- name: Create Release Archives using 7-Zip with Splitting
run: |
mkdir -p release_assets
echo "Archiving CPU version..."
cd dist/manga-translator-cpu/
7z a -v1990m -m0=lzma2 -ms=on ../../release_assets/manga-translator-cpu-${{ github.ref_name }}.7z .
cd ../../
echo "CPU version archived. Deleting source directory to save space..."
rm -rf dist/manga-translator-cpu
echo "Archiving GPU version..."
cd dist/manga-translator-gpu/
7z a -v1990m -m0=lzma2 -ms=on ../../release_assets/manga-translator-gpu-${{ github.ref_name }}.7z .
cd ../../
echo "GPU version archived. Deleting source directory to save space..."
rm -rf dist/manga-translator-gpu
- name: Prepare TUF Assets for Release
run: |
echo "Preparing TUF assets..."
TUF_TARGETS_DIR="update_repository/targets"
RELEASE_ASSETS_DIR="release_assets"
# Copy any TUF assets that are small enough directly
find $TUF_TARGETS_DIR -type f -size -1990M -exec cp {} $RELEASE_ASSETS_DIR/ \;
# For TUF assets that are too large, create split archives
find $TUF_TARGETS_DIR -type f -size +1990M | while read f; do
echo "Splitting large TUF asset: $f"
7z a -v1990m "$RELEASE_ASSETS_DIR/$(basename "$f").7z" "$f"
done
echo "Final release assets list:"
ls -l $RELEASE_ASSETS_DIR
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
files: release_assets/*
draft: false
prerelease: false