build(github): update to latest macos runners images #9
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 | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
jobs: | |
build: | |
name: ${{ matrix.job.target }} (${{ matrix.job.os }}) | |
runs-on: ${{ matrix.job.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
job: | |
- { target: aarch64-apple-darwin , os: macos-latest } | |
- { target: x86_64-apple-darwin , os: macos-13 } | |
- { target: x86_64-pc-windows , os: windows-latest } | |
- { target: x86_64-unknown-linux-gnu , os: ubuntu-latest } | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@v3 | |
- name: Extract pyproject infos | |
shell: bash | |
run: | | |
echo "PROJECT_NAME=$(sed -n 's/^name = "\(.*\)"/\1/p' pyproject.toml| head -n 1)" >> $GITHUB_ENV | |
echo "PROJECT_VERSION=$(sed -n 's/^version = "\(.*\)"/\1/p' pyproject.toml| head -n 1)" >> $GITHUB_ENV | |
- name: Generate project data | |
shell: bash | |
run: | | |
EXE_suffix="" | |
case ${{ matrix.job.target }} in | |
*-windows-*) EXE_suffix=".exe" ;; | |
esac | |
BIN_NAME="alwaysdata${EXE_suffix}" | |
COMPILER_OPTS="--disable-ccache" | |
case ${{ matrix.job.target }} in | |
*-linux-* | *-apple-*) COMPILER_OPTS="${COMPILER_OPTS} --clang --lto=yes" ;; | |
*-apple-*) COMPILER_OPTS="${COMPILER_OPTS} --clang" ;; | |
x86_64-*-windows-*) COMPILER_OPTS="${COMPILER_OPTS} --mingw64" ;; | |
esac | |
PLUGINS_OPTS="" | |
case ${{ matrix.job.target }} in | |
x86_64-*-windows-* | x86_64-apple-*) PLUGINS_OPTS="${PLUGINS_OPTS} --enable-plugin=upx" ;; | |
esac | |
PLATFORM="x64" | |
case ${{ matrix.job.target }} in | |
i686-*) PLATFORM="x86" ;; | |
esac | |
BASENAME=${PROJECT_NAME}-v${PROJECT_VERSION}-${{ matrix.job.target }} | |
mkdir -p ${BASENAME} | |
echo "BASENAME=${BASENAME}" >> $GITHUB_ENV | |
echo "BIN_NAME=${BIN_NAME}" >> $GITHUB_ENV | |
echo "COMPILER_OPTS=${COMPILER_OPTS}" >> $GITHUB_ENV | |
echo "PLUGINS_OPTS=${PLUGINS_OPTS}" >> $GITHUB_ENV | |
echo "PLATFORM=${PLATFORM}" >> $GITHUB_ENV | |
- name: Install Python 3.11 | |
uses: actions/setup-python@v4 | |
with: | |
python-version: "3.11" | |
architecture: ${{ env.PLATFORM }} | |
- name: Install Poetry | |
uses: abatilo/actions-poetry@v2 | |
with: | |
poetry-version: 1.8.2 | |
- name: Install dependencies | |
shell: bash | |
run: poetry install --with build | |
- name: Run Nuitka build | |
shell: bash | |
run: | | |
poetry run python -m nuitka \ | |
--company-name=alwaysdata --product-name=${{ env.PROJECT_NAME }} \ | |
--product-version=${{ env.PROJECT_VERSION }} \ | |
--standalone \ | |
--onefile \ | |
--onefile-tempdir-spec='%CACHE_DIR%/%COMPANY%/%PRODUCT%/%VERSION%' \ | |
--python-flag=-m \ | |
--follow-import-to=src \ | |
--assume-yes-for-downloads \ | |
--enable-plugin=no-qt ${{ env.PLUGINS_OPTS }} \ | |
--noinclude-default-mode=nofollow \ | |
--show-anti-bloat-changes \ | |
--report=${{ env.BASENAME }}/report-${{ env.BASENAME }}.xml \ | |
--output-dir=${{ env.BASENAME }} \ | |
--output-filename=${{ env.BIN_NAME }} \ | |
--no-progressbar \ | |
${{ env.COMPILER_OPTS }} \ | |
src | |
- name: "Report upload" | |
uses: actions/upload-artifact@master | |
with: | |
name: report-${{ env.BASENAME }}.xml | |
path: ${{ env.BASENAME }}/report-${{ env.BASENAME }}.xml | |
- name: Package | |
shell: bash | |
run: | | |
PKG_suffix=".tar.gz" | |
case ${{ matrix.job.target }} in | |
*-windows-*) PKG_suffix=".zip" ;; | |
esac | |
PKG_NAME=${BASENAME}${PKG_suffix} | |
PKG_DIR=${BASENAME}/packages | |
mkdir -p ${PKG_DIR}/${BASENAME} | |
case ${{ matrix.job.target }} in | |
*-apple-* | *-linux-*) chmod +x ${BASENAME}/${BIN_NAME} ;; | |
esac | |
cp ${BASENAME}/${BIN_NAME} ${PKG_DIR}/${BASENAME} | |
pushd "${PKG_DIR}/" >/dev/null | |
case ${{ matrix.job.target }} in | |
*-windows-*) 7z -y a "${PKG_NAME}" "${BASENAME}" | tail -2 ;; | |
*) tar czf "${PKG_NAME}" "${BASENAME}" ;; | |
esac | |
popd > /dev/null | |
echo "PKG_NAME=${PKG_NAME}" >> $GITHUB_ENV | |
echo "PKG_PATH=${PKG_DIR}/${PKG_NAME}" >> $GITHUB_ENV | |
- name: "Artifact upload" | |
uses: actions/upload-artifact@master | |
with: | |
name: ${{ env.PKG_NAME }} | |
path: ${{ env.PKG_PATH }} |