Build Executables #5
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: Build Executables | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build: | |
name: Build on ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: windows-latest | |
platform: windows | |
arch: amd64 | |
- os: macos-13 | |
platform: macos | |
arch: amd64 | |
- os: macos-14 | |
platform: macos | |
arch: arm64 | |
- os: ubuntu-latest | |
platform: linux | |
arch: amd64 | |
- os: ubuntu-latest | |
platform: linux | |
arch: arm64 | |
qemu: true | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up QEMU | |
if: matrix.qemu | |
uses: docker/setup-qemu-action@v3 | |
with: | |
platforms: arm64 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install PDM | |
run: | | |
python -m pip install --upgrade pip | |
pip install pdm | |
- name: Install dependencies | |
run: pdm install | |
- name: Install Nuitka | |
run: pdm add nuitka | |
- name: Build with Nuitka (Windows) | |
if: matrix.platform == 'windows' | |
run: | | |
pdm run nuitka ` | |
--standalone ` | |
--onefile ` | |
--nofollow-imports ` | |
--include-module=typer ` | |
--include-module=requests ` | |
--include-module=git ` | |
--include-module=prompt_toolkit ` | |
--include-module=rich ` | |
--include-package=gptcomet ` | |
--disable-console ` | |
--output-dir=dist ` | |
--output-filename=gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/} ` | |
--noinclude-setuptools-mode=allow ` | |
--noinclude-pytest-mode=allow ` | |
--no-pyi-file ` | |
--no-debug ` | |
--lto=yes ` | |
gptcomet/__main__.py | |
- name: Test built executable (Windows) | |
if: matrix.platform == 'windows' | |
run: | | |
./dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/}.exe --version | |
- name: Build with Nuitka (Unix) | |
if: matrix.platform != 'windows' | |
run: | | |
pdm run nuitka \ | |
--standalone \ | |
--onefile \ | |
--nofollow-imports \ | |
--include-module=typer \ | |
--include-module=requests \ | |
--include-module=git \ | |
--include-module=prompt_toolkit \ | |
--include-module=rich \ | |
--include-package=gptcomet \ | |
--disable-console \ | |
--output-dir=dist \ | |
--output-filename=gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/} \ | |
--noinclude-setuptools-mode=allow \ | |
--noinclude-pytest-mode=allow \ | |
--no-pyi-file \ | |
--no-debug \ | |
--lto=yes \ | |
gptcomet/__main__.py | |
- name: Test built executable (Unix) | |
if: matrix.platform != 'windows' | |
run: | | |
chmod +x ./dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/} | |
./dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/} --version | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/} | |
path: dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${GITHUB_REF#refs/tags/}* | |
release: | |
needs: build | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
# download all artifacts | |
- name: Download all artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: dist | |
merge-multiple: true | |
# list contents | |
- name: List contents of dist | |
run: ls -al dist/ | |
# get version | |
- name: Get version | |
id: get_version | |
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
# checkout code for git-cliff | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# install git-cliff | |
- name: Install git-cliff | |
uses: kenji-miyake/setup-git-cliff@v1 | |
# generate release notes | |
- name: Generate Release Notes | |
run: | | |
# Generate changelog for the current tag | |
git cliff --current > release_notes.md | |
# Append artifacts information | |
echo "" >> release_notes.md | |
echo "## Artifacts" >> release_notes.md | |
echo "* Windows (x64)" >> release_notes.md | |
echo "* macOS (x64, arm64)" >> release_notes.md | |
echo "* Linux (x64, arm64)" >> release_notes.md | |
# create GitHub Release | |
- name: Create Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: dist/gptcomet-* | |
body_path: release_notes.md | |
draft: false # no draft | |
prerelease: false # no prerelease | |
generate_release_notes: true # generate release notes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# notification | |
- name: Notification | |
if: success() | |
run: | | |
echo "Release ${{ steps.get_version.outputs.VERSION }} has been published successfully!" |