Skip to content

fix .github/workflows/build-macos.yml #35

fix .github/workflows/build-macos.yml

fix .github/workflows/build-macos.yml #35

Workflow file for this run

name: Build for MacOS x86_64 / arm64
# ALSO SEE: pyicu: https://github.com/googlefonts/pyfontaine/issues/109
on:
push:
branches:
- 'build-release'
workflow_dispatch:
env:
UV_SYSTEM_PYTHON: 0
PYTHONWARNINGS: ignore::EncodingWarning
PYTHONWARNDEFAULTENCODING: 0
APPNAME: PyGlossaryTk
DIST_DIR: dist.nuitka.tk
HOMEBREW_NO_INSTALL_CLEANUP: true
HOMEBREW_NO_ENV_HINTS: true
HOMEBREW_CLEANUP_MAX_AGE_DAYS: 999
HOMEBREW_NO_ANALYTICS: true
HOMEBREW_NO_AUTO_UPDATE: true
MAIN_SCRIPT: main.py
RESOURCE_DIR: "resources"
jobs:
build_macos:
runs-on: ${{ matrix.os }}
strategy:
# DOC: https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow
matrix:
python-version: ['3.13']
os: ['macos-14']
fail-fast: true
steps:
- uses: actions/checkout@v4
with:
submodules: true
fetch-depth: 0
fetch-tags: true
# TODO: !!! comment out before merging to master
ref: build-release
- name: Update brew
run: brew update
- name: Install brew dependencies
run: |
brew install libffi gettext cmake pkg-config icu4c lzo
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
# https://docs.astral.sh/uv/guides/integration/github/#caching
uses: astral-sh/setup-uv@v6
with:
version: "latest"
- name: Cache uv
uses: actions/cache@v4
env:
BASE_KEY: ${{ runner.os }}-uv-${{ matrix.python-version }}-
UV_HASH: ${{ hashFiles('pyproject.toml', 'uv.lock') }}
with:
path: ~/.cache/uv
key: ${{ env.BASE_KEY }}${{ env.UV_HASH }}
restore-keys: ${{ env.BASE_KEY }}
- name: Create venv
run: |
uv venv .venv --python ${{ matrix.python-version }}
echo "VIRTUAL_ENV=$PWD/.venv" >> $GITHUB_ENV
echo "$PWD/.venv/bin" >> $GITHUB_PATH
- name: Activate venv
run: |
source .venv/bin/activate
- name: set vars
id: envconf
run: |
echo "BREW_PREFIX=$(brew --prefix)" >> $GITHUB_ENV
echo "VERSION=$(git describe --abbrev=0)" >> $GITHUB_ENV
echo "VERSION_WITH_HASH=$(git describe)" >> $GITHUB_ENV
echo "PREFIX_ICU4C=$(brew --prefix icu4c)" >> $GITHUB_ENV
echo "PREFIX_LZO=$(brew --prefix lzo)" >> $GITHUB_ENV
echo "PREFIX_LIBFFI=$(brew --prefix libffi)" >> $GITHUB_ENV
- name: Set pip build vars
id: envpip
run: bash .github/scripts/mac/prepare-env-vars.sh
- name: Print env vars
run: |
echo "BREW_PREFIX: $BREW_PREFIX"
echo "PREFIX_ICU4C: $PREFIX_ICU4C"
echo "PREFIX_LZO: $PREFIX_LZO"
echo "PREFIX_LIBFFI: $PREFIX_LIBFFI"
echo "LDFLAGS: $LDFLAGS"
echo "CPPFLAGS: $CPPFLAGS"
echo "PKG_CONFIG_PATH: $PKG_CONFIG_PATH"
echo "DYLD_LIBRARY_PATH: $DYLD_LIBRARY_PATH"
- name: Install pyglossary dependencies
run: bash scripts/ci/mac/prepare-deps.sh
- name: Patch sources for nuitka build
run: python3 scripts/ci/mac/patch_sources.py
- name: Set PYTHONPATH
run: echo "PYTHONPATH=$PREFIX_ICU4C/lib:$PREFIX_LZO/lib:$PREFIX_LZO/lib:$PREFIX_LIBFFI/lib:$PYTHONPATH" >> $GITHUB_ENV
- name: nuitka Build
env:
PYTHONWARNDEFAULTENCODING: 0
run: bash scripts/ci/mac/nuitka-build.sh
- name: Copy assets
run: python3 scripts/ci/mac/copy_assets.py
# - name: Upload Artifacts zip
# uses: actions/upload-artifact@v4
# with:
# # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context
# overwrite: true
# name: ${{ github.event.repository.name }}-${{ matrix.os }}-py${{ matrix.python-version }}-${{ env.VERSION_WITH_HASH }}
# path: |
# ${{ env.DIST_DIR }}/${{ env.APPNAME }}.app
- name: Create DMG
run: bash scripts/ci/mac/make-dmg.sh ${{ matrix.os }}
- name: Upload Artifacts DMG
if: true
uses: actions/upload-artifact@v4
with:
overwrite: true
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#github-context
name: ${{ github.event.repository.name }}-${{ matrix.os }}-py${{ matrix.python-version }}-${{ github.sha }}-${{ env.VERSION_WITH_HASH }}-DMG
path: |
**/*.dmg
release:
if: true
needs: [build_macos]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
# ref: build-release # comment out before merge
- name: Set release vars
run: |
echo "VERSION=$(git describe --abbrev=0)" >> $GITHUB_ENV
echo "VERSION_WITH_HASH=$(git describe)" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: ./artifacts
merge-multiple: true
- name: Show generated artifacts
run: |
pwd
echo ${{ github.workspace }}/artifacts
find ${{ github.workspace }}/artifacts
- name: make release
uses: ncipollo/release-action@v1
# https://github.com/ncipollo/release-action
with:
name: ${{ env.VERSION }}
body: |
### ${{ github.event.repository.name }}-${{ env.VERSION_WITH_HASH }}
## macOS
- __IMPORTANT__: macOS Intel-x64 & ARM64 DMG
<blockquote>
<details>
<summary> :bulb: How to fix macOS security warning — "APP IS DAMAGED AND CAN'T BE OPENED" :question:</summary>
![macos file quarantene](https://f002.backblazeb2.com/file/imatgas/macos-remove-quarantine1.png)
### ⚠️ If macOS displays a warning that _the app is damaged and cannot be opened_ then move the unpacked bundle to `/Applications`, and run from the terminal.app:
```bash
/usr/bin/xattr -d com.apple.quarantine /Applications/PyGlossary.app
```
Now you should be able to open the app by **right-clicking** on **/Applications/PyGlossary.app** in Finder, selecting **Open** and confirming running an app unsigned by Apple (only needs to be done once).
</details>
</blockquote>
artifacts: "artifacts/*.dmg"
artifactContentType: application/zip
generateReleaseNotes: true
makeLatest: true
allowUpdates: true
omitBodyDuringUpdate: true # preserve the existing body during updates:
tag: ${{ env.VERSION }}