Prepare 2.3.0 release and Linux Docker workflows
Desktop CI / tests (push) Failing after 1m51s

This commit is contained in:
benya
2026-09-25 14:02:32 +03:00
parent 0a82ad7e3e
commit bb6de9b737
15 changed files with 759 additions and 315 deletions
+103 -100
View File
@@ -8,8 +8,7 @@ on:
jobs:
prerelease:
runs-on: windows
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: https://git.daemonlord.ru/actions/checkout@v4
@@ -17,127 +16,131 @@ jobs:
fetch-depth: 0
tags: true
- name: Ensure Python 3.13
shell: powershell
run: |
if (Get-Command python -ErrorAction SilentlyContinue) {
python --version
} elseif (Get-Command py -ErrorAction SilentlyContinue) {
$pyExe = py -3.13 -c "import sys; print(sys.executable)"
if (-not $pyExe) {
throw "Python 3.13 launcher is available, but interpreter was not found."
}
Split-Path $pyExe | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
python --version
} else {
throw "Python is not installed on runner. Install Python 3.13 and restart runner service."
}
- name: Set up Python for tests
uses: https://git.daemonlord.ru/actions/setup-python@v5
with:
python-version: "3.13"
- name: Install dependencies
shell: powershell
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt pyinstaller
- name: Extract prerelease metadata
- name: Read prerelease metadata
id: meta
shell: powershell
shell: bash
run: |
$version = (python -c "from app_version import APP_VERSION; print(APP_VERSION)").Trim()
$commit = (git rev-parse --short HEAD).Trim()
$tag = "v$version-$commit"
$archive = "AnabasisManager-$version-$commit"
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::AppendAllText($env:GITHUB_OUTPUT, "version=$version`n", $utf8NoBom)
[System.IO.File]::AppendAllText($env:GITHUB_OUTPUT, "commit=$commit`n", $utf8NoBom)
[System.IO.File]::AppendAllText($env:GITHUB_OUTPUT, "tag=$tag`n", $utf8NoBom)
[System.IO.File]::AppendAllText($env:GITHUB_OUTPUT, "archive=$archive`n", $utf8NoBom)
[System.IO.File]::AppendAllText($env:GITHUB_ENV, "CONTINUE=true`n", $utf8NoBom)
Write-Host "Detected tag: $tag"
set -euo pipefail
test "$GITHUB_REF" = refs/heads/dev
version="$(python -c 'from app_version import APP_VERSION; print(APP_VERSION)')"
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]
commit="$(git rev-parse --short HEAD)"
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "commit=$commit" >> "$GITHUB_OUTPUT"
echo "tag=v$version-$commit" >> "$GITHUB_OUTPUT"
echo "archive=AnabasisManager-$version-$commit" >> "$GITHUB_OUTPUT"
- name: Stop if prerelease already exists
if: env.CONTINUE == 'true'
shell: powershell
- name: Check prerelease does not exist
id: check_release
shell: bash
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
RELEASE_TAG: ${{ steps.meta.outputs.tag }}
run: |
$tag = "${{ steps.meta.outputs.tag }}"
$apiUrl = "https://git.daemonlord.ru/api/v1/repos/${{ gitea.repository }}/releases?page=1&limit=100"
$headers = @{ Authorization = "token ${{ secrets.API_TOKEN }}" }
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
try {
$response = Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Get
$found = $false
foreach ($release in $response) {
if ($release.tag_name -eq $tag) {
$found = $true
break
}
}
if ($found) {
Write-Host "Pre-release $tag already exists, stopping job."
[System.IO.File]::AppendAllText($env:GITHUB_ENV, "CONTINUE=false`n", $utf8NoBom)
} else {
Write-Host "Pre-release $tag not found, continuing workflow..."
}
} catch {
Write-Host "Failed to query releases list, continuing workflow..."
}
set -euo pipefail
test -n "$API_TOKEN" || { echo 'API_TOKEN secret is missing'; exit 1; }
status="$(curl --silent --show-error --output /dev/null --write-out '%{http_code}' \
--header "Authorization: token $API_TOKEN" \
"https://git.daemonlord.ru/api/v1/repos/${{ gitea.repository }}/releases/tags/$RELEASE_TAG")"
case "$status" in
200) echo "Prerelease $RELEASE_TAG already exists; skipping."; echo 'publish=false' >> "$GITHUB_OUTPUT" ;;
404) echo 'publish=true' >> "$GITHUB_OUTPUT" ;;
*) echo "Cannot check prerelease: HTTP $status"; exit 1 ;;
esac
- name: Check Linux Docker runner
if: steps.check_release.outputs.publish == 'true'
shell: bash
run: |
set -euo pipefail
test "$(uname -m)" = x86_64
if ! command -v docker > /dev/null; then
if [ "$(id -u)" -eq 0 ]; then
apt-get update && apt-get install -y docker.io
else
sudo apt-get update && sudo apt-get install -y docker.io
fi
fi
docker info --format '{{.OSType}}' | grep -qx linux
- name: Install test dependencies
if: steps.check_release.outputs.publish == 'true'
shell: bash
run: |
set -euo pipefail
python -m pip install -r requirements.txt
- name: Run tests
if: env.CONTINUE == 'true'
shell: powershell
if: steps.check_release.outputs.publish == 'true'
shell: bash
env:
QT_QPA_PLATFORM: offscreen
run: |
python -m py_compile app_version.py main.py build.py updater_gui.py tests/test_auth_relogin_smoke.py tests/test_auto_update_service.py tests/test_chat_actions.py tests/test_token_store.py
python -m unittest discover -s tests -p "test_*.py" -v
set -euo pipefail
python -m compileall -q app_version.py main.py build.py updater_gui.py services ui tests
python -m unittest discover -s tests -p 'test_*.py' -v
- name: Build release zip
if: env.CONTINUE == 'true'
shell: powershell
run: |
python build.py
- name: Build Windows application with PyInstaller
if: steps.check_release.outputs.publish == 'true'
shell: bash
run: bash scripts/docker-build-windows.sh
- name: Prepare prerelease artifacts
if: env.CONTINUE == 'true'
shell: powershell
- name: Prepare prerelease archive
if: steps.check_release.outputs.publish == 'true'
shell: bash
env:
APP_VERSION: ${{ steps.meta.outputs.version }}
ARCHIVE_BASE: ${{ steps.meta.outputs.archive }}
run: |
$version = "${{ steps.meta.outputs.version }}"
$archiveBase = "${{ steps.meta.outputs.archive }}"
$srcZip = "dist/AnabasisManager-$version.zip"
$dstZip = "dist/$archiveBase.zip"
if (-not (Test-Path $srcZip)) {
throw "Archive not found: $srcZip"
}
Copy-Item -Path $srcZip -Destination $dstZip -Force
$hash = (Get-FileHash -Path $dstZip -Algorithm SHA256).Hash.ToLower()
"$hash $archiveBase.zip" | Set-Content -Path "dist/$archiveBase.zip.sha256" -Encoding UTF8
set -euo pipefail
test -s "dist/AnabasisManager-$APP_VERSION.zip"
cp "dist/AnabasisManager-$APP_VERSION.zip" "dist/$ARCHIVE_BASE.zip"
python - "$ARCHIVE_BASE" "$APP_VERSION" <<'PY'
import sys
from pathlib import Path
from zipfile import ZipFile
- name: Configure git identity
if: env.CONTINUE == 'true'
shell: powershell
run: |
git config user.name "gitea-actions"
git config user.email "gitea-actions@daemonlord.ru"
archive = Path('dist') / f'{sys.argv[1]}.zip'
with ZipFile(archive) as package:
required = {'AnabasisManager.exe', 'AnabasisUpdater.exe', 'version.txt'}
missing = required.difference(package.namelist())
if missing:
raise SystemExit(f'Archive is missing: {sorted(missing)}')
if package.read('version.txt').decode('utf-8').strip() != sys.argv[2]:
raise SystemExit('Archive version does not match APP_VERSION')
PY
(cd dist && sha256sum "$ARCHIVE_BASE.zip" > "$ARCHIVE_BASE.zip.sha256")
(cd dist && sha256sum --check "$ARCHIVE_BASE.zip.sha256")
- name: Create git tag
if: env.CONTINUE == 'true'
shell: powershell
if: steps.check_release.outputs.publish == 'true'
shell: bash
env:
RELEASE_TAG: ${{ steps.meta.outputs.tag }}
run: |
$tag = "${{ steps.meta.outputs.tag }}"
$tagLine = (git ls-remote --tags origin "refs/tags/$tag" | Select-Object -First 1)
if ([string]::IsNullOrWhiteSpace($tagLine)) {
git tag "$tag"
git push origin "$tag"
} else {
Write-Host "Tag $tag already exists on origin, skipping tag push."
}
set -euo pipefail
if git ls-remote --exit-code --tags origin "refs/tags/$RELEASE_TAG" > /dev/null; then
git fetch origin "refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG"
test "$(git rev-parse "$RELEASE_TAG^{commit}")" = "$GITHUB_SHA"
else
git tag "$RELEASE_TAG" "$GITHUB_SHA"
git push origin "$RELEASE_TAG"
fi
- name: Create Gitea Pre-release
if: env.CONTINUE == 'true'
if: steps.check_release.outputs.publish == 'true'
uses: https://git.daemonlord.ru/actions/gitea-release-action@v1
with:
server_url: https://git.daemonlord.ru
repository: ${{ gitea.repository }}
token: ${{ secrets.API_TOKEN }}
tag_name: ${{ steps.meta.outputs.tag }}
target_commitish: ${{ gitea.sha }}
name: Anabasis Manager ${{ steps.meta.outputs.version }} (dev ${{ steps.meta.outputs.commit }})
prerelease: true
body: |
+124 -164
View File
@@ -1,14 +1,11 @@
name: Desktop Release
on:
push:
branches:
- master
workflow_dispatch:
jobs:
release:
runs-on: windows
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: https://git.daemonlord.ru/actions/checkout@v4
@@ -16,193 +13,156 @@ jobs:
fetch-depth: 0
tags: true
- name: Ensure Python 3.13
shell: powershell
run: |
if (Get-Command python -ErrorAction SilentlyContinue) {
python --version
} elseif (Get-Command py -ErrorAction SilentlyContinue) {
$pyExe = py -3.13 -c "import sys; print(sys.executable)"
if (-not $pyExe) {
throw "Python 3.13 launcher is available, but interpreter was not found."
}
Split-Path $pyExe | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
python --version
} else {
throw "Python is not installed on runner. Install Python 3.13 and restart runner service."
}
- name: Require master branch
shell: bash
run: test "$GITHUB_REF" = refs/heads/master
- name: Install dependencies
shell: powershell
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt pyinstaller
- name: Set up Python for tests
uses: https://git.daemonlord.ru/actions/setup-python@v5
with:
python-version: "3.13"
- name: Ensure Inno Setup 6
shell: powershell
- name: Read release version
id: version
shell: bash
run: |
$isccPath = ""
$inPath = Get-Command iscc.exe -ErrorAction SilentlyContinue
if ($inPath) {
$isccPath = $inPath.Source
Write-Host "Inno Setup compiler found in PATH."
} elseif (Test-Path "C:\Program Files (x86)\Inno Setup 6\ISCC.exe") {
"C:\Program Files (x86)\Inno Setup 6" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$isccPath = "C:\Program Files (x86)\Inno Setup 6\ISCC.exe"
Write-Host "Inno Setup compiler found in Program Files (x86)."
} elseif (Test-Path "C:\Program Files\Inno Setup 6\ISCC.exe") {
"C:\Program Files\Inno Setup 6" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
$isccPath = "C:\Program Files\Inno Setup 6\ISCC.exe"
Write-Host "Inno Setup compiler found in Program Files."
} else {
throw "Inno Setup 6 is not installed on runner. Install Inno Setup and restart runner service."
}
Write-Host "Using ISCC: $isccPath"
exit 0
set -euo pipefail
version="$(python -c 'from app_version import APP_VERSION; print(APP_VERSION)')"
[[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || { echo "Invalid APP_VERSION: $version"; exit 1; }
echo "value=$version" >> "$GITHUB_OUTPUT"
echo "Release version: $version"
- name: Extract app version
id: extract_version
shell: powershell
- name: Check release does not exist
id: check_release
shell: bash
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
RELEASE_TAG: v${{ steps.version.outputs.value }}
run: |
$version = (python -c "from app_version import APP_VERSION; print(APP_VERSION)").Trim()
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::AppendAllText($env:GITHUB_OUTPUT, "version=$version`n", $utf8NoBom)
Write-Host "Detected version: $version"
set -euo pipefail
test -n "$API_TOKEN" || { echo 'API_TOKEN secret is missing'; exit 1; }
status="$(curl --silent --show-error --output /dev/null --write-out '%{http_code}' \
--header "Authorization: token $API_TOKEN" \
"https://git.daemonlord.ru/api/v1/repos/${{ gitea.repository }}/releases/tags/$RELEASE_TAG")"
case "$status" in
200) echo "Release $RELEASE_TAG already exists; skipping."; echo 'publish=false' >> "$GITHUB_OUTPUT" ;;
404) echo 'publish=true' >> "$GITHUB_OUTPUT" ;;
*) echo "Cannot check release: HTTP $status"; exit 1 ;;
esac
- name: Initialize release flow
id: flow_init
shell: powershell
- name: Check Linux Docker runner
if: steps.check_release.outputs.publish == 'true'
shell: bash
run: |
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::AppendAllText($env:GITHUB_ENV, "CONTINUE=true`n", $utf8NoBom)
exit 0
set -euo pipefail
test "$(uname -m)" = x86_64
if ! command -v docker > /dev/null; then
if [ "$(id -u)" -eq 0 ]; then
apt-get update && apt-get install -y docker.io
else
sudo apt-get update && sudo apt-get install -y docker.io
fi
fi
docker info --format '{{.OSType}}' | grep -qx linux
- name: Stop if release already exists
shell: powershell
- name: Install test dependencies
if: steps.check_release.outputs.publish == 'true'
shell: bash
run: |
$version = "${{ steps.extract_version.outputs.version }}"
$tag = "v$version"
$apiUrl = "https://git.daemonlord.ru/api/v1/repos/${{ gitea.repository }}/releases?page=1&limit=100"
$headers = @{ Authorization = "token ${{ secrets.API_TOKEN }}" }
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
try {
$response = Invoke-RestMethod -Uri $apiUrl -Headers $headers -Method Get
$found = $false
foreach ($release in $response) {
if ($release.tag_name -eq $tag) {
$found = $true
break
}
}
if ($found) {
Write-Host "Release $tag already exists, stopping job."
[System.IO.File]::AppendAllText($env:GITHUB_ENV, "CONTINUE=false`n", $utf8NoBom)
} else {
Write-Host "Release $tag not found, continuing workflow..."
}
} catch {
Write-Host "Failed to query releases list, continuing workflow..."
}
set -euo pipefail
python -m pip install -r requirements.txt
- name: Run tests
if: env.CONTINUE == 'true'
shell: powershell
run: |
python -m py_compile app_version.py main.py build.py updater_gui.py tests/test_auth_relogin_smoke.py tests/test_auto_update_service.py tests/test_chat_actions.py tests/test_token_store.py
python -m unittest discover -s tests -p "test_*.py" -v
- name: Build release zip
if: env.CONTINUE == 'true'
shell: powershell
if: steps.check_release.outputs.publish == 'true'
shell: bash
env:
PYTHONUTF8: "1"
PYTHONIOENCODING: "utf-8"
QT_QPA_PLATFORM: offscreen
run: |
$ErrorActionPreference = "Continue"
$repoRoot = (git rev-parse --show-toplevel).Trim()
if (-not [string]::IsNullOrWhiteSpace($repoRoot)) {
Set-Location $repoRoot
}
$logDir = Join-Path $env:RUNNER_TEMP "anabasis-build"
New-Item -ItemType Directory -Force -Path $logDir | Out-Null
$buildLog = Join-Path $logDir "build.log"
python build.py *>&1 | Tee-Object -FilePath $buildLog
$code = $LASTEXITCODE
if ($code -ne 0) {
Write-Host "Build failed with exit code $code. Dumping build log:"
if (Test-Path $buildLog) {
Get-Content -Path $buildLog -Raw
} else {
Write-Host "Build log was not created: $buildLog"
}
exit $code
}
set -euo pipefail
python -m compileall -q app_version.py main.py build.py updater_gui.py services ui tests
python -m unittest discover -s tests -p 'test_*.py' -v
- name: Ensure artifacts exist
if: env.CONTINUE == 'true'
shell: powershell
run: |
$version = "${{ steps.extract_version.outputs.version }}"
$archivePath = "dist/AnabasisManager-$version.zip"
$installerPath = "dist/AnabasisManager-setup-$version.exe"
if (-not (Test-Path $archivePath)) {
throw "Archive not found: $archivePath"
}
if (-not (Test-Path $installerPath)) {
throw "Installer not found: $installerPath"
}
- name: Build Windows application with PyInstaller
if: steps.check_release.outputs.publish == 'true'
shell: bash
run: bash scripts/docker-build-windows.sh
- name: Generate SHA256 checksum
if: env.CONTINUE == 'true'
shell: powershell
- name: Build Windows installer with Inno Setup
if: steps.check_release.outputs.publish == 'true'
shell: bash
env:
APP_VERSION: ${{ steps.version.outputs.value }}
run: |
$version = "${{ steps.extract_version.outputs.version }}"
$archiveName = "AnabasisManager-$version.zip"
$installerName = "AnabasisManager-setup-$version.exe"
foreach ($name in @($archiveName, $installerName)) {
$path = "dist/$name"
$checksumPath = "dist/$name.sha256"
$hash = (Get-FileHash -Path $path -Algorithm SHA256).Hash.ToLower()
"$hash $name" | Set-Content -Path $checksumPath -Encoding UTF8
Write-Host "Checksum created: $checksumPath"
}
set -euo pipefail
test -f 'dist/AnabasisManager/AnabasisManager.exe'
test -f 'dist/AnabasisManager/AnabasisUpdater.exe'
bash scripts/docker-build-installer.sh "$APP_VERSION"
- name: Configure git identity
if: env.CONTINUE == 'true'
shell: powershell
- name: Verify release assets
if: steps.check_release.outputs.publish == 'true'
shell: bash
env:
APP_VERSION: ${{ steps.version.outputs.value }}
run: |
git config user.name "gitea-actions"
git config user.email "gitea-actions@daemonlord.ru"
set -euo pipefail
archive="AnabasisManager-$APP_VERSION.zip"
installer="AnabasisManager-setup-$APP_VERSION.exe"
test -s "dist/$archive"
test -s "dist/$installer"
python - "$APP_VERSION" <<'PY'
import sys
from pathlib import Path
from zipfile import ZipFile
version = sys.argv[1]
archive = Path('dist') / f'AnabasisManager-{version}.zip'
with ZipFile(archive) as package:
required = {'AnabasisManager.exe', 'AnabasisUpdater.exe', 'version.txt'}
missing = required.difference(package.namelist())
if missing:
raise SystemExit(f'Archive is missing: {sorted(missing)}')
actual_version = package.read('version.txt').decode('utf-8').strip()
if actual_version != version:
raise SystemExit(f'Archive version {actual_version} != {version}')
PY
for name in "$archive" "$installer"; do
(cd dist && sha256sum "$name" > "$name.sha256")
(cd dist && sha256sum --check "$name.sha256")
done
- name: Create git tag
if: env.CONTINUE == 'true'
shell: powershell
if: steps.check_release.outputs.publish == 'true'
shell: bash
env:
RELEASE_TAG: v${{ steps.version.outputs.value }}
run: |
$version = "${{ steps.extract_version.outputs.version }}"
$tag = "v$version"
$sha = "${{ gitea.sha }}"
$tagLine = (git ls-remote --tags origin "refs/tags/$tag" | Select-Object -First 1)
if ([string]::IsNullOrWhiteSpace($tagLine)) {
git tag -a "$tag" -m "Release $tag" "$sha"
git push origin "$tag"
} else {
Write-Host "Tag $tag already exists on origin, skipping tag push."
}
set -euo pipefail
if git ls-remote --exit-code --tags origin "refs/tags/$RELEASE_TAG" > /dev/null; then
git fetch origin "refs/tags/$RELEASE_TAG:refs/tags/$RELEASE_TAG"
test "$(git rev-parse "$RELEASE_TAG^{commit}")" = "$GITHUB_SHA" || {
echo "Tag $RELEASE_TAG points to another commit"; exit 1;
}
else
git config user.name gitea-actions
git config user.email gitea-actions@daemonlord.ru
git tag -a "$RELEASE_TAG" -m "Release $RELEASE_TAG" "$GITHUB_SHA"
git push origin "$RELEASE_TAG"
fi
- name: Create Gitea Release
if: env.CONTINUE == 'true'
if: steps.check_release.outputs.publish == 'true'
uses: https://git.daemonlord.ru/actions/gitea-release-action@v1
with:
server_url: https://git.daemonlord.ru
repository: ${{ gitea.repository }}
token: ${{ secrets.API_TOKEN }}
tag_name: v${{ steps.extract_version.outputs.version }}
tag_name: v${{ steps.version.outputs.value }}
target_commitish: ${{ gitea.sha }}
name: Anabasis Manager ${{ steps.extract_version.outputs.version }}
name: Anabasis Manager ${{ steps.version.outputs.value }}
body: |
Desktop release v${{ steps.extract_version.outputs.version }}
Desktop release v${{ steps.version.outputs.value }}
files: |
dist/AnabasisManager-${{ steps.extract_version.outputs.version }}.zip
dist/AnabasisManager-${{ steps.extract_version.outputs.version }}.zip.sha256
dist/AnabasisManager-setup-${{ steps.extract_version.outputs.version }}.exe
dist/AnabasisManager-setup-${{ steps.extract_version.outputs.version }}.exe.sha256
dist/AnabasisManager-${{ steps.version.outputs.value }}.zip
dist/AnabasisManager-${{ steps.version.outputs.value }}.zip.sha256
dist/AnabasisManager-setup-${{ steps.version.outputs.value }}.exe
dist/AnabasisManager-setup-${{ steps.version.outputs.value }}.exe.sha256