Skip to content

Add pyinstaller builds to GitHub releases #53

Add pyinstaller builds to GitHub releases

Add pyinstaller builds to GitHub releases #53

Workflow file for this run

# Builds the package, and, if the commit has a tag assigned to it, create a release for it and publish it to PyPI
name: Build CI/CD
on:
push:
pull_request:
jobs:
# Builds the package and uploads a build artifiact
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: distribution-archives
path: dist/*
# Builds binaries with pyinstaller
pyinstaller:
strategy:
matrix:
os: ['ubuntu', 'windows', 'macos']
runs-on: ${{ matrix.os }}-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/[email protected]
with:
python-version: '3.12'
- name: Install dependencies
run: pip install .[packaging]
- name: Build executable
run: pyinstaller --noconfirm pyinstaller.spec
- name: Create DMG
if: runner.os == 'macOS'
run: |
brew update
brew install create-dmg
mkdir -p dist/dmg
mv dist/*.app dist/dmg
create-dmg \
--volname "E-mail Draft Generator" \
--volicon "assets/icon.png" \
--window-pos 200 120 \
--window-size 600 300 \
--icon-size 100 \
--icon "E-mail Draft Generator.app" 175 120 \
--hide-extension "E-mail Draft Generator.app" \
--app-drop-link 425 120 \
"dist/E-mail Draft Generator.dmg" \
"dist/dmg/"
rm -r "dist/E-mail Draft Generator" "dist/dmg"
- name: Upload a Build Artifact
uses: actions/[email protected]
with:
name: package-${{ matrix.os }}
path: dist/*
# Creates a release if the commit has a tag associated with it
release:
needs: [build, pyinstaller]
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download build
uses: actions/[email protected]
with:
path: dist
- name: Create release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: dist/*
# Publish to PyPI if the commit has a tag associated with it
publish:
needs: build
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download build
uses: actions/[email protected]
with:
name: distribution-archives
path: dist
- name: Publish package
uses: pypa/gh-action-pypi-publish@81e9d935c883d0b210363ab89cf05f3894778450