Skip to content

Build executables and publish 🐍 package 📦 to PyPI #62

Build executables and publish 🐍 package 📦 to PyPI

Build executables and publish 🐍 package 📦 to PyPI #62

Workflow file for this run

name: Build executables and publish 🐍 package 📦 to PyPI
on:
workflow_dispatch:
release:
types:
- "published"
jobs:
build:
strategy:
fail-fast: false
matrix:
os:
- "windows-latest"
#- "macos-latest"
#- "ubuntu-latest"
python:
- "3.10.x"
cx-freeze:
- "v7.1.0-post0"
name: "Build exe for ${{ matrix.os }}"
runs-on: "${{ matrix.os }}"
steps:
# === SETUP ===
- name: "Setup python"
uses: "actions/setup-python@v5"
with:
python-version: "${{ matrix.python }}"
- name: "Install cx_Freeze bootloader"
run: |
python -m pip install cx_Freeze==${{ matrix.cx-freeze }}
# === BUILD ===
- name: "Clone repo"
uses: "actions/checkout@v4"
with:
path: "./src/"
- name: "Install requirements" # N.B.: First install a pinned SciPy version that is known to package correctly with cx_Freeze
run: |
cd ./src/
python -m pip install -U scipy==1.11.3
python -m pip install -U -r ./requirements.txt
- name: "Build"
if: runner.os != 'macOS'
run: |
cd ./src/
python ./buildGUI.py build
mv ./build/*/ ./dist/
- name: "Build macOS"
if: runner.os == 'macOS'
run: |
cd ./src/
python ./buildGUI.py bdist_mac
mkdir ./dist/
mv ./build/*.app/ ./dist/
- name: "Resolve symlinks"
if: runner.os != 'Windows'
run: |
cd ./src/dist/
find ./ -type l -exec echo Resolving {} \; -exec sed -i '' {} \;
# export Apple development certificate from Xcode: https://help.apple.com/xcode/mac/current/#/dev154b28f09
# base64 CERTIFICATE.p12 | pbcopy -> secrets.CODESIGN_P12_BASE64
- name: "Import macOS codesign certificate"
if: runner.os == 'macOS'
uses: "apple-actions/import-codesign-certs@v3"
with:
p12-file-base64: "${{ secrets.CODESIGN_P12_BASE64 }}"
p12-password: "${{ secrets.CODESIGN_P12_PASSWORD }}"
# security find-identity, returns something like:
# A30C8432FADE0B3E7D5BA54034EF2ECA39A0BDD0 "Apple Development: [email protected] (6LR9J7UR6F)"
# the first hex string is your identity -> secrets.CODESIGN_P12_NAME
- name: "Codesign macOS"
if: runner.os == 'macOS'
run: |
cd ./src/dist/
find ./ -type f -empty -delete
codesign -s "${{ secrets.CODESIGN_P12_NAME }}" --deep -f ./*.app
# === ARTIFACT ===
- name: "Zip artifact"
run: |
7z a -r ./${{ github.event.repository.name }}-${{ runner.os }}.zip ./src/dist/*
- name: "Upload artifact to workflow run"
uses: actions/upload-artifact@v4
with:
name: executable
path: "./${{ github.event.repository.name }}-${{ runner.os }}.zip"
- name: "Upload artifact to release"
uses: "softprops/action-gh-release@v2"
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
files: "./${{ github.event.repository.name }}-${{ runner.os }}.zip"
wheel:
name: Package 📦 wheel and upload to PyPI
runs-on: ubuntu-latest
steps:
- name: Clone repo
uses: actions/checkout@v4
- name: Setup python
uses: actions/setup-python@v5
with:
python-version: "3.10.x"
- name: Install pypa/build
run: >-
python -m
pip install
build
--user
- name: Build a wheel and a source tarball
run: >-
python -m
build
--sdist
--wheel
--outdir dist/
- name: "Upload wheel as workflow artifact"
uses: actions/upload-artifact@v4
with:
name: wheel
path: ./dist/*.whl
- name: Upload wheel as release artifact
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
files: "./dist/*.whl"
- name: Publish distribution 📦 to PyPI
if: github.event_name == 'release' && github.event.action == 'published'
uses: pypa/[email protected]
with:
password: ${{ secrets.PYPI_API_TOKEN }}