Skip to content

Commit

Permalink
Merge pull request #1138 from Gatsik/linux
Browse files Browse the repository at this point in the history
Provide frozen executable for linux
  • Loading branch information
Gatsik authored Sep 20, 2024
2 parents 0b69a2b + 46ec768 commit 40e6680
Show file tree
Hide file tree
Showing 232 changed files with 1,188 additions and 1,001 deletions.
33 changes: 30 additions & 3 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ on:

jobs:
checks:
runs-on: windows-latest
strategy:
matrix:
os: [windows-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4

Expand All @@ -17,10 +20,34 @@ jobs:
python-version: 3.12
cache: pip

- name: Install dependencies
- name: Install Linux dependencies
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
libxkbcommon-x11-0 \
x11-utils \
libyaml-dev \
libegl1-mesa \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-xinerama0 \
libopengl0 \
libxcb-cursor0 \
pulseaudio
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pytest-xvfb
- name: Install Windows dependencies
if: startsWith(matrix.os, 'windows')
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
python -m pip install -r win_requirements.txt
- name: Test with pytest
run: |
Expand Down
141 changes: 126 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@ on:
version:
description: 'Release Version'
required: true
env:
UID_VERSION: v4.0.6
ICE_ADAPTER_VERSION: 3.3.9
BUILD_VERSION: ${{ github.event.inputs.version }}

jobs:
release:
build-windows:
environment: deploy
runs-on: windows-latest
env:
UID_VERSION: v4.0.6
ICE_ADAPTER_VERSION: 3.3.9
BUILD_VERSION: ${{ github.event.inputs.version }}

outputs:
MSI_SUM: ${{ steps.checksum.outputs.MSI_SUM }}
steps:
- uses: actions/checkout@v4

Expand All @@ -28,20 +29,28 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install -r win_requirements.txt
- name: Test with pytest
run: |
python runtests.py -vv --full-trace
- name: Download ICE adapter and UID calculator
run: |
mkdir build_setup\ice-adapter
Invoke-WebRequest -Uri "https://github.com/FAForever/uid/releases/download/$($env:UID_VERSION)/faf-uid.exe" -OutFile ".\\build_setup\\faf-uid.exe"
Invoke-WebRequest -Uri "https://content.faforever.com/build/jre/windows-amd64-21.0.1.tar.gz" -OutFile ".\\windows-amd64-15.0.1.tar.gz"
7z x windows-amd64-15.0.1.tar.gz
7z x windows-amd64-15.0.1.tar -obuild_setup/ice-adapter/jre
Invoke-WebRequest -Uri "https://github.com/FAForever/java-ice-adapter/releases/download/$($env:ICE_ADAPTER_VERSION)/faf-ice-adapter-$($env:ICE_ADAPTER_VERSION)-win.jar" -OutFile ".\\build_setup\\ice-adapter\\faf-ice-adapter.jar"
- name: Test with pytest
- name: Download JDK and create JRE
run: |
python runtests.py -vv --full-trace
Invoke-WebRequest -Uri "https://download.oracle.com/java/21/latest/jdk-21_windows-x64_bin.zip" -OutFile ".\\windows-jdk.zip"
7z x windows-jdk.zip -ojdk
pushd jdk
mv $(ls) jdk
popd
$ICE_ADAPTER_JAVA_MODULES=((jdk/jdk/bin/jdeps.exe -s "build_setup/ice-adapter/faf-ice-adapter.jar" | findstr "java" | ForEach-Object { $_.split(" ")[2] }) -join ",")
jdk/jdk/bin/jlink.exe --add-modules "$ICE_ADAPTER_JAVA_MODULES,jdk.crypto.ec,jdk.unsupported" --strip-debug --no-man-pages --no-header-files --compress "zip-6" --output "build_setup/ice-adapter/jre"
- name: Build application
run: |
Expand All @@ -52,15 +61,117 @@ jobs:
run: |
$MSI_SUM = $(Get-FileHash dist/*).hash
Write-Host $MSI_SUM
echo "MSI_SUM=$MSI_SUM" >> "$env:GITHUB_ENV"
echo "MSI_SUM=$MSI_SUM" >> "$env:GITHUB_OUTPUT"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: client-windows
path: dist/*

build-linux:
runs-on: ubuntu-latest
environment: release
outputs:
TAR_SUM: ${{ steps.checksum.outputs.TAR_SUM }}

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
cache: pip

- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y \
libxkbcommon-x11-0 \
x11-utils \
libyaml-dev \
libegl1-mesa \
libxcb-icccm4 \
libxcb-image0 \
libxcb-keysyms1 \
libxcb-randr0 \
libxcb-render-util0 \
libxcb-xinerama0 \
libopengl0 \
libxcb-cursor0 \
pulseaudio
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
python -m pip install pytest-xvfb
- name: Test with pytest
run: |
python runtests.py -vv --full-trace
- name: Download ICE adapter and UID calculator
run: |
mkdir -p build_setup/ice-adapter
wget -O build_setup/faf-uid "https://github.com/FAForever/uid/releases/download/$UID_VERSION/faf-uid"
chmod +x build_setup/faf-uid
wget "https://github.com//FAForever/java-ice-adapter/releases/download/$ICE_ADAPTER_VERSION/faf-ice-adapter-$ICE_ADAPTER_VERSION-win.jar" -O "build_setup/ice-adapter/faf-ice-adapter.jar"
- name: Download JDK and create JRE
run: |
wget -O "jdk.tar.gz" "https://download.oracle.com/java/21/latest/jdk-21_linux-x64_bin.tar.gz"
mkdir jdk
tar -xzvf jdk.tar.gz -C jdk --strip-components=1
ICE_ADAPTER_JAVA_MODULES=$(jdk/bin/jdeps -s build_setup/ice-adapter/faf-ice-adapter.jar | cut -d' ' -f 3 | grep java | xargs echo | tr ' ' ',')
jdk/bin/jlink --add-modules "$ICE_ADAPTER_JAVA_MODULES,jdk.crypto.ec,jdk.unsupported" --strip-debug --no-man-pages --no-header-files --compress "zip-6" --output "build_setup/ice-adapter/jre"
- name: Build application
run: |
python3 setup.py build
python3 post_setup.py
tar -C "build" -cvzf "faforever.tar.gz" "faf_python_client"
- name: Calculate checksum
id: checksum
run: |
TAR_SUM=$(echo faforever.tar.gz -n | sha256sum)
echo $TAR_SUM
echo "TAR_SUM=$TAR_SUM" >> "$GITHUB_OUTPUT"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: client-linux
path: faforever.tar.gz

create-release:
needs: [build-windows, build-linux]
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Download Windows artifact
uses: actions/download-artifact@v4
with:
name: client-windows
path: release-artifacts/

- name: Download Linux artifact
uses: actions/download-artifact@v4
with:
name: client-linux
path: release-artifacts/

- name: Create draft release
id: create_release
uses: ncipollo/[email protected]
with:
commit: ${{ github.sha }}
tag: ${{ github.event.inputs.version }}
body: "SHA256: ${{ env.MSI_SUM }}"
body: "SHA256 (Windows): ${{ needs.build-windows.outputs.MSI_SUM }}\nSHA256 (Linux): ${{ needs.build-linux.outputs.TAR_SUM }}"
draft: true
prerelease: true
artifacts: dist/*
artifacts: "release-artifacts/*"
46 changes: 0 additions & 46 deletions conftest.py

This file was deleted.

39 changes: 39 additions & 0 deletions post_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pathlib
import sys


def remove_some_redundant_qt_files() -> None:
current_dir = pathlib.Path(__file__).parent
build_dir = current_dir / "build"
app_dir, = build_dir.iterdir()
app_qt6 = app_dir / "lib" / "PyQt6" / "Qt6"

# cx_Freeze copies these into lib directory itself
# and into every plugin directory for some reason
libfiles = [file.name for file in (app_qt6 / "lib").iterdir()]

# not all of them, but the most obvious and largest ones
redundant_plugins_files = [
"libffmpegmediaplugin.so",
"libQt6Pdf.so.6",
"libQt6Qml.so.6",
"libQt6QmlModels.so.6",
"libQt6Quick.so.6",
]

plugins_dir = app_qt6 / "plugins"
for plugin in plugins_dir.iterdir():
for file in plugin.iterdir():
if file.name in libfiles + redundant_plugins_files:
print(f"Removing {file}...")
file.unlink()


def main() -> None:
if sys.platform == "win32":
return
remove_some_redundant_qt_files()


if __name__ == "__main__":
raise SystemExit(main())
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ pytest
pytest-cov
pytest-mock
pytest-qt
pywin32
semantic_version
zstandard
4 changes: 2 additions & 2 deletions res/chat/channel.ui
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@
<customwidget>
<class>ChatLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">chat.chatlineedit</header>
<header location="global">src.chat.chatlineedit</header>
</customwidget>
<customwidget>
<class>ChatterListView</class>
<extends>QListView</extends>
<header location="global">chat.chatterlistview</header>
<header location="global">src.chat.chatterlistview</header>
</customwidget>
</customwidgets>
<tabstops>
Expand Down
2 changes: 1 addition & 1 deletion res/coop/coop.ui
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ p, li { white-space: pre-wrap; }
<customwidget>
<class>CoopLeaderboardTableView</class>
<extends>QTableView</extends>
<header>coop.cooptableview</header>
<header>src.coop.cooptableview</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
4 changes: 2 additions & 2 deletions res/stats/leaderboard.ui
Original file line number Diff line number Diff line change
Expand Up @@ -779,12 +779,12 @@
<customwidget>
<class>LeaderboardTableView</class>
<extends>QTableView</extends>
<header location="global">stats.itemviews.leaderboardtableview</header>
<header location="global">src.stats.itemviews.leaderboardtableview</header>
</customwidget>
<customwidget>
<class>LeaderboardLineEdit</class>
<extends>QLineEdit</extends>
<header location="global">stats.leaderboardlineedit</header>
<header location="global">src.stats.leaderboardlineedit</header>
</customwidget>
</customwidgets>
<resources/>
Expand Down
Loading

0 comments on commit 40e6680

Please sign in to comment.