Skip to content

Improve GitHub Actions workflow with better error handling and debugging #3

Improve GitHub Actions workflow with better error handling and debugging

Improve GitHub Actions workflow with better error handling and debugging #3

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: windows-latest
artifact_name: android-bloatware-remover.exe
asset_name: android-bloatware-remover-windows.exe
- os: ubuntu-latest
artifact_name: android-bloatware-remover
asset_name: android-bloatware-remover-linux
- os: macos-latest
artifact_name: android-bloatware-remover
asset_name: android-bloatware-remover-macos
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller
- name: Create PyInstaller spec file
run: |
python -c "
import os

Check failure on line 41 in .github/workflows/build-release.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/build-release.yml

Invalid workflow file

You have an error in your yaml syntax on line 41
spec_content = '''# -*- mode: python ; coding: utf-8 -*-
import os
block_cipher = None
# Collect all brand directories and their contents
brand_dirs = ['Samsung', 'Xiaomi', 'Oppo', 'Vivo', 'Realme', 'Tecno', 'OnePlus', 'Huawei', 'Honor', 'Motorola', 'Nothing']
datas = []
# Add brand directories (only if they exist)
for brand in brand_dirs:
if os.path.exists(brand):
md_files = os.path.join(brand, '*.md')
py_files = os.path.join(brand, '*.py')
datas.append((md_files, brand + '/'))
datas.append((py_files, brand + '/'))
# Add core module
if os.path.exists('core'):
datas.append(('core/*.py', 'core/'))
# Add other files (only if they exist)
if os.path.exists('README.md'):
datas.append(('README.md', '.'))
if os.path.exists('LICENSE'):
datas.append(('LICENSE', '.'))
a = Analysis(
['main.py'],
pathex=[os.getcwd()],
binaries=[],
datas=datas,
hiddenimports=[
'Samsung.samsung_remover',
'Xiaomi.xiaomi_remover',
'Oppo.oppo_remover',
'Vivo.vivo_remover',
'Realme.realme_remover',
'Tecno.tecno_remover',
'OnePlus.oneplus_remover',
'Huawei.huawei_remover',
'Honor.honor_remover',
'Motorola.motorola_remover',
'Nothing.nothing_remover',
'core.bloatware_remover',
'device_detector',
'version'
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='android-bloatware-remover',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
'''
with open('android-bloatware-remover.spec', 'w') as f:
f.write(spec_content)
print('Spec file created successfully')
"
- name: Build with PyInstaller
run: |
echo "Building with PyInstaller..."
echo "Current directory: $(pwd)"
echo "Files in current directory:"
ls -la
echo "Building executable..."
pyinstaller android-bloatware-remover.spec --clean --log-level INFO
echo "Build completed. Checking dist directory:"
ls -la dist/ || echo "dist directory not found"
- name: Test executable (Windows)
if: matrix.os == 'windows-latest'
run: |
echo "Testing Windows executable..."
if (Test-Path "dist/android-bloatware-remover.exe") {
echo "Executable exists, running test..."
Start-Process -FilePath "dist/android-bloatware-remover.exe" -ArgumentList "--test" -Wait -NoNewWindow -PassThru
} else {
echo "Executable not found!"
exit 1
}
shell: powershell
timeout-minutes: 2
- name: Test executable (Unix)
if: matrix.os != 'windows-latest'
run: |
echo "Testing Unix executable..."
if [ -f "dist/android-bloatware-remover" ]; then
echo "Executable exists, running test..."
chmod +x dist/android-bloatware-remover
timeout 30s dist/android-bloatware-remover --test || echo "Test completed with timeout"
else
echo "Executable not found!"
exit 1
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.asset_name }}
path: dist/${{ matrix.artifact_name }}
release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.ref_name }}
name: Release ${{ github.ref_name }}
body: |
## Android Bloatware Remover ${{ github.ref_name }}
Standalone executables for Windows, Linux, and macOS.
### Download Instructions:
- **Windows**: Download `android-bloatware-remover-windows.exe`
- **Linux**: Download `android-bloatware-remover-linux`
- **macOS**: Download `android-bloatware-remover-macos`
### Usage:
1. Download the appropriate executable for your operating system
2. Make sure ADB is installed and in your PATH
3. Enable USB debugging on your Android device
4. Connect your device and run the executable
### Supported Devices:
- Samsung (One UI)
- Xiaomi/Redmi/POCO (MIUI)
- Oppo (ColorOS)
- Vivo/iQOO (FunTouch OS)
- Realme (Realme UI)
- Tecno (HiOS)
- OnePlus (OxygenOS)
- Huawei (EMUI/HarmonyOS)
- Honor (Magic UI)
- Motorola (My UX)
- Nothing (Nothing OS)
### Test Mode:
Run with `--test` flag to try without a connected device.
draft: false
prerelease: false
files: |
android-bloatware-remover-windows.exe/android-bloatware-remover.exe
android-bloatware-remover-linux/android-bloatware-remover
android-bloatware-remover-macos/android-bloatware-remover
fail_on_unmatched_files: false