-
Notifications
You must be signed in to change notification settings - Fork 0
168 lines (144 loc) · 6.53 KB
/
Copy pathpython-check.yml
File metadata and controls
168 lines (144 loc) · 6.53 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
name: Python checks
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
contents: read
concurrency:
group: video-translator-checks-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
verify:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"
- name: Install runtime dependencies
shell: pwsh
run: |
python -m pip install -r requirements.txt -r requirements-optional-ai.txt
python -m pip check
- name: Compile application, package, tests and tools
shell: pwsh
run: python -m compileall -q video_translator.py videotranslator tests tools
- name: Run offline regression tests
shell: pwsh
run: |
$env:TEMP = $env:RUNNER_TEMP
$env:TMP = $env:RUNNER_TEMP
python -m unittest discover -s tests -v
package-windows:
needs: verify
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && contains(github.event.head_commit.message, '[package]'))
runs-on: windows-latest
timeout-minutes: 120
env:
PYTHONUTF8: "1"
PYTHONIOENCODING: "utf-8"
steps:
- name: Checkout repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
cache: pip
cache-dependency-path: requirements.txt
- name: Install application and build dependencies
shell: pwsh
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt -r requirements-optional-ai.txt "pyinstaller==6.22.3"
python -m pip check
- name: Install and locate FFmpeg
shell: pwsh
run: |
choco install ffmpeg -y --no-progress
$chocoRoot = if ($env:ChocolateyInstall) { $env:ChocolateyInstall } else { 'C:\ProgramData\chocolatey' }
$ffmpeg = (Get-ChildItem "$chocoRoot\lib" -Filter ffmpeg.exe -Recurse -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -match '\\bin\\ffmpeg\.exe$' } | Select-Object -First 1).FullName
$ffprobe = (Get-ChildItem "$chocoRoot\lib" -Filter ffprobe.exe -Recurse -ErrorAction SilentlyContinue |
Where-Object { $_.FullName -match '\\bin\\ffprobe\.exe$' } | Select-Object -First 1).FullName
if (-not $ffmpeg -or -not $ffprobe) { throw 'Real ffmpeg/ffprobe binaries were not found in the Chocolatey package' }
& $ffmpeg -version
& $ffprobe -version
"FFMPEG_BINARY=$ffmpeg" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
"FFPROBE_BINARY=$ffprobe" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Verify source with installed runtime dependencies
shell: pwsh
run: |
python -m compileall -q video_translator.py videotranslator tests tools
python -m unittest discover -s tests -v
- name: Build self-contained Windows EXE
shell: pwsh
run: |
python tools/build_exe.py --onefile
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
Move-Item -LiteralPath 'dist\VideoTranslatorPRO.exe' -Destination 'dist\Video-Translator-Pro.exe'
- name: Smoke-test packaged EXE and create checksum
shell: pwsh
run: |
$exe = 'dist\Video-Translator-Pro.exe'
if (-not (Test-Path $exe)) { throw 'Video-Translator-Pro.exe was not created' }
$process = Start-Process -FilePath $exe -ArgumentList '--self-test' -PassThru -Wait
if ($process.ExitCode -ne 0) { throw "Packaged self-test failed with exit code $($process.ExitCode)" }
$hash = (Get-FileHash $exe -Algorithm SHA256).Hash.ToLowerInvariant()
"$hash Video-Translator-Pro.exe" | Set-Content 'dist\Video-Translator-Pro.sha256.txt' -Encoding ascii
Get-Item $exe | Format-List Name,Length,LastWriteTime
Get-Content 'dist\Video-Translator-Pro.sha256.txt'
- name: Upload verified Windows binary
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: Video-Translator-Pro-Windows-x64
path: |
dist/Video-Translator-Pro.exe
dist/Video-Translator-Pro.sha256.txt
if-no-files-found: error
retention-days: 30
publish-release:
needs: package-windows
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && contains(github.event.head_commit.message, '[package]'))
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout release notes
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 2
- name: Require fresh Russian release notes on package pushes
if: github.event_name == 'push'
shell: bash
run: |
set -euo pipefail
git diff-tree --no-commit-id --name-only -r "$GITHUB_SHA" | grep -Fxq RELEASE_NOTES_RU.md || {
echo "RELEASE_NOTES_RU.md must be updated in the same [package] commit."
exit 1
}
- name: Download exact binary built above
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: Video-Translator-Pro-Windows-x64
path: release
- name: Publish GitHub Release with Russian notes
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
short_sha="${GITHUB_SHA::7}"
tag="build-$short_sha"
title="Video Translator Pro — Windows-сборка $short_sha"
if gh release view "$tag" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release edit "$tag" --repo "$GITHUB_REPOSITORY" --title "$title" --notes-file RELEASE_NOTES_RU.md
gh release upload "$tag" release/Video-Translator-Pro.exe release/Video-Translator-Pro.sha256.txt --repo "$GITHUB_REPOSITORY" --clobber
else
gh release create "$tag" release/Video-Translator-Pro.exe release/Video-Translator-Pro.sha256.txt --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" --title "$title" --notes-file RELEASE_NOTES_RU.md --prerelease
fi