Skip to content

ci: simplify windows build workflow #11

ci: simplify windows build workflow

ci: simplify windows build workflow #11

Workflow file for this run

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:
- name: Checkout code
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
# Windows Build
- name: Build with Nuitka (Windows)
if: matrix.platform == 'windows'
shell: pwsh
run: |
echo "Starting Nuitka build for Windows..."
echo "Current directory: $(Get-Location)"
$outputName = "gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}"
echo "Output name will be: $outputName"
Remove-Item -Path dist -Recurse -Force -ErrorAction SilentlyContinue
New-Item -ItemType Directory -Force -Path dist
pdm run python -m nuitka `
--standalone `
--onefile `
--nofollow-imports `
--include-module=typer `
--include-module=requests `
--include-module=git `
--include-module=prompt_toolkit `
--include-module=rich `
--include-package=gptcomet `
--output-dir="dist" `
--output-filename="$outputName" `
--noinclude-setuptools-mode=allow `
--noinclude-pytest-mode=allow `
--no-pyi-file `
--no-debug `
--lto=yes `
--remove-output `
gptcomet/__main__.py
echo "Nuitka build completed"
echo "Checking dist directory contents:"
Get-ChildItem dist -Recurse | Format-Table FullName, Length, LastWriteTime
# Windows Test
- name: Test built executable (Windows)
if: matrix.platform == 'windows'
shell: pwsh
run: |
echo "Testing Windows executable..."
$exeName = "gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}.exe"
$exePath = Join-Path (Get-Location) "dist" $exeName
if (Test-Path $exePath) {
echo "Found executable at: $exePath"
echo "Attempting to run executable..."
& $exePath --version
} else {
echo "ERROR: Executable not found at path: $exePath"
echo "Directory contents:"
Get-ChildItem "dist" -Recurse | Format-Table FullName, Length, LastWriteTime
}
# Unix Build
- name: Build with Nuitka (Unix)
if: matrix.platform != 'windows'
run: |
echo "Starting Nuitka build for Unix..."
echo "Current directory: $(pwd)"
rm -rf dist
mkdir -p dist
pdm run python -m nuitka \
--standalone \
--onefile \
--nofollow-imports \
--include-module=typer \
--include-module=requests \
--include-module=git \
--include-module=prompt_toolkit \
--include-module=rich \
--include-package=gptcomet \
--output-dir="dist" \
--output-filename="gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}" \
--noinclude-setuptools-mode=allow \
--noinclude-pytest-mode=allow \
--no-pyi-file \
--no-debug \
--lto=yes \
--remove-output \
gptcomet/__main__.py
echo "Nuitka build completed"
echo "Checking dist directory contents:"
ls -la dist/
# Unix Test
- name: Test built executable (Unix)
if: matrix.platform != 'windows'
run: |
echo "Testing Unix executable..."
EXECUTABLE="./dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}"
if [ -f "$EXECUTABLE" ]; then
echo "Found executable at: $EXECUTABLE"
chmod +x "$EXECUTABLE"
echo "Attempting to run executable..."
"$EXECUTABLE" --version
else
echo "ERROR: Executable not found at: $EXECUTABLE"
echo "Directory contents:"
ls -la dist/
exit 1
fi
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}
path: dist/gptcomet-${{ matrix.platform }}-${{ matrix.arch }}-${{ github.ref_name }}*
release:
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: List contents of dist
run: |
echo "Listing contents of dist directory:"
ls -la dist/
- name: Get version
id: get_version
run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install git-cliff
uses: kenji-miyake/setup-git-cliff@v1
- 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
echo "Generated release notes:"
cat release_notes.md
- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: dist/gptcomet-*
body_path: release_notes.md
draft: false
prerelease: false
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notification
if: success()
run: |
echo "Release ${{ steps.get_version.outputs.VERSION }} has been published successfully!"
echo "Artifacts can be found in the GitHub release page."