name: Release on: push: branches: [master] workflow_dispatch: concurrency: group: release cancel-in-progress: false jobs: release: # Пропускаем коммиты от CI (bump версии) if: "!contains(github.event.head_commit.message, '[skip ci]')" runs-on: docker container: image: electronuserland/builder:wine env: API: https://git.vodyanoysh.ru/api/v1/repos/vodyanoy/aero-mail steps: - name: Checkout (full history for tags) uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Save release notes (commit message) run: | git config --global --add safe.directory "$GITHUB_WORKSPACE" git log -1 --format=%B > /tmp/release-notes.txt - name: Determine next version id: version run: node .forgejo/version.js - name: Install dependencies run: npm ci - name: Set release version env: VERSION: ${{ steps.version.outputs.version }} run: npm version "${VERSION}" --no-git-tag-version --allow-same-version - name: Check types run: npm run typecheck - name: Run tests run: | npm run test:agent npm run test:realtime npm run test:compose npm run test:navigation - name: Build application run: npm run build - name: Build Linux AppImage timeout-minutes: 20 run: npx electron-builder --linux --x64 --publish=never - name: Check Linux artifacts env: VERSION: ${{ steps.version.outputs.version }} run: test -s "dist/aero-mail-${VERSION}.AppImage" - name: Build Windows installer timeout-minutes: 20 env: DEBUG: electron-builder run: npx electron-builder --win --x64 --publish=never - name: Check Windows artifacts env: VERSION: ${{ steps.version.outputs.version }} run: | test -s "dist/aero-mail-${VERSION}-win-x64.exe" test -s "dist/aero-mail-${VERSION}-win-x64.exe.blockmap" test -s dist/latest.yml - name: Commit version and create tag env: VERSION: ${{ steps.version.outputs.version }} TAG: ${{ steps.version.outputs.tag }} GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | git config user.email "ci@vodyanoysh.ru" git config user.name "Forgejo CI" git remote set-url origin "https://x-token:${GIT_TOKEN}@git.vodyanoysh.ru/vodyanoy/aero-mail.git" git add package.json package-lock.json git diff --cached --quiet || git commit -m "Обновлена версия до ${VERSION} [skip ci]" git push origin master git tag "${TAG}" git push origin "${TAG}" - name: Create Forgejo release id: release env: TAG: ${{ steps.version.outputs.tag }} TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | # Тело релиза — сообщение коммита, сохранённое до коммита версии PAYLOAD=$(node -e 'const fs = require("fs"); console.log(JSON.stringify({ tag_name: process.env.TAG, name: "Aero Mail " + process.env.TAG, body: fs.readFileSync("/tmp/release-notes.txt", "utf8").trim(), draft: false, prerelease: false }))') RELEASE=$(curl -sf -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/json" \ -d "${PAYLOAD}" \ "${API}/releases") RELEASE_ID=$(printf '%s' "$RELEASE" | node -e 'let input = ""; process.stdin.on("data", chunk => { input += chunk }); process.stdin.on("end", () => { const release = JSON.parse(input); if (!Number.isSafeInteger(release.id)) throw new Error("Некорректный ID релиза"); process.stdout.write(String(release.id)) })') printf '%s' "${RELEASE_ID}" > /tmp/release-id.txt - name: Upload Linux and Windows release files env: TOKEN: ${{ secrets.GITHUB_TOKEN }} VERSION: ${{ steps.version.outputs.version }} run: | RELEASE_ID=$(cat /tmp/release-id.txt) # Только цифры: защита от ANSI-цветов (FORCE_COLOR) и прочего мусора printf '%s' "${RELEASE_ID}" | grep -qxE '[0-9]+' || { echo "Некорректный ID релиза: $(printf '%s' "${RELEASE_ID}" | od -c)"; exit 1; } for ASSET_PATH in "dist/aero-mail-${VERSION}.AppImage" "dist/aero-mail-${VERSION}-win-x64.exe" "dist/aero-mail-${VERSION}-win-x64.exe.blockmap" dist/latest.yml; do ASSET_NAME=$(basename "${ASSET_PATH}") URL="${API}/releases/${RELEASE_ID}/assets?name=${ASSET_NAME}" curl --globoff --fail-with-body --silent --show-error -X POST \ -H "Authorization: token ${TOKEN}" \ -H "Content-Type: application/octet-stream" \ --data-binary @"${ASSET_PATH}" \ "${URL}" done