fixing github actions #40
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Executables | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
continue-on-error: false | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.12.3' | |
- name: Install dependencies | |
shell: bash | |
run: | | |
if [[ "$RUNNER_OS" == "Linux" ]]; then | |
sudo apt-get update | |
sudo apt-get install -y tk-dev | |
elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
brew update | |
brew install tcl-tk | |
elif [[ "$RUNNER_OS" == "Windows" ]]; then | |
# No need to install tcl-tk for windows in this case | |
echo "Skipping tcl-tk install on Windows" | |
fi | |
python -m pip install --upgrade pip | |
pip install pyinstaller | |
pip install -r requirements.txt | |
- name: Build executable | |
shell: bash | |
run: | | |
if [[ "$RUNNER_OS" == "Linux" ]]; then | |
echo "Adding Tcl/Tk to LD_LIBRARY_PATH" | |
echo "LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
fi | |
pyinstaller --onefile --collect-all PIL backgroundremoval.py | |
- name: Rename executables | |
shell: bash | |
run: | | |
if [[ "$RUNNER_OS" == "Linux" ]]; then | |
mv dist/backgroundremoval dist/backgroundremoval-linux | |
elif [[ "$RUNNER_OS" == "Windows" ]]; then | |
mv dist/backgroundremoval.exe dist/backgroundremoval-windows.exe | |
elif [[ "$RUNNER_OS" == "macOS" ]]; then | |
mv dist/backgroundremoval dist/backgroundremoval-UNTESTED-macos | |
fi | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ matrix.os }}-executable | |
path: dist/* | |
create-release: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v4 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
draft: false | |
prerelease: false | |
- name: Zip Ubuntu artifact | |
run: | | |
zip -r ubuntu-latest-executable.zip ./ubuntu-latest-executable* | |
- name: Upload Ubuntu zip to release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./ubuntu-latest-executable.zip | |
asset_name: ubuntu-latest-executable.zip | |
asset_content_type: application/zip | |
- name: Zip Mac artifact | |
run: | | |
zip -r macos-latest-executable.zip ./macos-latest-executable* | |
- name: Upload Mac zip to release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./macos-latest-executable.zip | |
asset_name: macos-latest-executable.zip | |
asset_content_type: application/zip | |
- name: Zip Windows artifact | |
run: | | |
zip -r windows-latest-executable.zip ./windows-latest-executable* | |
- name: Upload windows zip to release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./windows-latest-executable.zip | |
asset_name: windows-latest-executable.zip | |
asset_content_type: application/zip | |
- name: List files # Debug step to see what was downloaded | |
run: find . |