Files
AnabasisChatRemove/.gitea/workflows/release-dev.yml
T
benya bb6de9b737
Desktop CI / tests (push) Failing after 1m51s
Prepare 2.3.0 release and Linux Docker workflows
2026-09-25 14:02:32 +03:00

152 lines
5.8 KiB
YAML

name: Desktop Dev Pre-release
on:
push:
branches:
- dev
workflow_dispatch:
jobs:
prerelease:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: https://git.daemonlord.ru/actions/checkout@v4
with:
fetch-depth: 0
tags: true
- name: Set up Python for tests
uses: https://git.daemonlord.ru/actions/setup-python@v5
with:
python-version: "3.13"
- name: Read prerelease metadata
id: meta
shell: bash
run: |
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: Check prerelease does not exist
id: check_release
shell: bash
env:
API_TOKEN: ${{ secrets.API_TOKEN }}
RELEASE_TAG: ${{ steps.meta.outputs.tag }}
run: |
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: steps.check_release.outputs.publish == 'true'
shell: bash
env:
QT_QPA_PLATFORM: offscreen
run: |
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 Windows application with PyInstaller
if: steps.check_release.outputs.publish == 'true'
shell: bash
run: bash scripts/docker-build-windows.sh
- 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: |
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
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: steps.check_release.outputs.publish == 'true'
shell: bash
env:
RELEASE_TAG: ${{ steps.meta.outputs.tag }}
run: |
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: 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: |
Development pre-release for commit ${{ steps.meta.outputs.commit }}
Version base: ${{ steps.meta.outputs.version }}
files: |
dist/${{ steps.meta.outputs.archive }}.zip
dist/${{ steps.meta.outputs.archive }}.zip.sha256