Promote code for 2.0.17 (#341) #98
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
name: Package-and-Upload | |
# Pyinstaller requires that executables for each OS are built on that OS | |
# This action is intended to build on each of the supported OS's: mac (x86 and arm), windows, linux. | |
# and then upload all four files to a new release | |
# reference material: | |
# https://data-dive.com/multi-os-deployment-in-cloud-using-pyinstaller-and-github-actions | |
# https://anshumanfauzdar.medium.com/using-github-actions-to-bundle-python-application-into-a-single-package-and-automatic-release-834bd42e0670 | |
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: | |
jobs: | |
buildexe: | |
name: Build executables and upload them to the existing release | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: windows-latest | |
TARGET: windows | |
CMD_BUILD: > | |
pyinstaller tabcmd-windows.spec --clean --noconfirm --distpath ./dist/windows | |
UPLOAD_FILE_NAME: tabcmd.exe | |
OUT_FILE_NAME: tabcmd.exe | |
ASSET_MIME: application/vnd.microsoft.portable-executable | |
- os: macos-13 | |
TARGET: macos | |
CMD_BUILD: > | |
pyinstaller tabcmd-mac.spec --clean --noconfirm --distpath ./dist/macos/ | |
# the extension .app is not allowed as an upload by github | |
UPLOAD_FILE_NAME: tabcmd-x86.app.tar | |
# these two names must match the output defined in tabcmd-mac.spec | |
OUT_FILE_NAME: tabcmd.app | |
APP_BINARY_FILE_NAME: tabcmd | |
ASSET_MIME: application/zip | |
- os: macos-latest | |
# This must match the value set in tabcmd-mac.spec for the output folder | |
TARGET: macos | |
CMD_BUILD: > | |
pyinstaller tabcmd-mac.spec --clean --noconfirm --distpath ./dist/macos/ | |
UPLOAD_FILE_NAME: tabcmd_arm64.app.tar | |
OUT_FILE_NAME: tabcmd.app | |
APP_BINARY_FILE_NAME: tabcmd | |
ASSET_MIME: application/zip | |
- os: ubuntu-latest | |
TARGET: ubuntu | |
# https://stackoverflow.com/questions/31259856 | |
# /how-to-create-an-executable-file-for-linux-machine-using-pyinstaller | |
CMD_BUILD: > | |
pyinstaller --clean -y --distpath ./dist/ubuntu tabcmd-linux.spec && | |
chown -R --reference=. ./dist/ubuntu | |
OUT_FILE_NAME: tabcmd | |
UPLOAD_FILE_NAME: tabcmd | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: 3.9 | |
- name: Install dependencies and build | |
run: | | |
python --version | |
python -m pip install --upgrade pip | |
python -m pip install --upgrade build | |
pip install . | |
pip install .[package] | |
doit version | |
python -m build | |
- name: Package with pyinstaller for ${{matrix.TARGET}} | |
run: ${{matrix.CMD_BUILD}} | |
- name: Validate package for ${{matrix.TARGET}} | |
if: matrix.TARGET != 'macos' | |
run: ./dist/${{ matrix.TARGET }}/${{matrix.OUT_FILE_NAME}} | |
- name: Validate package for Mac | |
if: matrix.TARGET == 'macos' | |
run: ./dist/${{ matrix.TARGET }}/${{ matrix.OUT_FILE_NAME }}/Contents/MacOS/${{ matrix.APP_BINARY_FILE_NAME }} | |
- name: Tar app bundle for Mac | |
if: matrix.TARGET == 'macos' | |
run: | | |
rm -f dist/${{ matrix.TARGET }}/${{ matrix.APP_BINARY_FILE_NAME }} | |
cd dist/${{ matrix.TARGET }} | |
tar -cvf ${{ matrix.UPLOAD_FILE_NAME }} ${{ matrix.OUT_FILE_NAME }} | |
- name: Upload binaries to release for ${{ matrix.TARGET }} | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
asset_name: ${{ matrix.UPLOAD_FILE_NAME }} | |
file: ./dist/${{ matrix.TARGET }}/${{ matrix.UPLOAD_FILE_NAME }} | |
tag: ${{ github.ref_name }} | |
overwrite: true | |
promote: true | |