test release workflow
This commit is contained in:
@@ -1,59 +1,223 @@
|
|||||||
|
name: Build and Release
|
||||||
|
|
||||||
on:
|
on:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
inputs:
|
inputs:
|
||||||
release_notes:
|
|
||||||
description: Release notes (use \n for newlines)
|
|
||||||
type: string
|
|
||||||
required: false
|
|
||||||
github_release:
|
github_release:
|
||||||
description: 'Create Gitea Release'
|
description: "Create Gitea Release"
|
||||||
default: true
|
default: true
|
||||||
type: boolean
|
type: boolean
|
||||||
|
prerelease:
|
||||||
|
description: "Is this a prerelease?"
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
bump:
|
bump:
|
||||||
description: 'Bump type'
|
description: "Bump type"
|
||||||
required: false
|
required: false
|
||||||
default: 'patch'
|
default: "patch"
|
||||||
type: choice
|
type: choice
|
||||||
options:
|
options:
|
||||||
- 'major'
|
- "major"
|
||||||
- 'minor'
|
- "minor"
|
||||||
- 'patch'
|
- "patch"
|
||||||
|
|
||||||
|
env:
|
||||||
|
BASE_URL: "http://192.168.178.110:3000"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
bump:
|
prepare:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
version: ${{ steps.bump.outputs.version }}
|
||||||
|
tag: ${{ steps.bump.outputs.tag }}
|
||||||
|
changelog: ${{ steps.build_changelog.outputs.changelog }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout code
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Install UV
|
fetch-tags: true
|
||||||
|
|
||||||
|
- name: Install uv
|
||||||
uses: astral-sh/setup-uv@v5
|
uses: astral-sh/setup-uv@v5
|
||||||
|
|
||||||
- name: Set up Python
|
- 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:
|
with:
|
||||||
python-version-file: "pyproject.toml"
|
python-version-file: "pyproject.toml"
|
||||||
- name: Install dependencies
|
|
||||||
run: uv sync --locked --all-extras --dev
|
- name: Install all dependencies
|
||||||
- name: Install Bump tool
|
run: uv sync --all-groups
|
||||||
run: uv tool install bump-my-version
|
|
||||||
- name: Bump version
|
- name: Build Linux release with Nuitka
|
||||||
id: bump_version
|
|
||||||
run: |
|
run: |
|
||||||
uv tool run bump-my-version bump ${{ github.event.inputs.bump }} --tag --allow-dirty
|
uv run python -m nuitka \
|
||||||
- name: Add release notes
|
--standalone \
|
||||||
id: add_release_notes
|
--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: |
|
run: |
|
||||||
echo "RELEASE_NOTES<<EOF" >> $GITHUB_ENV
|
mkdir -p releases
|
||||||
echo "${{ github.event.inputs.release_notes }}" >> $GITHUB_ENV
|
cd dist/SemesterApparatsManager.dist
|
||||||
echo "EOF" >> $GITHUB_ENV
|
zip -r "../../releases/SAM-linux-v${VERSION}.zip" *
|
||||||
- name: Create Gitea Release
|
cd ../../
|
||||||
|
|
||||||
|
- name: Create / Update Gitea Release (Linux asset + changelog)
|
||||||
if: ${{ github.event.inputs.github_release == 'true' }}
|
if: ${{ github.event.inputs.github_release == 'true' }}
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v2
|
||||||
with:
|
with:
|
||||||
tag_name:
|
tag_name: ${{ env.TAG_NAME }}
|
||||||
release_name: Release ${{ github.sha }}
|
name: Release ${{ env.TAG_NAME }}
|
||||||
body: ${{ env.RELEASE_NOTES }}
|
body: ${{ needs.prepare.outputs.changelog }}
|
||||||
draft: false
|
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