Skip to content

Commit

Permalink
Fix action packaging macos (#483)
Browse files Browse the repository at this point in the history
  • Loading branch information
airvzxf committed Oct 26, 2022
1 parent 5afb3bd commit 28dd753
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 84 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

Expand Down
81 changes: 38 additions & 43 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,35 +16,32 @@ jobs:
strategy:
matrix:
PEXT_BUILD_PORTABLE: [0, 1]
name: "AppImage (portable: ${{ matrix.PEXT_BUILD_PORTABLE }})"
runs-on: ubuntu-18.04
# Operative systems: [ubuntu-18.04, ubuntu-20.04, ubuntu-22.04]
# The Ubuntu version 22.04 has problems with Linux script to deploy plugin conda.
OPERATIVE_SYSTEM: [ubuntu-18.04]
# Python versions: ["3.6", "3.7", "3.8", "3.9", "3.10"]
# The Python versions 3.6 has problems with QT.
# The Python versions 3.10 has problems with Tox Travis.
PYTHON_VERSION: ["3.9"]
fail-fast: false
name: "${{ matrix.OPERATIVE_SYSTEM }} Python-${{ matrix.PYTHON_VERSION }} Portable-${{ matrix.PEXT_BUILD_PORTABLE }}"
runs-on: ${{ matrix.OPERATIVE_SYSTEM }}
env:
PEXT_BUILD_PORTABLE: ${{ matrix.PEXT_BUILD_PORTABLE }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install dependencies
run: |
bash -xe ci/bootstrap-container.sh
- name: Compile translations
run: |
source /opt/qt514/bin/qt514-env.sh || true
bash -xe prepare_activate_translations.sh 70 "https://hosted.weblate.org/exports/stats/pext/?format=json"
lrelease pext/pext.pro
- name: Run tests
run: |
source pext-env/bin/activate
xvfb-run tox -v -e py38
- name: Build AppImage
run: |
mkdir -p build
cd build
bash -xe ../ci/build-appimage.sh
- name: Set up
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.PYTHON_VERSION }}
- name: Build
run: bash -xve ci/build-linux.sh ${{ matrix.PYTHON_VERSION }}
- name: Archive artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: AppImage-x86_64
name: ${{ matrix.OPERATIVE_SYSTEM }}_Python-${{ matrix.PYTHON_VERSION }}_Portable-${{ matrix.PEXT_BUILD_PORTABLE }}
path: |
build/Pext*.AppImage
build/Pext*.AppImage.zsync
Expand All @@ -53,35 +50,33 @@ jobs:
osx:
strategy:
matrix:
PEXT_BUILD_PORTABLE: [0, 1]
# Pext portable: [0, 1]
# The portable version is not working in macOS.
PEXT_BUILD_PORTABLE: [0]
# Operative systems: [macos-10.15, macos-11, macos-12]
OPERATIVE_SYSTEM: [macos-latest]
# Python versions: ["3.6", "3.7", "3.8", "3.9", "3.10"]
# The Python versions 3.6 and 3.10 are not working correctly.
PYTHON_VERSION: ["3.9"]
fail-fast: false
name: "macOS (portable: ${{ matrix.PEXT_BUILD_PORTABLE }})"
runs-on: macos-10.15
name: "${{ matrix.OPERATIVE_SYSTEM }} Python-${{ matrix.PYTHON_VERSION }} Portable-${{ matrix.PEXT_BUILD_PORTABLE }}"
runs-on: ${{ matrix.OPERATIVE_SYSTEM }}
env:
PEXT_BUILD_PORTABLE: ${{ matrix.PEXT_BUILD_PORTABLE }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Python 3.6
uses: actions/setup-python@v2
- name: Set up
uses: actions/setup-python@v4
with:
python-version: 3.6
- name: Install dependencies
run: pip3 install tox-travis
- name: Compile translations
run: |
brew install qt jq
bash prepare_activate_translations.sh 70 "https://hosted.weblate.org/exports/stats/pext/?format=json"
PATH="/usr/local/opt/qt/bin:$PATH" lrelease pext/pext.pro
- name: Run tests
run: tox -v -e py36
- name: Build dmg for macOS
run: bash -xe ci/build-dmg.sh
python-version: ${{ matrix.PYTHON_VERSION }}
- name: Build
run: bash -xve ci/build-macos.sh ${{ matrix.PYTHON_VERSION }}
- name: Archive artifacts
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: macOS
name: ${{ matrix.OPERATIVE_SYSTEM }}_Python-${{ matrix.PYTHON_VERSION }}_Portable-${{ matrix.PEXT_BUILD_PORTABLE }}
path: |
Pext*.zip
Pext*.dmg
Expand All @@ -94,7 +89,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
- name: Inspect directory after downloading artifacts
run: ls -alFR
- name: Create release and upload artifacts
Expand Down
20 changes: 0 additions & 20 deletions ci/bootstrap-container.sh

This file was deleted.

16 changes: 7 additions & 9 deletions ci/build-appimage.sh → ci/build-app-image.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#! /bin/bash

set -x
set -e

# use RAM disk if possible
if [ -d /dev/shm ] && [ "$CI" != "" ]; then
TEMP_BASE=/dev/shm
Expand All @@ -21,10 +18,10 @@ cleanup () {
trap cleanup EXIT

# store repo root as variable
REPO_ROOT=$(readlink -f $(dirname $(dirname "$0")))
OLD_CWD=$(readlink -f .)
REPO_ROOT="$(readlink -f $(dirname $(dirname "$0")))"
OLD_CWD="$(readlink -f .)"

pushd "$BUILD_DIR"/
pushd "${BUILD_DIR}"/ || exit 1

# set up custom AppRun script
cat > AppRun.sh <<\EAT
Expand Down Expand Up @@ -119,10 +116,11 @@ ls -al AppDir/

python "$REPO_ROOT/setup.py" || true
if [ "$PEXT_BUILD_PORTABLE" -eq 1 ]; then
export VERSION=portable-$(cat "$REPO_ROOT/pext/VERSION")
VERSION=portable-$(cat "$REPO_ROOT/pext/VERSION")
else
export VERSION=$(cat "$REPO_ROOT/pext/VERSION")
VERSION=$(cat "$REPO_ROOT/pext/VERSION")
fi
export VERSION

wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage
chmod +x appimagetool*.AppImage
Expand All @@ -133,4 +131,4 @@ chmod +x Pext*.AppImage*
xvfb-run ./Pext*.AppImage* --version

# move AppImage back to old CWD
mv Pext*.AppImage* "$OLD_CWD"/
sudo mv Pext*.AppImage* "$OLD_CWD"/
21 changes: 10 additions & 11 deletions ci/build-dmg.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#! /bin/bash

set -x
set -e

# use RAM disk if possible
if [ -d /dev/shm ]; then
TEMP_BASE=/dev/shm
Expand All @@ -27,9 +24,9 @@ python3 setup.py || true

VERSION="$(head -n 1 "$OLD_CWD"/pext/VERSION)"

pushd "$BUILD_DIR"/
pushd "$BUILD_DIR"/ || exit 1

# install Miniconda, a self contained Python distribution
# install Miniconda, a self-contained Python distribution
wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh
bash Miniconda3-latest-MacOSX-x86_64.sh -b -p ~/miniconda -f
rm Miniconda3-latest-MacOSX-x86_64.sh
Expand Down Expand Up @@ -76,7 +73,7 @@ fi
chmod a+x Pext.app/Contents/MacOS/Pext

# remove bloat
pushd Pext.app/Contents/Resources
pushd Pext.app/Contents/Resources || exit 1
rm -rf pkgs
find . -type d -iname '__pycache__' -print0 | xargs -0 rm -r
#find . -type f -iname '*.so*' -print -exec strip '{}' \;
Expand All @@ -89,15 +86,17 @@ rm -r lib/python3.7/site-packages/PyQt5/Qt/qml/QtWebEngine* || true
rm -r lib/python3.7/site-packages/PyQt5/Qt/plugins/webview/libqtwebview* || true
rm lib/python3.7/site-packages/PyQt5/Qt/libexec/QtWebEngineProcess* || true
rm lib/python3.7/site-packages/PyQt5/Qt/lib/libQt5WebEngine* || true
popd
popd
popd || exit 1
popd || exit 1

# generate .dmg
if [ "$PEXT_BUILD_PORTABLE" -eq 1 ]; then
mv "$BUILD_DIR"/Pext.app Pext-portable-$VERSION.app
zip -r Pext-portable-$VERSION.app.zip Pext-portable-*.app
mv "$BUILD_DIR"/Pext.app Pext-portable-"${VERSION}".app
zip -r Pext-portable-"${VERSION}".app.zip Pext-portable-*.app
else
brew install create-dmg
# "--skip-jenkins" is a temporary workaround for https://github.com/create-dmg/create-dmg/issues/72
create-dmg --skip-jenkins --volname "Pext $VERSION" --volicon "$OLD_CWD"/pext/images/scalable/pext.icns --window-pos 200 120 --window-size 800 400 --icon-size 100 --icon Pext.app 200 190 --hide-extension Pext.app --app-drop-link 600 185 Pext-$VERSION.dmg "$BUILD_DIR"/
create-dmg --skip-jenkins --volname "Pext $VERSION" --volicon "$OLD_CWD"/pext/images/scalable/pext.icns \
--window-pos 200 120 --window-size 800 400 --icon-size 100 --icon Pext.app 200 190 --hide-extension Pext.app \
--app-drop-link 600 185 Pext-"${VERSION}".dmg "$BUILD_DIR"/
fi
47 changes: 47 additions & 0 deletions ci/build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#! /bin/bash

PYTHON_VERSION="${1}"
UBUNTU_RELEASE=$(sudo lsb_release -rs)

# Update APT repositories
sudo apt-get update

# Update pip
python3 -m pip install --user --upgrade pip

# Install vEnv
python3 -m pip install --user virtualenv

# Install curl
sudo apt-get install -y curl libcurl4 libcurl4-gnutls-dev bc

# Install Qt
if [ "${UBUNTU_RELEASE}" = "22.04" ]; then
sudo apt-get install -y qtbase5-dev qt5-qmake qtbase5-dev-tools qttools5-dev-tools
else
sudo apt-get install -y qt5-default qt5-qmake qtbase5-dev-tools qttools5-dev-tools
fi

# Create the Python vEnv
python3 -m venv pext-env
source pext-env/bin/activate
python3 -m pip install --upgrade pip

# Install Tox
python3 -m pip install tox

# Install requirements
python3 -m pip install -r requirements.txt

# Generate translation
bash -xe prepare_activate_translations.sh 70 "https://hosted.weblate.org/exports/stats/pext/?format=json"
lrelease pext/pext.pro

# Run tests
xvfb-run tox -v -e py"${PYTHON_VERSION//./}"

# Build the app
rm -fR build
mkdir -p build
cd build || exit 1
bash -xve ../ci/build-app-image.sh
17 changes: 17 additions & 0 deletions ci/build-macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#! /bin/bash

PYTHON_VERSION="${1}"

# Install Tox
pip3 install tox

# Generate translation
brew install qt jq
bash prepare_activate_translations.sh 70 "https://hosted.weblate.org/exports/stats/pext/?format=json"
PATH="/usr/local/opt/qt/bin:$PATH" lrelease pext/pext.pro

# Run tests
tox -v -e py"${PYTHON_VERSION//./}"

# Build the app
bash -xve ci/build-dmg.sh

0 comments on commit 28dd753

Please sign in to comment.