Skip to content

chore(GHA): workaround DMG building error on macos-13 (intel) #45

chore(GHA): workaround DMG building error on macos-13 (intel)

chore(GHA): workaround DMG building error on macos-13 (intel) #45

Workflow file for this run

name: Build
# Controls when the action will run.
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
version:
runs-on: 'ubuntu-latest'
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checking out the repo
uses: actions/checkout@v4
- name: Figure out version string
id: version
shell: sh
run: |
# get the latest commit hash in the short form
COMMIT=$(git rev-parse --short HEAD)
# get the latest commit date in the form of YYYYmmdd
DATE=$(git log -1 --format=%cd --date=format:'%y%m%d%H%M')
echo "version=${DATE}-${COMMIT}" >> "$GITHUB_OUTPUT"
build:
needs: [version]
# convert this to a matrix if builds differ between platforms
runs-on: ${{ matrix.os }}
strategy:
matrix:
# preferring older OS versions for better backward compat,
# the build platform may be the oldest platform it works on
os: [ 'ubuntu-22.04', 'ubuntu-22.04-arm', 'windows-2022', 'macos-14', 'macos-13' ]
# [ 'ubuntu-22.04', 'windows-latest', 'macos-latest']
outputs:
version: ${{ needs.version.outputs.version }}
steps:
- name: Checking out the repo
uses: actions/checkout@v4
# see *py_ver* in ci/update.py
- name: Setting up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
cache-dependency-path: |
requirements.txt
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install --progress-bar=off -r requirements.txt
python -m pip install pyinstaller
- name: Get OS and machine architecture
id: os
shell: python
run: |
import os, platform
machine = platform.machine().replace("x86_", "intel").replace("AMD", "intel")
with open(os.environ["GITHUB_OUTPUT"], "a") as fd:
fd.write(f"res={platform.system()}-{machine}\n")
- name: Build
env:
VERSION: ${{ needs.version.outputs.version }}
shell: sh
run: |
OS=${{ steps.os.outputs.res }}
which sed
sed -E -i -e "s/(name=['\"])([^'\"\.]+)((\.[^'\"]+)?['\"],)/\1\2-$VERSION-${OS}\3/" LiveFT.spec
cat LiveFT.spec # show result of sed replacement
pyinstaller LiveFT.spec
- name: Create DMG
if: startsWith(matrix.os, 'macos')
shell: sh
run: |
if [ ${{ matrix.os }} == "macos-13" ]; then
# workaround 'hdiutil: create failed - Resource busy'
# https://github.com/actions/runner-images/issues/7522#issuecomment-1556766641
sudo pkill -9 XProtect >/dev/null || true;
while pgrep XProtect; do sleep 3; done;
fi
cd dist
fn="$(ls -d LiveFT*.app)"; fn="${fn%.*}"
hdiutil create -fs HFS+ -srcfolder "$fn.app" -volname "$fn" "$fn.dmg"
rm -Rf "$fn.app" "$fn"
- name: Check what was created
shell: sh
run: ls -la dist
- name: Store built packages for publishing later
uses: actions/upload-artifact@v4
with:
name: package-${{ matrix.os }}
path: dist/*
overwrite: true
if-no-files-found: 'error'
publish:
needs: [build]
runs-on: 'ubuntu-latest'
steps:
- name: Download previuously built package artifacts
uses: actions/download-artifact@v4
with:
pattern: package-*
merge-multiple: true
path: dist
- name: Check contents
run: |
pwd
ls -la dist
[ "$(find dist -type f | wc -l)" -gt 0 ] # fails if no files where created
- name: Release
if: false
uses: softprops/action-gh-release@v2
with:
make_latest: true
draft: false
prerelease: false
tag_name: ${{ needs.build.outputs.version }}
files: dist/*