Skip to content

Commit

Permalink
Merge pull request #363 from emcek/improve_relese_ci
Browse files Browse the repository at this point in the history
Improve Release CI pipeline
  • Loading branch information
emcek authored Sep 12, 2024
2 parents 2340ab2 + 5b055d8 commit c928ee9
Show file tree
Hide file tree
Showing 13 changed files with 209 additions and 95 deletions.
41 changes: 0 additions & 41 deletions .github/actions/build-app/action.yaml

This file was deleted.

79 changes: 79 additions & 0 deletions .github/workflows/nuitka.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Build dcspy binary with Nuitka

on: workflow_call

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
nuitka_type: [ dcspy_nuitka, dcspy_nuitka_cli ]
steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Set up Python environment"
uses: ./.github/actions/setup-python

- name: "Generate version info file"
shell: pwsh
id: nuitka_data
run: |
python -m pip install -U pyinstaller
$output = & python scripts/generate_ver_file.py
$output = $output -replace "[\(\)\s\']", ""
$values = $output.Split(',')
$ref_name = $values[0].Trim()
$run_number = $values[1].Trim()
$sha = $values[2].Trim()
Write-Output "git_ref_name=$ref_name" >> $env:GITHUB_OUTPUT
Write-Output "git_run_number=$run_number" >> $env:GITHUB_OUTPUT
Write-Output "git_sha=$sha" >> $env:GITHUB_OUTPUT
- uses: Nuitka/Nuitka-Action@main
if: ${{ endsWith( matrix.nuitka_type, '_nuitka') }}
with:
nuitka-version: 2.4.8
script-name: src/dcs_py.py
onefile: true
windows-console-mode: disable
prefer-source-code: true
enable-plugins: pyside6
include-package-data: dcspy
assume-yes-for-downloads: true
onefile-windows-splash-screen-image: src/dcspy/img/splash.png
output-file: ${{ matrix.nuitka_type }}
output-dir: dist
windows-icon-from-ico: src/dcspy/img/dcspy_white.ico
product-name: DCSpy
file-version: ${{ steps.nuitka_data.outputs.git_ref_name }}.${{ steps.nuitka_data.outputs.git_run_number }}
product-version: ${{ steps.nuitka_data.outputs.git_ref_name }}.${{ steps.nuitka_data.outputs.git_sha }}
file-description: Integrating DCS Planes with Logitech keyboards with LCD
copyright: (c) 2024 Michal Plichta. All rights reserved.

- uses: Nuitka/Nuitka-Action@main
if: ${{ endsWith( matrix.nuitka_type, '_cli') }}
with:
nuitka-version: 2.4.8
script-name: src/dcs_py.py
onefile: true
windows-console-mode: force
prefer-source-code: true
enable-plugins: pyside6
include-package-data: dcspy
assume-yes-for-downloads: true
onefile-windows-splash-screen-image: src/dcspy/img/splash.png
output-file: ${{ matrix.nuitka_type }}
output-dir: dist
windows-icon-from-ico: src/dcspy/img/dcspy_white.ico
product-name: DCSpy
file-version: ${{ steps.nuitka_data.outputs.git_ref_name }}.${{ steps.nuitka_data.outputs.git_run_number }}
product-version: ${{ steps.nuitka_data.outputs.git_ref_name }}.${{ steps.nuitka_data.outputs.git_sha }}
file-description: Integrating DCS Planes with Logitech keyboards with LCD
copyright: (c) 2024 Michal Plichta. All rights reserved.

- name: "Upload dcspy binaries"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.nuitka_type }}_nuitka
path: dist/${{ matrix.nuitka_type }}.exe
52 changes: 52 additions & 0 deletions .github/workflows/pyinstaller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build dcspy binary with PyInstaller

on: workflow_call

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
spec_file: [ dcspy, dcspy_cli ]
steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Set up Python environment"
uses: ./.github/actions/setup-python

- name: "Compile and install PyInstaller"
shell: bash
run: |
git clone https://github.com/pyinstaller/pyinstaller.git
pyi_tag=$(python scripts/latest_tag.py pyinstaller 1)
pyi_ver=$(python scripts/latest_tag.py pyinstaller 0)
cd pyinstaller/bootloader
git checkout $pyi_tag
python.exe ./waf all
cd ..
python -m build
python -m twine check dist/*
pip install dist/pyinstaller-$pyi_ver-py3-none-any.whl
- name: "Generate version info file"
shell: bash
run: |
python scripts/generate_ver_file.py
- name: "Build dcspy binaries"
shell: bash
run: |
export SOURCE_DATE_EPOCH=1674687685
export PYTHONHASHSEED=1674687685
pyinstaller --clean --noconfirm --log-level INFO ${{ matrix.spec_file }}.spec
md5sum dist/*.exe
unset PYTHONHASHSEED
unset SOURCE_DATE_EPOCH
pyi-bindepend dist/*.exe
- name: "Upload dcspy binaries"
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.spec_file }}_pyinstaller
path: dist/${{ matrix.spec_file }}.exe
45 changes: 21 additions & 24 deletions .github/workflows/release-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,30 @@ name: Release Pipeline

on:
push:
tags: ["v*"]
tags: [ "v*" ]

jobs:
style:
uses: ./.github/workflows/style.yml

test:
needs: [style]
needs: [ style ]
uses: ./.github/workflows/test.yml

build:
needs: [test]
runs-on: windows-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
pyinstaller:
needs: [ test ]
uses: ./.github/workflows/pyinstaller.yml

- name: "Set up Python environment"
uses: ./.github/actions/setup-python
nuitka:
needs: [ test ]
uses: ./.github/workflows/nuitka.yml

- name: "Build dcspy"
uses: ./.github/actions/build-app

- name: "Upload dcspy binaries"
uses: actions/upload-artifact@v4
with:
name: dcspy_binaries
path: dist/
wheel:
needs: [ test ]
uses: ./.github/workflows/wheel.yml

github:
needs: [build]
needs: [ pyinstaller, nuitka, wheel ]
runs-on: windows-latest
steps:
- name: "Checkout"
Expand All @@ -44,12 +37,14 @@ jobs:
- name: "Download dcspy binaries"
uses: actions/download-artifact@v4
with:
name: dcspy_binaries
merge-multiple: true
pattern: |
dcspy_*
- name: "Release Notes"
id: version
run: |
$dcspy_ver = python latest_tag.py . 0
$dcspy_ver = python scripts/latest_tag.py . 0
Write-Output "number=$dcspy_ver" >> $env:GITHUB_OUTPUT
$changelog = Get-Content .\CHANGELOG.md
$last_change = ($changelog | Select-String -Pattern "^##\s" | Select-Object -Skip 1 -First 1).LineNumber - 3
Expand All @@ -58,7 +53,7 @@ jobs:
- name: "Create Release"
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.REL_TOKEN }}
GITHUB_TOKEN: ${{ secrets.PYI_REL_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: dcspy ${{ steps.version.outputs.number }}
Expand All @@ -68,11 +63,13 @@ jobs:
files: |
dcspy.exe
dcspy_cli.exe
dcspy_nuitka.exe
dcspy_nuitka_cli.exe
dcspy-${{ steps.version.outputs.number }}-py3-none-any.whl
dcspy-${{ steps.version.outputs.number }}.tar.gz
pypi:
needs: [build]
needs: [ pyinstaller, nuitka, wheel ]
runs-on: ubuntu-latest
steps:
- name: "Checkout"
Expand All @@ -84,7 +81,7 @@ jobs:
- name: "Download dcspy binaries"
uses: actions/download-artifact@v4
with:
name: dcspy_binaries
name: dcspy_wheel

- name: "Publish dcspy to PyPI"
run: |
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']
exclude:
- os: windows-latest
python-version: '3.12'
steps:
- name: "Checkout"
uses: actions/checkout@v4
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/wheel.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build dcspy wheel package

on: workflow_call

jobs:
build:
runs-on: windows-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4

- name: "Set up Python environment"
uses: ./.github/actions/setup-python

- name: "Build dcspy wheel package"
shell: bash
run: |
python -m build
python -m twine check dist/*
- name: "Upload dcspy wheel"
uses: actions/upload-artifact@v4
with:
name: dcspy_wheel
path: |
dist/*.whl
dist/*.tar.gz
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* check if BIOS JSON's files exist before do generation and compilation
* Introduction of UV tool
* use src-layout for python package
* introduce Nuitka based executable generation
* clean-up release pipeline

## 3.5.1
* Add missing `F-4E-45MC.yaml` - #316 (@emcek)
Expand Down
14 changes: 7 additions & 7 deletions dcspy.spec
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# -*- mode: python ; coding: utf-8 -*-
from PyInstaller.utils.hooks import collect_data_files

images = [(f'dcspy/img/{res}', 'dcspy/img') for res in ['splash.png', 'dcspy_white.ico', 'dcspy_black.ico']]
resources = [(f'dcspy/resources/{res}', 'dcspy/resources') for res in ['falconded.ttf', 'license.txt', 'AH-64D_BLK_II.yaml', 'AV8BNA.yaml', 'F-4E-45MC.yaml', 'F-14A-135-GR.yaml', 'F-14B.yaml',
images = [(f'src/dcspy/img/{res}', 'dcspy/img') for res in ['splash.png', 'dcspy_white.ico', 'dcspy_black.ico']]
resources = [(f'src/dcspy/resources/{res}', 'dcspy/resources') for res in ['falconded.ttf', 'license.txt', 'AH-64D_BLK_II.yaml', 'AV8BNA.yaml', 'F-4E-45MC.yaml', 'F-14A-135-GR.yaml', 'F-14B.yaml',
'F-15ESE.yaml', 'F-16C_50.yaml', 'FA-18C_hornet.yaml', 'Ka-50.yaml', 'Ka-50_3.yaml', 'config.yaml',]]
headers = [(f'dcspy/sdk/{head}', 'dcspy/sdk') for head in ['LogitechLCDLib.h', 'LogitechLEDLib.h', 'LogitechGkeyLib.h']]
headers = [(f'src/dcspy/sdk/{head}', 'dcspy/sdk') for head in ['LogitechLCDLib.h', 'LogitechLEDLib.h', 'LogitechGkeyLib.h']]
block_cipher = None


a = Analysis(
['dcs_py.py'],
['src/dcs_py.py'],
pathex=[],
binaries=[],
datas=images + resources + headers,
Expand All @@ -25,7 +25,7 @@ a = Analysis(
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
splash = Splash(
'dcspy/img/splash.png',
'src/dcspy/img/splash.png',
binaries=a.binaries,
datas=a.datas,
text_pos=None,
Expand All @@ -43,7 +43,7 @@ exe = EXE(
splash,
splash.binaries,
[],
name=f'dcspy',
name='dcspy',
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand All @@ -57,5 +57,5 @@ exe = EXE(
codesign_identity=None,
entitlements_file=None,
version='file_version_info.txt',
icon=['dcspy/img/dcspy_white.ico'],
icon=['src/dcspy/img/dcspy_white.ico'],
)
Loading

0 comments on commit c928ee9

Please sign in to comment.