-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_and_publish.ps1
More file actions
53 lines (48 loc) · 1.62 KB
/
build_and_publish.ps1
File metadata and controls
53 lines (48 loc) · 1.62 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
$ErrorActionPreference = "Stop"
Write-Host "Step 1: Updating Versions..." -ForegroundColor Cyan
try {
python tools/update_versions.py
if ($LASTEXITCODE -ne 0) { throw "Version update failed." }
Write-Host "Versions updated successfully." -ForegroundColor Green
}
catch {
Write-Error "Version update failed. Aborting build."
exit 1
}
Write-Host "`nStep 2: Running Unit Tests..." -ForegroundColor Cyan
try {
# Run unittest discovery on the tests directory
python -m unittest discover tests
if ($LASTEXITCODE -ne 0) { throw "Tests failed." }
Write-Host "Tests passed successfully." -ForegroundColor Green
}
catch {
Write-Error "Unit tests failed. Aborting build."
exit 1
}
Write-Host "`nStep 3: Building the Project..." -ForegroundColor Cyan
try {
# Clean previous builds
if (Test-Path "dist") { Remove-Item "dist" -Recurse -Force }
if (Test-Path "build") { Remove-Item "build" -Recurse -Force }
# helper to ensure 'build' module is installed: pip install build
python -m build
if ($LASTEXITCODE -ne 0) { throw "Build failed." }
Write-Host "Build completed successfully." -ForegroundColor Green
}
catch {
Write-Error "Build failed. Aborting upload."
exit 1
}
Write-Host "`nStep 4: Uploading to PyPI..." -ForegroundColor Cyan
try {
# Upload specifically the newly created files in dist/
# This requires 'twine' to be installed: pip install twine
twine upload dist/*
if ($LASTEXITCODE -ne 0) { throw "Upload failed." }
Write-Host "Uploaded to PyPI successfully." -ForegroundColor Green
}
catch {
Write-Error "Upload to PyPI failed."
exit 1
}