Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
6da3fb6
add pyinstaller to dev tools,
sjswerdloff May 21, 2025
7f76d01
changed from sys.argv[0] to sys.executable per: https://github.com/py…
sjswerdloff May 21, 2025
03b74d6
make config file searches work within a pyinstaller executable
sjswerdloff May 21, 2025
3134c00
remove .toml files from dist after doing a compress-archive
sjswerdloff May 21, 2025
e7bca61
bump poetry version to 2.1.1, the repo is using a relatively new vers…
sjswerdloff May 21, 2025
9096623
Update tdwii_plus_examples/cli/upsscp/upsscp.py
sjswerdloff May 21, 2025
803dc20
Update .github/workflows/build-executables.yml
sjswerdloff May 21, 2025
41f6f72
Update .github/workflows/build-executables.yml
sjswerdloff May 21, 2025
0918d11
Merge branch 'add_pyinstaller_build' of github.com:sjswerdloff/tdwii_…
sjswerdloff May 21, 2025
6d99ec2
fix syntax error, change names to match current repo
sjswerdloff May 21, 2025
78c3179
additional corrections for FileExistsError to FileNotFoundError
sjswerdloff May 21, 2025
bdb9d31
Merge branch 'add_pyinstaller_build' into sjswerdloff-patch-1
sjswerdloff May 21, 2025
e666801
try to fix removal of dist/config directory and contents (after it ha…
sjswerdloff May 21, 2025
43af620
fix pwsh copy command, add cacheing
sjswerdloff May 21, 2025
1dea0fe
check -> scan
sjswerdloff May 21, 2025
418675b
DestinationPath -> Destination
sjswerdloff May 21, 2025
fb2ea1d
tomli vs tomllib after python 3.11
sjswerdloff May 21, 2025
f6c97cc
missed a few tomli -> tomllib as tomli for python >=3.11
sjswerdloff May 21, 2025
5a36999
deleting build-executables.yml in favour of alt_build_executables.yml
sjswerdloff May 21, 2025
0d26fe3
fix path issue in upsscp.py for relative instance folder
sjswerdloff May 22, 2025
415adc2
added gen_tx_record as an exe
sjswerdloff May 22, 2025
a0ff187
eliminate safety scan, it forces an older version of psutil and it's …
sjswerdloff May 22, 2025
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
175 changes: 126 additions & 49 deletions .github/workflows/alt_build_executables.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
name: Alt Build Executables
name: Build Windows Executables

on:
workflow_dispatch: # Manual trigger
push:
branches: [main] # Automatically run on main branch updates
paths:
- 'tdwii_plus_examples/**'
- 'poetry.lock'
- 'pyproject.toml'
- '.github/workflows/build_executables.yml'

permissions:
contents: write # This allows creating releases and tags
Expand All @@ -10,34 +17,64 @@ jobs:
build:
strategy:
matrix:
os: [windows-latest] # , macos-latest, ubuntu-latest]
os: [windows-latest] # Currently only building for Windows
include:
- os: windows-latest
asset-name: tdwii_plus_examples
# platform-name: windows
# path-sep: ";"

# - os: macos-latest
# platform-name: macos
# asset-name: tdwii_plus_examples-macos
# path-sep: ":"

# - os: ubuntu-latest
# platform-name: ubuntu
# asset-name: tdwii_plus_examples-ubuntu
# path-sep: ":"

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper versioning

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

# Setup cache keys with security considerations
- name: Set up cache key
id: cache-key
shell: bash
run: |
echo "python-version=$(python -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}")' | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "poetry-version=2.1.1" >> $GITHUB_OUTPUT
echo "dep-hash=${{ runner.os }}-$(cat poetry.lock 2>/dev/null | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
echo "branch-id=$(echo ${{ github.ref }} | sha256sum | cut -d' ' -f1)" >> $GITHUB_OUTPUT
# Add weekly cache rotation for security
echo "weekly-rotation=$(( $(date +%s) / (7*24*60*60) ))" >> $GITHUB_OUTPUT

# Cache Poetry installation
- name: Cache Poetry installation
uses: actions/cache@v4
with:
path: ~/.cache/pypoetry
key: poetry-${{ steps.cache-key.outputs.poetry-version }}-${{ steps.cache-key.outputs.python-version }}
restore-keys: |
poetry-${{ steps.cache-key.outputs.poetry-version }}-

# Cache Python dependencies with security controls
- name: Cache Python dependencies
uses: actions/cache@v4
with:
path: .venv
key: venv-${{ runner.os }}-${{ steps.cache-key.outputs.python-version }}-${{ steps.cache-key.outputs.dep-hash }}-${{ steps.cache-key.outputs.branch-id }}-${{ steps.cache-key.outputs.weekly-rotation }}
restore-keys: |
venv-${{ runner.os }}-${{ steps.cache-key.outputs.python-version }}-${{ steps.cache-key.outputs.dep-hash }}-${{ steps.cache-key.outputs.branch-id }}-
venv-${{ runner.os }}-${{ steps.cache-key.outputs.python-version }}-${{ steps.cache-key.outputs.dep-hash }}-

# Cache PyInstaller artifacts
- name: Cache PyInstaller
uses: actions/cache@v4
with:
path: |
~\AppData\Local\pyinstaller
~/.cache/pyinstaller
key: ${{ runner.os }}-pyinstaller-${{ steps.cache-key.outputs.python-version }}-${{ steps.cache-key.outputs.weekly-rotation }}

- name: Install Poetry
uses: snok/install-poetry@v1
with:
Expand All @@ -50,64 +87,104 @@ jobs:
run: |
poetry install --with=dev

# # Security scan of dependencies
# # Eliminated because it's a paid service (which is OK for a business, not for this)
# # and because it forces downgrade of psutil which then conflicts with other needs.
# - name: Security scan of dependencies
# shell: bash
# run: |
# poetry run pip install safety
# poetry run safety scan --full-report || echo "Security vulnerabilities found - review the report above"

# Build Windows executables with PyInstaller
- name: Build with PyInstaller (Windows)
if: matrix.os == 'windows-latest'
shell: bash
run: |
poetry run pyinstaller --onefile --name=tdwii_config_dump.exe tdwii_plus_examples/cli/config_dump.py
poetry run pyinstaller --onefile --windowed --name=eScheduler.exe tdwii_plus_examples/rtbdi_creator/mainbdiwidget.py
poetry run pyinstaller --onefile --windowed --name=ppvs_proxy.exe tdwii_plus_examples/TDWII_PPVS_subscriber/ppvs_subscriber_widget.py
poetry run pyinstaller --onefile --name=eTMS.exe tdwii_plus_examples/cli/upsscp/upsscp.py
poetry run pyinstaller --onefile --name=tdwii_config_dump.exe tdwii_plus_examples/cli/config_dump.py
poetry run pyinstaller --onefile --windowed --name=eScheduler.exe tdwii_plus_examples/rtbdi_creator/mainbdiwidget.py
poetry run pyinstaller --onefile --windowed --name=ppvs_proxy.exe tdwii_plus_examples/TDWII_PPVS_subscriber/ppvs_subscriber_widget.py
poetry run pyinstaller --onefile --name=eTMS.exe tdwii_plus_examples/cli/upsscp/upsscp.py
poetry run pyinstaller --onefile --windowed --name=TDD.exe tdwii_plus_examples/tdd/tdd_widget.py
poetry run pyinstaller --onefile --name=generate_treatment_record_from_plan.exe tdwii_plus_examples/generate_treatment_record_from_plan.py
cp rtbdi.toml dist/
cp ppvs.toml dist/
mkdir dist/config
cp tdd.toml dist/
mkdir -p dist/config
cp ./tdwii_plus_examples/config/ApplicationEntities.json dist/config/
cp ./tdwii_plus_examples/config/MachineMap.json dist/config/
cp ./tdwii_plus_examples/cli/upsscp/config/upsscp_default.ini dist/config


# - name: Create distribution package (macOS/Linux)
# if: matrix.os != 'windows-latest'
# run: |
# mkdir dist-package
# if [ "${{ matrix.os }}" = "macos-latest" ]; then
# cp -r dist/tdwii_plus_examples.app dist-package/
# # Create a DMG file for easier distribution
# hdiutil create -volname tdwii_plus_examples -srcfolder dist-package -ov -format UDZO dist/tdwii_plus_examples.dmg
# elif [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
# cp -r dist/tdwii_plus_examples dist-package/
# # Create a tarball for Linux
# tar -czvf dist/tdwii_plus_examples-linux.tar.gz -C dist-package .
# fi
# shell: bash
cp ./tdwii_plus_examples/cli/upsscp/config/upsscp_default.ini dist/config/

# Create distribution package with fixed PowerShell commands
- name: Create distribution package (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
Compress-Archive -Path "dist/config" -DestinationPath "dist/config.zip" -Force
Remove-Item -Path "dist/config" -Force
Compress-Archive -Path "dist/" -DestinationPath "./twdii_plus_examples.zip" -Force
Remove-Item -Path "dist/*.exe" -Force
Remove-Item -Path "dist/*.toml" -Force
Remove-Item -Path "dist/config.zip" -Force
Copy-Item -Path "./twdii_plus_examples.zip" -DestinationPath "dist/" -Force
# Create config archive
Compress-Archive -Path "dist\config\*" -DestinationPath "dist\config.zip" -Force

# Remove config directory with proper error handling
if (Test-Path "dist\config") {
Remove-Item -Path "dist\config" -Recurse -Force
}

# Create full archive of distribution files
Compress-Archive -Path "dist\*" -DestinationPath ".\twdii_plus_examples.zip" -Force

# Cleanup dist directory
if (Test-Path "dist\*.exe") {
Remove-Item -Path "dist\*.exe" -Force
}

if (Test-Path "dist\*.toml") {
Remove-Item -Path "dist\*.toml" -Force
}

if (Test-Path "dist\config.zip") {
Remove-Item -Path "dist\config.zip" -Force
}

# Copy the archive back to dist
Copy-Item -Path ".\twdii_plus_examples.zip" -Destination "dist\" -Force

# Upload artifact for workflow run
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: twdii_plus_examples.zip
name: twdii_plus_examples
path: dist/twdii_plus_examples.zip
retention-days: 30

# Generate release notes
- name: Generate Release Notes
id: release_notes
shell: bash
run: |
# Get commit messages since last release
LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "")
if [ -z "$LAST_TAG" ]; then
# If no tags exist, get all commits
CHANGES=$(git log --pretty=format:"* %s (%h)" -10)
else
# Get commits since last tag
CHANGES=$(git log --pretty=format:"* %s (%h)" $LAST_TAG..HEAD)
fi

# Create formatted release notes with date
RELEASE_NOTES="## Changes in this release ($(date +%Y-%m-%d))\n\n$CHANGES"
echo "RELEASE_NOTES<<EOF" >> $GITHUB_OUTPUT
echo -e "$RELEASE_NOTES" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT

# Create GitHub Release
- name: Create Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2
if: github.ref == 'refs/heads/main'
with:
tag_name: v${{ github.run_number }}
name: Release ${{ github.run_number }}
body: ${{ steps.release_notes.outputs.RELEASE_NOTES }}
draft: true
fail_on_unmatched_files: true
files: |
dist/

dist/twdii_plus_examples.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- id: nbstripout

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.0 # Specify the latest Ruff version
rev: v0.11.10 # Specify the latest Ruff version
hooks:
- id: ruff
types: [python]
Expand Down
Loading