mirror of
https://github.com/derrod/legendary.git
synced 2026-07-30 01:59:11 +00:00
ci: update actions (#739)
* update action steps versions * added support for multiple architectures * switch to zipapp building on Linux * drop support for deb package CI
This commit is contained in:
parent
9942cd987f
commit
cdf6645d5c
76
.github/workflows/python.yml
vendored
76
.github/workflows/python.yml
vendored
|
|
@ -11,23 +11,26 @@ jobs:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: ['ubuntu-24.04', 'windows-latest', 'macos-13']
|
os: [
|
||||||
|
'windows-2025', 'windows-11-arm',
|
||||||
|
'macos-15-intel', 'macos-15'
|
||||||
|
]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
max-parallel: 3
|
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v6
|
||||||
with:
|
with:
|
||||||
python-version: '3.9'
|
python-version: '3.13'
|
||||||
|
|
||||||
- name: Legendary dependencies and build tools
|
- name: Dependencies
|
||||||
|
run: pip3 install --requirement requirements.txt
|
||||||
|
|
||||||
|
- name: Build tools
|
||||||
run: pip3 install --upgrade
|
run: pip3 install --upgrade
|
||||||
setuptools
|
setuptools
|
||||||
pyinstaller
|
pyinstaller
|
||||||
requests
|
|
||||||
filelock
|
|
||||||
|
|
||||||
- name: Optional dependencies (WebView)
|
- name: Optional dependencies (WebView)
|
||||||
run: pip3 install --upgrade pywebview
|
run: pip3 install --upgrade pywebview
|
||||||
|
|
@ -35,7 +38,7 @@ jobs:
|
||||||
|
|
||||||
- name: Set strip option on non-Windows
|
- name: Set strip option on non-Windows
|
||||||
id: strip
|
id: strip
|
||||||
run: echo ::set-output name=option::--strip
|
run: echo "option=--strip" >> $GITHUB_OUTPUT
|
||||||
if: runner.os != 'Windows'
|
if: runner.os != 'Windows'
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
|
|
@ -49,40 +52,43 @@ jobs:
|
||||||
env:
|
env:
|
||||||
PYTHONOPTIMIZE: 1
|
PYTHONOPTIMIZE: 1
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
name: ${{ runner.os }}-package
|
name: ${{ runner.os }}-${{ runner.arch }}-package
|
||||||
path: legendary/dist/*
|
path: legendary/dist/*
|
||||||
|
|
||||||
deb:
|
zipapp:
|
||||||
runs-on: ubuntu-22.04
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
os: [
|
||||||
|
'ubuntu-24.04', 'ubuntu-24.04-arm'
|
||||||
|
]
|
||||||
|
fail-fast: false
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
|
- uses: actions/setup-python@v6
|
||||||
|
with:
|
||||||
|
python-version: '3.13'
|
||||||
|
|
||||||
|
- run: mkdir -p build dist
|
||||||
|
|
||||||
- name: Dependencies
|
- name: Dependencies
|
||||||
run: |
|
run: pip3 install --requirement requirements.txt --target build
|
||||||
sudo apt install ruby
|
|
||||||
sudo gem install fpm
|
- run: cp -r legendary build
|
||||||
|
- run: cp zipapp_main.py build/__main__.py
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
run: fpm
|
run: python -m zipapp
|
||||||
--input-type python
|
--output dist/legendary
|
||||||
--output-type deb
|
--python "/usr/bin/env python3"
|
||||||
--python-package-name-prefix python3
|
--compress
|
||||||
--deb-suggests python3-webview
|
build
|
||||||
--maintainer "Rodney <rodney@rodney.io>"
|
|
||||||
--category python
|
|
||||||
--depends "python3 >= 3.9"
|
|
||||||
setup.py
|
|
||||||
|
|
||||||
- name: Os version
|
- uses: actions/upload-artifact@v7
|
||||||
id: os_version
|
|
||||||
run: |
|
|
||||||
source /etc/os-release
|
|
||||||
echo ::set-output name=version::$NAME-$VERSION_ID
|
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v4
|
|
||||||
with:
|
with:
|
||||||
name: ${{ steps.os_version.outputs.version }}-deb-package
|
name: ${{ runner.os }}-${{ runner.arch }}-package
|
||||||
path: ./*.deb
|
path: dist/*
|
||||||
|
|
|
||||||
42
zipapp_main.py
Normal file
42
zipapp_main.py
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import zipfile
|
||||||
|
import filelock
|
||||||
|
import zlib
|
||||||
|
|
||||||
|
# We assume zipapp is created on Linux only
|
||||||
|
|
||||||
|
cache_path = os.environ.get('XDG_CACHE_HOME')
|
||||||
|
if cache_path:
|
||||||
|
cache_path = os.path.join(cache_path, 'legendary')
|
||||||
|
else:
|
||||||
|
cache_path = os.path.expanduser('~/.cache/legendary')
|
||||||
|
|
||||||
|
vendored_packages_path = os.path.join(cache_path, 'vendored')
|
||||||
|
vendored_packages_lock = os.path.join(cache_path, 'vendored.lock')
|
||||||
|
|
||||||
|
# At the moment only Cryptodome AES uses a native module
|
||||||
|
# Thus we only handle the extraction of that
|
||||||
|
|
||||||
|
if zipfile.is_zipfile(os.path.dirname(__file__)):
|
||||||
|
with filelock.FileLock(vendored_packages_lock) as lock:
|
||||||
|
with zipfile.ZipFile(os.path.dirname(__file__)) as zf:
|
||||||
|
# First see if we need to do the extraction
|
||||||
|
should_extract = True
|
||||||
|
init_path = os.path.join(vendored_packages_path, 'Cryptodome/__init__.py')
|
||||||
|
if os.path.exists(init_path):
|
||||||
|
file = zf.getinfo('Cryptodome/__init__.py')
|
||||||
|
with open(init_path, 'rb') as init:
|
||||||
|
should_extract = zlib.crc32(init.read()) != file.CRC
|
||||||
|
|
||||||
|
# We extract only dependencies that require native code
|
||||||
|
if should_extract:
|
||||||
|
for file in zf.infolist():
|
||||||
|
if file.filename.startswith('Cryptodome'):
|
||||||
|
extracted = zf.extract(file.filename, vendored_packages_path)
|
||||||
|
os.chmod(extracted, file.external_attr >> 16)
|
||||||
|
sys.path.insert(0, vendored_packages_path)
|
||||||
|
|
||||||
|
# Run CLI
|
||||||
|
import legendary.cli
|
||||||
|
legendary.cli.main()
|
||||||
Loading…
Reference in a new issue