Skip to content

Commit

Permalink
Merge commit 'ca2c362' into 2024-10-24-pagination-buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
jotelha committed Nov 7, 2024
2 parents d88ab7e + ca2c362 commit 5a0a1e1
Show file tree
Hide file tree
Showing 49 changed files with 2,825 additions and 1,340 deletions.
155 changes: 111 additions & 44 deletions .github/workflows/build-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master
- main
tags:
- '*'
pull_request:
Expand All @@ -20,17 +21,14 @@ jobs:
build-on-macos:
uses: livMatS/dtool-lookup-gui/.github/workflows/build-on-macos.yml@master

publish-on-pypi:
runs-on: ubuntu-22.04
build-python-package:
name: Build
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Get history and tags for SCM versioning to work
run: |
git fetch --prune --unshallow
git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Python 3.12
uses: actions/setup-python@v5
Expand All @@ -48,44 +46,89 @@ jobs:
gir1.2-gtk-3.0 \
libgtksourceview-4-0
- name: Install pythonic dependencies
- name: Install requirements
run: |
pip install --upgrade pip
pip install wheel build
pip install -r requirements.txt
pip install --upgrade build
pip install --upgrade setuptools wheel setuptools-scm[toml]
pip list
- name: Package distribution
run: |
python -m build --sdist --wheel
ls -1 dist/
python -m build
- name: Get master HEAD SHA
id: get_master_sha
run: |
git fetch --depth 1 origin master
echo "Commit that triggered this workflow: ${{ github.sha }}"
echo "HEAD at master: $(git rev-parse origin/master)"
echo "sha=$(git rev-parse origin/master)" >> $GITHUB_OUTPUT
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/


publish-to-testpypi:
name: Publish to TestPyPI
needs:
- build-python-package
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/dtool-lookup-gui

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

- name: Publish package
if: >-
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
steps.get_master_sha.outputs.sha == github.sha
uses: pypa/[email protected]
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
verbose: true
skip-existing: true

publish-to-pypi:
name: Publish to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build-python-package
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/dtool-lookup-gui # Replace <package-name> with your PyPI project name
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.pypi_password }}
verbose: true

publish-on-github:
runs-on: ubuntu-20.04
name: >-
Make github release
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

needs:
- build-on-ubuntu
- build-on-macos
- build-on-windows
- build-installer-on-windows
- publish-to-pypi

steps:
- name: Checkout
Expand Down Expand Up @@ -136,6 +179,19 @@ jobs:
run: |
ls -lhv .
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/

- name: Sign with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Get master HEAD SHA
id: get_master_sha
run: |
Expand All @@ -144,16 +200,27 @@ jobs:
echo "HEAD at master: $(git rev-parse master)"
echo "sha=$(git rev-parse origin/master)" >> $GITHUB_OUTPUT
- name: Make release
if: >-
github.event_name == 'push' &&
startsWith(github.ref, 'refs/tags') &&
steps.get_master_sha.outputs.sha == github.sha
uses: softprops/action-gh-release@v2
with:
files: |
dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-linux.tar.gz
dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-macos.dmg
dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-windows.zip
dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-windows-installer.exe
draft: true
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' \
--repo '${{ github.repository }}' \
dist/** \
dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-linux.tar.gz \
dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-macos.dmg \
dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-windows.zip \
dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-windows-installer.exe
14 changes: 8 additions & 6 deletions .github/workflows/build-installer-on-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ jobs:
curl
git
zip
mingw-w64-x86_64-cmake
mingw-w64-x86_64-cython
mingw-w64-x86_64-gcc
mingw-w64-x86_64-gobject-introspection
mingw-w64-x86_64-gtk3
mingw-w64-x86_64-gtksourceview4
mingw-w64-x86_64-openssl
Expand Down Expand Up @@ -82,7 +84,7 @@ jobs:
echo "### pacman -Q ###"
pacman -Q | tee pacman_Q.txt
echo "### pacman -Q diff to reference configuration ###"
(git diff --ignore-space-change --ignore-cr-at-eol --no-index pyinstaller/mingw64_pacman_Q.txt pacman_Q.txt || true) | tee diff_pacman_q.txt
(git diff --ignore-space-change --ignore-cr-at-eol --no-index pyinstaller/win/mingw64_pacman_Q.txt pacman_Q.txt || true) | tee diff_pacman_q.txt
# 2022/01/23, although msys2/setup-msys2@v2 setup has been kept as close as possible to
# a local reference build system, former diverged from latter's pyinstaller behavior
Expand All @@ -101,8 +103,8 @@ jobs:
python --version
pip --version
echo "### install pythonic dependencies ###"
pip install --upgrade pip
pip install -r pyinstaller/mingw64_requirements.txt
python -m pip install --upgrade pip
pip install -r pyinstaller/win/requirements.txt
pip install PyInstaller
echo "PyInstaller version: $(python -m PyInstaller --version)"
Expand Down Expand Up @@ -130,12 +132,12 @@ jobs:
echo "### pip freeze --local ###"
pip freeze --local | tee pip_freeze_local.txt
echo "### pip freeze --local diff to reference configuration ###"
(git diff --ignore-space-change --ignore-cr-at-eol --no-index pyinstaller/mingw64_venv_pip_freeze_local.txt pip_freeze_local.txt || true) | tee diff_pip_freeze_local.txt
(git diff --ignore-space-change --ignore-cr-at-eol --no-index pyinstaller/win/mingw64_venv_pip_freeze_local.txt pip_freeze_local.txt || true) | tee diff_pip_freeze_local.txt
echo "### pip freeze ###"
pip freeze | tee pip_freeze.txt
echo "### pip freeze diff to reference configuration ###"
(git diff --ignore-space-change --ignore-cr-at-eol --no-index pyinstaller/mingw64_venv_pip_freeze.txt pip_freeze.txt || true) | tee diff_pip_freeze.txt
(git diff --ignore-space-change --ignore-cr-at-eol --no-index pyinstaller/win/mingw64_venv_pip_freeze.txt pip_freeze.txt || true) | tee diff_pip_freeze.txt
- name: Compile gschemas
run: |
Expand All @@ -147,7 +149,7 @@ jobs:
source venv/bin/activate
# only ran into problems when calling PyInstaller or pyinstaller directly,
# would never find package metadata within the venv, call as module mitigates the issue:
python -m PyInstaller -y ./pyinstaller/dtool-lookup-gui-windows.spec 2>&1 | tee pyinstaller.log
python -m PyInstaller -y ./pyinstaller/win/dtool-lookup-gui-windows.spec 2>&1 | tee pyinstaller.log
- name: Build installer
run: |
Expand Down
87 changes: 67 additions & 20 deletions .github/workflows/build-on-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
build:

runs-on: macos-11
runs-on: macos-14

steps:

Expand All @@ -24,7 +24,18 @@ jobs:

- name: Install system dependencies
run: |
brew install python pygobject3 gtk+3 gtksourceview4 gnome-icon-theme create-dmg
brew install \
python \
glib \
gobject-introspection \
pygobject3 \
gtk+3 \
gtksourceview4 \
adwaita-icon-theme \
create-dmg \
gfortran \
numpy \
scipy
- name: Log system package info
run: |
Expand All @@ -37,13 +48,13 @@ jobs:
- name: Install pythonic dependencies
run: |
python3 -m venv --system-site-packages venv
python3.13 -m venv --system-site-packages venv
source venv/bin/activate
pip install --upgrade pip
pip install wheel setuptools setuptools_scm
pip install -r requirements.txt
pip install pyinstaller
pip install wheel setuptools_scm
pip install -r pyinstaller/macos/requirements.txt
pip install pyinstaller pyinstaller-hooks-contrib
- name: Fix setuptools_scm-generated version
id: fix_version
Expand All @@ -70,7 +81,7 @@ jobs:
- name: Package executable with pyinstaller
run: |
source venv/bin/activate
pyinstaller -y ./pyinstaller/dtool-lookup-gui-macos.spec 2>&1 | tee pyinstaller.log
pyinstaller -y ./pyinstaller/macos/dtool-lookup-gui-macos.spec 2>&1 | tee pyinstaller.log
ls -lh dist
mv dist/dtool-lookup-gui.app dtool-lookup-gui.app
Expand All @@ -90,21 +101,57 @@ jobs:
run: |
ls -lhv release/
# see hditutil issue https://github.com/actions/runner-images/issues/7522
- name: Create dmg
shell: bash {0}
run: |
create-dmg \
--volname "dtool-lookup-gui" \
--eula "LICENSE.txt" \
--volicon "data/icons/dtool_logo.icns" \
--window-pos 200 120 \
--window-size 600 300 \
--icon-size 100 \
--icon "dtool-lookup-gui.app" 175 120 \
--hide-extension "dtool-lookup-gui.app" \
--app-drop-link 425 120 \
--hdiutil-verbose \
"dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-macos.dmg" \
"release/"
max_retries=3
retry_count=0
hdiutil info
echo "Killing XProtect if running..."
sudo pkill -9 XProtect >/dev/null || true
echo "Waiting for XProtect to stop..."
while pgrep XProtect; do sleep 3; done
sleep 10
while (( retry_count < max_retries )); do
echo "Attempt $(($retry_count + 1)) to create dmg..."
create-dmg \
--volname "dtool-lookup-gui" \
--eula "LICENSE.txt" \
--volicon "data/icons/dtool_logo.icns" \
--window-pos 200 120 \
--window-size 600 300 \
--icon-size 100 \
--icon "dtool-lookup-gui.app" 175 120 \
--hide-extension "dtool-lookup-gui.app" \
--app-drop-link 425 120 \
--hdiutil-verbose \
"dtool-lookup-gui-${{ steps.fix_version.outputs.version }}-macos.dmg" \
"release/"
# Check if create-dmg succeeded
if [[ $? -eq 0 ]]; then
echo "Disk image created successfully."
break
else
echo "Failed to create dmg. Resource might be busy."
((retry_count++))
echo "Retrying in 10 seconds... (Attempt $retry_count of $max_retries)"
sleep 10
fi
done
hdiutil info
if (( retry_count == max_retries )); then
echo "Failed to create dmg after $max_retries attempts."
exit 1
fi
- name: Upload build artifact
uses: actions/upload-artifact@v4
Expand Down
Loading

0 comments on commit 5a0a1e1

Please sign in to comment.