mirror of
https://github.com/KeksPirates/SoftwareManager.git
synced 2026-08-03 17:39:42 +02:00
202 lines
6.7 KiB
YAML
202 lines
6.7 KiB
YAML
name: Build Executables (Dev)
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
inputs:
|
|
version:
|
|
description: "Dev release version (e.g., v1.0.0-dev)"
|
|
required: true
|
|
default: "v1.0.0"
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
PYTHON_VERSION: "3.11"
|
|
APP_NAME: "SoftwareManager"
|
|
|
|
jobs:
|
|
build:
|
|
name: Build ${{ matrix.os }}
|
|
strategy:
|
|
matrix:
|
|
include:
|
|
- os: ubuntu-latest
|
|
artifact_name: SoftwareManager-dev-${{ github.sha }}-linux
|
|
asset_name: SoftwareManager-dev-${{ github.sha }}-linux
|
|
- os: windows-latest
|
|
artifact_name: SoftwareManager-dev-${{ github.sha }}-windows.exe
|
|
asset_name: SoftwareManager-dev-${{ github.sha }}-windows.exe
|
|
- os: macos-latest
|
|
artifact_name: SoftwareManager-dev-${{ github.sha }}-macos
|
|
asset_name: SoftwareManager-dev-${{ github.sha }}-macos
|
|
|
|
runs-on: ${{ matrix.os }}
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
short_sha: ${{ steps.version.outputs.short_sha }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v4
|
|
with:
|
|
python-version: ${{ env.PYTHON_VERSION }}
|
|
|
|
- name: Install system dependencies (Linux)
|
|
if: runner.os == 'Linux'
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y \
|
|
libxcb-xinerama0 \
|
|
libxkbcommon-x11-0 \
|
|
libxcb-cursor0 \
|
|
libxcb-keysyms1 \
|
|
libxcb-render-util0 \
|
|
libxcb-icccm4 \
|
|
libxcb-image0 \
|
|
libxcb-shape0 \
|
|
libxcb-util1
|
|
|
|
- name: Install Python dependencies
|
|
run: |
|
|
python -m pip install --upgrade pip
|
|
pip install -r requirements.txt
|
|
pip install pyinstaller backports.tarfile pillow
|
|
|
|
- name: Generate version
|
|
id: version
|
|
shell: bash
|
|
run: |
|
|
COMMIT_SHA=${{ github.sha }}
|
|
SHORT_SHA=${COMMIT_SHA:0:7}
|
|
VERSION="${SHORT_SHA}-dev"
|
|
echo "VERSION=$VERSION" >> $GITHUB_ENV
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
|
|
echo "Generated version: $VERSION"
|
|
|
|
- name: Inject commit hash into code
|
|
shell: bash
|
|
run: |
|
|
cat > build_info.json << EOF
|
|
{
|
|
"version": "${{ env.VERSION }}"
|
|
}
|
|
EOF
|
|
|
|
- name: Download aria2c (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
mkdir -p deps
|
|
C:\msys64\usr\bin\wget.exe https://github.com/aria2/aria2/releases/download/release-1.37.0/aria2-1.37.0-win-64bit-build1.zip
|
|
unzip -j aria2-1.37.0-win-64bit-build1.zip aria2-1.37.0-win-64bit-build1/aria2c.exe -d deps/
|
|
|
|
- name: Build executable with PyInstaller (Windows)
|
|
if: runner.os == 'Windows'
|
|
shell: bash
|
|
run: |
|
|
pyinstaller --onefile --windowed \
|
|
--add-data "build_info.json;." \
|
|
--add-data "deps/aria2c.exe;." \
|
|
--add-data "core/interface/assets;core/interface/assets" \
|
|
--icon "core/interface/assets/logo.png" \
|
|
--hidden-import=backports.tarfile \
|
|
--hidden-import=backports \
|
|
--hidden-import=jaraco.context \
|
|
--hidden-import=jaraco.text \
|
|
--hidden-import=jaraco.functools \
|
|
--name ${{ env.APP_NAME }} \
|
|
main.py
|
|
|
|
- name: Build executable with PyInstaller (Unix)
|
|
if: runner.os != 'Windows'
|
|
shell: bash
|
|
run: |
|
|
pyinstaller --onefile --windowed \
|
|
--add-data "build_info.json:." \
|
|
--add-data "core/interface/assets:core/interface/assets" \
|
|
--icon "core/interface/assets/logo.png" \
|
|
--hidden-import=backports.tarfile \
|
|
--hidden-import=backports \
|
|
--hidden-import=jaraco.context \
|
|
--hidden-import=jaraco.text \
|
|
--hidden-import=jaraco.functools \
|
|
--name ${{ env.APP_NAME }} \
|
|
main.py
|
|
|
|
- name: Make executable (Unix)
|
|
if: runner.os != 'Windows'
|
|
run: chmod +x dist/${{ env.APP_NAME }}
|
|
|
|
- name: Rename artifact
|
|
shell: bash
|
|
run: |
|
|
cd dist
|
|
mv ${{ env.APP_NAME }}${{ runner.os == 'Windows' && '.exe' || '' }} ${{ matrix.artifact_name }}
|
|
ls -la
|
|
|
|
- name: Upload build artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.os }}-build
|
|
path: dist/${{ matrix.artifact_name }}
|
|
retention-days: 1
|
|
|
|
release:
|
|
name: Create Release
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
if: success()
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Prepare release files
|
|
run: |
|
|
mkdir -p release
|
|
SHORT_SHA="${{ needs.build.outputs.short_sha }}"
|
|
cp artifacts/ubuntu-latest-build/SoftwareManager-dev-*-linux release/SoftwareManager-dev-${SHORT_SHA}-linux
|
|
cp artifacts/windows-latest-build/SoftwareManager-dev-*-windows.exe release/SoftwareManager-dev-${SHORT_SHA}-windows.exe
|
|
cp artifacts/macos-latest-build/SoftwareManager-dev-*-macos release/SoftwareManager-dev-${SHORT_SHA}-macos
|
|
chmod +x release/SoftwareManager-dev-*-linux release/SoftwareManager-dev-*-macos
|
|
ls -la release/
|
|
|
|
- name: Generate release notes
|
|
run: |
|
|
SHORT_SHA="${{ needs.build.outputs.short_sha }}"
|
|
cat > release_notes.md << EOF
|
|
## Development Build
|
|
|
|
**Commit:** [\`${SHORT_SHA}\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})
|
|
|
|
### Changes
|
|
$(git log -1 --pretty=format:"- %s" ${{ github.sha }})
|
|
|
|
### Downloads
|
|
- Linux: \`SoftwareManager-dev-${SHORT_SHA}-linux\`
|
|
- Windows: \`SoftwareManager-dev-${SHORT_SHA}-windows.exe\`
|
|
- macOS: \`SoftwareManager-dev-${SHORT_SHA}-macos\`
|
|
EOF
|
|
cat release_notes.md
|
|
|
|
- name: Create Release (Public)
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
tag_name: ${{ needs.build.outputs.version }}
|
|
name: ${{ needs.build.outputs.version }}
|
|
body_path: release_notes.md
|
|
files: |
|
|
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-linux
|
|
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-windows.exe
|
|
release/SoftwareManager-dev-${{ needs.build.outputs.short_sha }}-macos
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |