Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
name: CI
name: Tests

on:
push:
branches: [main, support/win]
pull_request:
release:
types: [published]

permissions:
contents: read

jobs:
test:
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
if: github.event_name != 'release' || github.event.release.prerelease == true
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand All @@ -34,3 +40,25 @@ jobs:

- name: Test
run: pytest

package-smoke:
name: Package smoke test
if: github.event_name != 'release' || github.event.release.prerelease == true
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip

- name: Install build frontend
run: python -m pip install --upgrade build

- name: Build source and wheel distributions
run: python -m build

- name: Check artifacts exist
run: test -n "$(find dist -maxdepth 1 -type f \( -name '*.tar.gz' -o -name '*.whl' \) -print -quit)"
77 changes: 77 additions & 0 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: Release Build

on:
release:
types: [published]

permissions:
contents: write

jobs:
python-package:
name: Build Python package
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip

- name: Install build frontend
run: python -m pip install --upgrade build

- name: Build source and wheel distributions
run: python -m build

- uses: actions/upload-artifact@v4
with:
name: willy-python-package
path: dist/*

- name: Upload package files to release
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.event.release.tag_name }}
run: gh release upload "$TAG_NAME" dist/* --clobber

windows-tray:
name: Build Windows tray
runs-on: windows-latest

steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.release.tag_name }}

- uses: actions/setup-python@v5
with:
python-version: "3.12"
cache: pip

- name: Install project
run: python -m pip install -e ".[dev]"

- name: Build tray executable
shell: pwsh
run: .\scripts\dev.ps1 build-exe

- name: Archive tray executable
shell: pwsh
run: Compress-Archive -Path .\dist\WillyTray -DestinationPath .\dist\WillyTray-windows-x64.zip -Force

- uses: actions/upload-artifact@v4
with:
name: WillyTray-windows-x64
path: dist/WillyTray-windows-x64.zip

- name: Upload tray executable to release
shell: pwsh
env:
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.event.release.tag_name }}
run: gh release upload $env:TAG_NAME .\dist\WillyTray-windows-x64.zip --clobber
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ version = "0.1.10"
description = "Local-first Git sync for OrcaSlicer profiles."
readme = "README.md"
requires-python = ">=3.11"
license = { text = "AGPL-3.0-only" }
license = "AGPL-3.0-only"
authors = [
{ name = "Gabriel Saraiva", email = "extremez3r0@gmail.com" },
]
Expand All @@ -18,7 +18,6 @@ classifiers = [
"Environment :: Console",
"Environment :: Win32 (MS Windows)",
"Intended Audience :: End Users/Desktop",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Operating System :: MacOS",
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
Expand Down
68 changes: 42 additions & 26 deletions scripts/dev.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,32 @@ $WillyExe = Join-Path $ScriptsDir "willy.exe"
$PyInstallerExe = Join-Path $ScriptsDir "pyinstaller.exe"
$IconPng = Join-Path $RepoRoot "assets\\icon.png"
$IconIco = Join-Path $RepoRoot "assets\\icon.ico"

function Invoke-Native {
param(
[Parameter(Mandatory = $true)]
[string]$FilePath,
[Parameter(ValueFromRemainingArguments = $true)]
[string[]]$Arguments
)

& $FilePath @Arguments
if ($LASTEXITCODE -ne 0) {
throw "Command failed with exit code ${LASTEXITCODE}: $FilePath $($Arguments -join ' ')"
}
}

function Ensure-Venv {
if (-not (Test-Path $PythonExe)) {
python -m venv $VenvDir
}
}
function Install-Env {
Ensure-Venv
& $PythonExe -m pip install --upgrade pip
& $PythonExe -m pip install -e '.[dev]'
}
function Ensure-Venv {
if (-not (Test-Path $PythonExe)) {
Invoke-Native python -m venv $VenvDir
}
}

function Install-Env {
Ensure-Venv
Invoke-Native $PythonExe -m pip install --upgrade pip
Invoke-Native $PythonExe -m pip install -e '.[dev]'
}

function Install-Hooks {
if (-not (Test-Path (Join-Path $RepoRoot ".git"))) {
Expand Down Expand Up @@ -75,28 +89,30 @@ try {
"install" {
Install-Env
}
"lint" {
Ensure-Venv
& $RuffExe check --fix src tests
& $RuffExe format src tests
& $RuffExe check src tests
}
"test" {
Ensure-Venv
& $PytestExe
}
"lint" {
Ensure-Venv
Invoke-Native $RuffExe check --fix src tests
Invoke-Native $RuffExe format src tests
Invoke-Native $RuffExe check src tests
}
"test" {
Ensure-Venv
Invoke-Native $PytestExe
}
"run" {
Ensure-Venv
& $WillyExe start
Invoke-Native $WillyExe start
}
"tray" {
Ensure-Venv
& $WillyExe statusbar
Invoke-Native $WillyExe statusbar
}
"build-exe" {
Ensure-Venv
Remove-Item -LiteralPath (Join-Path $RepoRoot "build\\WillyTray") -Recurse -Force -ErrorAction SilentlyContinue
Remove-Item -LiteralPath (Join-Path $RepoRoot "dist\\WillyTray") -Recurse -Force -ErrorAction SilentlyContinue
if ((Test-Path $IconPng) -and -not (Test-Path $IconIco)) {
& $PythonExe -c "from PIL import Image; Image.open(r'$IconPng').save(r'$IconIco', sizes=[(16,16),(32,32),(48,48),(64,64),(128,128),(256,256)])"
Invoke-Native $PythonExe -c "from PIL import Image; Image.open(r'$IconPng').save(r'$IconIco', sizes=[(16,16),(32,32),(48,48),(64,64),(128,128),(256,256)])"
}
$args = @(
"--noconfirm",
Expand All @@ -114,11 +130,11 @@ try {
$args += @("--icon", $IconIco)
}
$args += ".\\src\\willy\\tray_app.py"
& $PyInstallerExe @args
Invoke-Native $PyInstallerExe @args
}
"stop" {
Ensure-Venv
& $WillyExe stop
Invoke-Native $WillyExe stop
}
"hooks" {
Install-Hooks
Expand Down
Loading
Loading