build_pyinstaller #51
Workflow file for this run
This file contains 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
# Workflow for building pyinstaller packages for windows and MacOS and creating a (pre-)release | |
# see https://data-dive.com/multi-os-deployment-in-cloud-using-pyinstaller-and-github-actions | |
# | |
# The workflow runs: | |
# - when manually triggered | |
# - for push events on the main branch, creating a "latest" pre-release, triggered by 'build_flatpak' | |
# - for tagged release events, creating a versioned release, triggered by 'build_flatpak' | |
# | |
# The latter requires a workflow like: | |
# | |
# * <update version.py> # PyPI version number is created from this | |
# * git tag v0.4.5 # create new local tag | |
# * git push # push to origin (without tag) | |
# * git push origin --tags # push tag to origin | |
# * <draft a release on Github from tag, select prerelease or release> | |
# | |
# Tags can be deleted with: | |
# | |
# git tag -d <tag_name> | |
# git push --delete origin <tag_name> | |
# | |
# When the 'build_flatpak' workflow has finished, this workflow is triggered as well. | |
--- | |
name: build_pyinstaller | |
on: | |
push: | |
branches: main | |
release: | |
workflow_dispatch: | |
# workflow_run: | |
# workflows: ['build_flatpak'] | |
# types: | |
# - completed | |
jobs: | |
build: | |
name: Build packages | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
# --- | |
- os: windows-latest | |
# --- | |
TARGET: windows | |
CMD_BUILD: > | |
pyinstaller pyfdax.spec && | |
mv dist/pyfdax.exe dist/pyfdax_win.exe | |
OUT_FILE_NAME: pyfdax_win.exe | |
ASSET_MIME: application/vnd.microsoft.portable-executable | |
# --- | |
- os: macos-latest | |
# --- | |
TARGET: macos | |
CMD_BUILD: > | |
pyinstaller pyfdax.spec && | |
mv dist/pyfdax dist/pyfdax_osx | |
OUT_FILE_NAME: pyfdax_osx # .app # pyfda.zip | |
ASSET_MIME: application/zip | |
steps: | |
- name: Infos about github trigger event and ref | |
run: | | |
echo github.event_name: ${{ github.event_name }} | |
echo github.ref: ${{ github.ref }} | |
echo github.ref_type: ${{ github.ref_type }} | |
echo github.ref_name: ${{ github.ref_name }} | |
# Example result for tagged release: | |
# github.event_name: release | |
# github.ref: refs/tags/v0.8.0a3 | |
# github.ref_type: tag | |
# github.ref_name: v0.8.0a3 | |
- uses: actions/checkout@v3 | |
with: | |
ref: main # enforce using main branch | |
- name: Set up Python 3.10 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
pip install pyinstaller pyinstaller-hooks-contrib | |
- name: Build with pyinstaller for ${{matrix.TARGET}} | |
run: ${{matrix.CMD_BUILD}} | |
- name: Upload builds as artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.OUT_FILE_NAME}} | |
path: ./dist/${{ matrix.OUT_FILE_NAME}} | |
release: | |
name: Release packages | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download all artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: ./ | |
# not specifying the file names downloads all artifacts. However, | |
# an individual directory is created for each file identical to its name | |
- name: Display structure of downloaded files | |
run: ls -R | |
- name: Update Github prerelease latest | |
if: success() && github.ref_type != 'tag' | |
uses: pyTooling/Actions/releaser@main | |
with: | |
tag: latest | |
rm: true | |
token: ${{ secrets.GITHUB_TOKEN }} | |
files: | | |
pyfdax_win.exe/pyfdax_win.exe | |
pyfdax_osx/pyfdax_osx | |
- name: Update versioned release | |
if: success() && github.ref_type == 'tag' | |
uses: pyTooling/Actions/releaser@main | |
with: | |
tag: ${{ github.ref_name }} | |
rm: false | |
token: ${{ secrets.GITHUB_TOKEN }} | |
files: | | |
pyfdax_win.exe/pyfdax_win.exe | |
pyfdax_osx/pyfdax_osx | |