Skip to content

Commit 06735f5

Browse files
committed
fix: Clean up build workflow and CLI script; remove unused caching and UPX steps
1 parent 96cf15e commit 06735f5

File tree

2 files changed

+8
-112
lines changed

2 files changed

+8
-112
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -26,125 +26,22 @@ jobs:
2626
with:
2727
python-version: "3.11"
2828
cache: "pip"
29-
30-
# Cache PyInstaller build files to speed up future builds
31-
- name: Cache PyInstaller build files
32-
uses: actions/cache@v3
33-
with:
34-
path: |
35-
build
36-
__pycache__
37-
key: ${{ runner.os }}-pyinstaller-${{ hashFiles('**/*.py') }}-${{ matrix.name }}
38-
restore-keys: |
39-
${{ runner.os }}-pyinstaller-
4029

4130
- name: Install dependencies and PyInstaller
42-
run: |
43-
pip install -r requirements.txt
44-
pip install pyinstaller -U
45-
pip install pyinstaller-hooks-contrib -U
46-
47-
# Download UPX for better compression
48-
- name: Download UPX
49-
run: |
50-
$upxVersion = "5.0.0"
51-
Invoke-WebRequest -Uri "https://github.com/upx/upx/releases/download/v$upxVersion/upx-$upxVersion-win64.zip" -OutFile "upx.zip"
52-
Expand-Archive -Path "upx.zip" -DestinationPath "."
53-
Move-Item -Path "upx-$upxVersion-win64\upx.exe" -Destination "upx.exe"
54-
55-
# Extract version from base.py for use in the build
56-
- name: Extract version
57-
id: extract_version
58-
run: |
59-
$version = (Select-String -Path 'base.py' -Pattern 'VERSION = "(.*)"').Matches.Groups[1].Value
60-
echo "VERSION=$version" >> $env:GITHUB_OUTPUT
61-
echo "Version extracted: $version"
62-
63-
# Create version info file dynamically
64-
- name: Create version info file
65-
run: |
66-
$version = "${{ steps.extract_version.outputs.VERSION }}"
67-
# Remove 'v' prefix if present
68-
if ($version.StartsWith('v')) {
69-
$version = $version.Substring(1)
70-
}
71-
72-
$versionParts = $version.Split('.')
73-
# Ensure we have at least 3 parts
74-
while ($versionParts.Length -lt 3) {
75-
$versionParts += "0"
76-
}
77-
78-
$fileVersion = "$($versionParts[0]),$($versionParts[1]),$($versionParts[2]),0"
79-
$productVersion = $fileVersion
80-
81-
@"
82-
VSVersionInfo(
83-
ffi=FixedFileInfo(
84-
filevers=($fileVersion),
85-
prodvers=($productVersion),
86-
mask=0x3f,
87-
flags=0x0,
88-
OS=0x40004,
89-
fileType=0x1,
90-
subtype=0x0,
91-
date=(0, 0)
92-
),
93-
kids=[
94-
StringFileInfo(
95-
[
96-
StringTable(
97-
u'040904B0',
98-
[StringStruct(u'CompanyName', u'techtanic'),
99-
StringStruct(u'FileDescription', u'Discounted Udemy Course Enroller'),
100-
StringStruct(u'FileVersion', u'$version'),
101-
StringStruct(u'InternalName', u'Discounted-Udemy-Course-Enroller'),
102-
StringStruct(u'LegalCopyright', u'Copyright (c) 2025 techtanic'),
103-
StringStruct(u'OriginalFilename', u'${{ matrix.name }}.exe'),
104-
StringStruct(u'ProductName', u'DUCE'),
105-
StringStruct(u'ProductVersion', u'$version')])
106-
]),
107-
VarFileInfo([VarStruct(u'Translation', [1033, 1200])])
108-
]
109-
)
110-
"@ | Out-File -FilePath "version-info.txt" -Encoding utf8
111-
112-
# Display the content of the file for debugging
113-
Get-Content -Path "version-info.txt"
31+
run: pip install -r requirements.txt pyinstaller -U
11432

11533
- name: Build ${{ matrix.name }}
11634
run: >
117-
pyinstaller -y -F ${{ matrix.mode }}
118-
-i "extra/DUCE-LOGO.ico"
119-
--clean
120-
--name "${{ matrix.name }}"
121-
--upx-dir="./"
122-
--add-data "base.py;."
123-
--add-data "colors.py;."
124-
--add-data "default-duce-${{ matrix.script }}-settings.json;."
125-
--add-data "README.md;."
126-
--add-data "LICENSE;."
127-
--exclude-module tkinter
128-
--exclude-module matplotlib
129-
--exclude-module PyQt5
130-
--exclude-module numpy
131-
--version-file="version-info.txt"
35+
pyinstaller -y -F ${{ matrix.mode }} -i "extra/DUCE-LOGO.ico" --clean --name "${{ matrix.name }}"
36+
--add-data "base.py;."
37+
--add-data "colors.py;."
38+
--add-data "default-duce-${{ matrix.script }}-settings.json;."
39+
--add-data "README.md;."
40+
--add-data "LICENSE;."
13241
"${{ matrix.script }}.py"
133-
env:
134-
VERSION: ${{ steps.extract_version.outputs.VERSION }}
135-
136-
- name: Optimize executable size
137-
run: |
138-
# Clean up unnecessary files
139-
Get-ChildItem -Path dist -Filter "*.exe" | ForEach-Object {
140-
$exePath = $_.FullName
141-
$fileSize = [math]::Round((Get-Item $exePath).Length / 1MB, 2)
142-
Write-Host "Executable size: $fileSize MB"
143-
}
14442
14543
- name: Upload ${{ matrix.name }}.exe
14644
uses: actions/upload-artifact@v4
14745
with:
148-
name: ${{ matrix.name }}-${{ steps.extract_version.outputs.VERSION }}
46+
name: ${{ matrix.name }}.exe
14947
path: ./dist/${{ matrix.name }}.exe
150-
if-no-files-found: error

cli.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import time
33
import traceback
44
import sys
5-
import os
65
from datetime import datetime
76

87
from rich.console import Console

0 commit comments

Comments
 (0)