Skip to content

Add macOS support for building and packaging artifacts in GitHub Actions #20

Add macOS support for building and packaging artifacts in GitHub Actions

Add macOS support for building and packaging artifacts in GitHub Actions #20

Workflow file for this run

on:
push:
tags:
# GitHub Actions does not support full regular expressions for tag matching.
# Please set tag rules in the repository settings:
# Settings -> Tags -> Go to rulesets to create a new tag rule
# The pattern must be: ([0-9]+(\.[0-9]+){1,3})(-(stable|alpha|beta|nightly|dev))?$
- "*"
workflow_dispatch:
permissions:
contents: write
jobs:
check-version:
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- run: |
TAG="${GITHUB_REF#refs/tags/}"
echo "Tag: $TAG"
if [[ ! "$TAG" =~ ^([0-9]+(\.[0-9]+){1,3})(-(stable|alpha|beta|nightly|dev))?$ ]]; then
echo "❌ Tag does not match version pattern!"
exit 1
fi
echo "✅ Tag format OK"
test:
uses: ./.github/workflows/test.yml
build:
strategy:
matrix:
include:
- os: ubuntu-latest
arch: x64
name: linux
- os: windows-latest
arch: x64
name: windows
- os: macos-latest
arch: arm64
name: macos
runs-on: ${{ matrix.os }}
needs:
- check-version
- test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: yezz123/setup-uv@v4
- name: Before script (Linux)
if: runner.os == 'Linux'
run: |
sudo apt-get update
sudo apt-get install -y patchelf
- name: Setup, install dependencies, build
if: runner.os != 'macOS'
run: |
uv sync
uv run pyside-cli build --onedir
- name: Setup, install dependencies, build (macOS)
if: runner.os == 'macOS'
run: |
uv sync
uv run pyside-cli build
- name: Package artifact (macOS)
if: runner.os == 'macOS'
run: |
brew install create-dmg
xattr -cr build/*.app
create-dmg --volname App --window-pos 200 120 --window-size 600 400 --icon-size 100 --app-drop-link 450 185 ../App.dmg *.app
- name: Package artifact (Linux)
if: runner.os == 'Linux'
run: |
mv ./build/App ./Package
zip -r App-${{ matrix.name }}-${{ matrix.arch }}.zip Package/
- name: Package artifact (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
Move-Item -Path ./build/App -Destination ./Package
Compress-Archive -Path .\Package\ -DestinationPath App-${{ matrix.name }}-${{ matrix.arch }}.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: App-${{ matrix.name }}-${{ matrix.arch }}
path: |
./App-*
*.dmg
build_whl:
runs-on: ubuntu-latest
needs:
- check-version
- test
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: yezz123/setup-uv@v4
- name: Setup, install dependencies, build
run: |
uv sync
uv run pyside-cli build --stage rc
uv build --no-sources
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: Python wheel package
path: ./dist/*.whl
release:
runs-on: ubuntu-latest
needs:
- build
- build_whl
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v5
with:
path: ./release
- uses: softprops/action-gh-release@v2
if: github.ref_type == 'tag'
with:
files: ./release/**
name: Release ${{ github.ref_name }}
body_path: CHANGE.md
prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') || contains(github.ref_name, '-dev') || contains(github.ref_name, '-nightly') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}