name: Build and Release on: workflow_dispatch: inputs: github_release: description: "Create Gitea Release" default: true type: boolean prerelease: description: "Is this a prerelease?" default: false type: boolean bump: description: "Bump type" required: false default: "patch" type: choice options: - "major" - "minor" - "patch" env: BASE_URL: "http://192.168.178.110:3000" jobs: prepare: runs-on: ubuntu-latest outputs: version: ${{ steps.bump.outputs.version }} tag: ${{ steps.bump.outputs.tag }} changelog: ${{ steps.build_changelog.outputs.changelog }} steps: - name: Checkout code uses: actions/checkout@v5 with: fetch-depth: 0 fetch-tags: true - name: Install uv uses: astral-sh/setup-uv@v7 - name: Set up Python uses: actions/setup-python@v5 with: # Uses the version specified in pyproject.toml python-version-file: "pyproject.toml" - name: Bump version (local only) id: bump run: | uv version --bump "${{ github.event.inputs.bump }}" version="$(uv version --short)" echo "VERSION=$version" >> "$GITHUB_ENV" echo "version=$version" >> "$GITHUB_OUTPUT" echo "tag=v$version" >> "$GITHUB_OUTPUT" - name: Build Changelog id: build_changelog uses: https://github.com/mikepenz/release-changelog-builder-action@v6.0.1 with: platform: "gitea" baseURL: "${{ env.BASE_URL }}" configuration: ".gitea/changelog_config.json" env: GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} build-linux: needs: prepare runs-on: ubuntu-latest env: VERSION: ${{ needs.prepare.outputs.version }} TAG_NAME: ${{ needs.prepare.outputs.tag }} steps: - name: Checkout code uses: actions/checkout@v5 with: fetch-depth: 0 fetch-tags: true - name: Install uv uses: astral-sh/setup-uv@v7 - name: Set up Python uses: actions/setup-python@v5 with: python-version-file: "pyproject.toml" - name: Install all dependencies run: uv sync --all-groups - name: Build Linux release with Nuitka run: | uv run python -m nuitka \ --standalone \ --output-dir=dist \ --include-data-dir=./config=config \ --include-data-dir=./site=site \ --include-data-dir=./icons=icons \ --include-data-dir=./mail_vorlagen=mail_vorlagen \ --enable-plugin=pyside6 \ --product-name=SemesterApparatsManager \ --product-version=${VERSION} \ --output-filename=SAM \ main.py - name: Prepare Linux Release Artifact run: | mkdir -p releases cd dist/SemesterApparatsManager.dist zip -r "../../releases/SAM-linux-v${VERSION}.zip" * cd ../../ - name: Create / Update Gitea Release (Linux asset + changelog) if: ${{ github.event.inputs.github_release == 'true' }} uses: softprops/action-gh-release@v2 with: tag_name: ${{ env.TAG_NAME }} name: Release ${{ env.TAG_NAME }} body: ${{ needs.prepare.outputs.changelog }} draft: false prerelease: ${{ github.event.inputs.prerelease }} make_latest: true files: | releases/SAM-linux-v${{ env.VERSION }}.zip env: GITHUB_TOKEN: ${{ secrets.TOKEN }} GITHUB_REPOSITORY: ${{ github.repository }} build-windows: needs: [prepare, build-linux] runs-on: windows-latest env: VERSION: ${{ needs.prepare.outputs.version }} TAG_NAME: ${{ needs.prepare.outputs.tag }} UV_PATH: 'C:\Users\gitea_runner_windows\.local\bin\uv.exe' UV_NO_PROJECT: "1" UV_NO_CONFIG: "1" steps: - name: Checkout code uses: actions/checkout@v5 - name: Ensure Python via uv shell: powershell run: | if (-not (Test-Path $env:UV_PATH)) { Write-Error "uv not found at $env:UV_PATH" exit 1 } & $env:UV_PATH self update $version = "3.12" Write-Host "Checking for Python $version via uv..." $exists = & $env:UV_PATH python list | Select-String $version -Quiet if (-not $exists) { Write-Host "Python $version not found; installing with uv..." & $env:UV_PATH python install $version } else { Write-Host "Python $version already installed in uv." } - name: Install build dependencies shell: powershell run: | & $env:UV_PATH sync --all-groups - name: Build Windows release with Nuitka shell: powershell run: | & $env:UV_PATH run --python 3.12 python -m nuitka ` --standalone ` --assume-yes-for-downloads ` --output-dir=dist ` --mingw64 ` --include-data-dir=./config=config ` --include-data-dir=./site=site ` --include-data-dir=./icons=icons ` --include-data-dir=./mail_vorlagen=mail_vorlagen ` --enable-plugin=pyside6 ` --product-name=SemesterApparatsManager ` --product-version=${env:VERSION} ` --output-filename=SAM.exe ` main.py - name: Prepare Windows Release Artifact shell: powershell run: | New-Item -ItemType Directory -Force -Path releases | Out-Null Set-Location dist Compress-Archive -Path * -DestinationPath "..\releases\SAM-windows-v${env:VERSION}.zip" -Force Set-Location .. - name: Attach Windows asset to Gitea Release if: ${{ github.event.inputs.github_release == 'true' }} uses: softprops/action-gh-release@v2 with: tag_name: ${{ env.TAG_NAME }} draft: false prerelease: ${{ github.event.inputs.prerelease }} files: | releases/SAM-windows-v${{ env.VERSION }}.zip env: GITHUB_TOKEN: ${{ secrets.TOKEN }} # GITHUB_REPOSITORY: ${{ github.repository }} finalize: needs: [prepare, build-linux, build-windows] runs-on: ubuntu-latest env: VERSION: ${{ needs.prepare.outputs.version }} steps: - name: Checkout code uses: actions/checkout@v5 with: fetch-depth: 0 fetch-tags: true - name: Install uv uses: astral-sh/setup-uv@v7 - name: Set up Python uses: actions/setup-python@v5 with: python-version-file: "pyproject.toml" - name: Set Git identity run: | git config user.name "Gitea CI" git config user.email "ci@git.theprivateserver.de" - name: Bump version and push run: | uv version --bump "${{ github.event.inputs.bump }}" - name: Push version bump uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: ${{ github.ref }}