dev-restructure-dir #20
@@ -1,59 +1,223 @@
|
||||
name: Build and Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_notes:
|
||||
description: Release notes (use \n for newlines)
|
||||
type: string
|
||||
required: false
|
||||
github_release:
|
||||
description: 'Create Gitea Release'
|
||||
description: "Create Gitea Release"
|
||||
default: true
|
||||
type: boolean
|
||||
prerelease:
|
||||
description: "Is this a prerelease?"
|
||||
default: false
|
||||
type: boolean
|
||||
bump:
|
||||
description: 'Bump type'
|
||||
description: "Bump type"
|
||||
required: false
|
||||
default: 'patch'
|
||||
default: "patch"
|
||||
type: choice
|
||||
options:
|
||||
- 'major'
|
||||
- 'minor'
|
||||
- 'patch'
|
||||
- "major"
|
||||
- "minor"
|
||||
- "patch"
|
||||
|
||||
env:
|
||||
BASE_URL: "http://192.168.178.110:3000"
|
||||
|
||||
jobs:
|
||||
bump:
|
||||
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
|
||||
uses: actions/checkout@v4
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Install UV
|
||||
fetch-tags: true
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
|
||||
- name: Set up Python
|
||||
run: uv python install
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
# Uses the version specified in pyproject.toml
|
||||
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
|
||||
id: bump
|
||||
run: |
|
||||
uv tool install bump-my-version
|
||||
|
||||
uv tool run bump-my-version bump "${{ github.event.inputs.bump }}"
|
||||
version="$(uv tool run bump-my-version show current_version)"
|
||||
|
||||
echo "VERSION=$version" >> "$GITHUB_ENV"
|
||||
echo "version=$version" >> "$GITHUB_OUTPUT"
|
||||
echo "tag=v$version" >> "$GITHUB_OUTPUT"
|
||||
# no env needed here, uv handles the Python it installs
|
||||
|
||||
- name: Push changes
|
||||
uses: ad-m/github-push-action@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ github.ref }}
|
||||
|
||||
- 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@v5
|
||||
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version-file: "pyproject.toml"
|
||||
- name: Install dependencies
|
||||
run: uv sync --locked --all-extras --dev
|
||||
- name: Install Bump tool
|
||||
run: uv tool install bump-my-version
|
||||
- name: Bump version
|
||||
id: bump_version
|
||||
|
||||
- name: Install all dependencies
|
||||
run: uv sync --all-groups
|
||||
|
||||
- name: Build Linux release with Nuitka
|
||||
run: |
|
||||
uv tool run bump-my-version bump ${{ github.event.inputs.bump }} --tag --allow-dirty
|
||||
- name: Add release notes
|
||||
id: add_release_notes
|
||||
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: |
|
||||
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
|
||||
echo "${{ github.event.inputs.release_notes }}" >> $GITHUB_ENV
|
||||
echo "EOF" >> $GITHUB_ENV
|
||||
- name: Create Gitea Release
|
||||
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@v1
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name:
|
||||
release_name: Release ${{ github.sha }}
|
||||
body: ${{ env.RELEASE_NOTES }}
|
||||
tag_name: ${{ env.TAG_NAME }}
|
||||
name: Release ${{ env.TAG_NAME }}
|
||||
body: ${{ needs.prepare.outputs.changelog }}
|
||||
draft: false
|
||||
prerelease: 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
|
||||
}
|
||||
|
||||
$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 }}
|
||||
|
||||
Reference in New Issue
Block a user