Skip to content

Автоматическая сборка раз в три дня #122

Автоматическая сборка раз в три дня

Автоматическая сборка раз в три дня #122

Workflow file for this run

name: Автоматическая сборка раз в три дня
on:
push:
paths: ['.github/workflows/build.yml']
schedule:
- cron: '0 0 */3 * *'
workflow_dispatch:
env:
PYTHONIOENCODING: utf-8
permissions:
contents: write
jobs:
build:
name: Сборка проекта
runs-on: windows-latest
env:
PYTHONUTF8: 1
steps:
- name: Копирование кода
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref || github.ref_name }}
fetch-depth: 2
- name: Получение даты и времени
id: datetime
shell: powershell
run: |
$current_time = Get-Date -Format "dd.MM.yyyy HH:mm"
echo "build_time=$current_time" >> $env:GITHUB_OUTPUT
- name: Проверка изменений в rus-python
id: check_changes
shell: bash
run: |
if [ "${{ github.event_name }}" = "push" ]; then
changed=$(git diff --name-only HEAD~1 HEAD -- rus-python/)
if [ -n "$changed" ]; then
echo "rus-python changed - will bump"
echo "should_bump=true" >> $GITHUB_OUTPUT
else
echo "rus-python not changed - skip bump"
echo "should_bump=false" >> $GITHUB_OUTPUT
fi
else
echo "Trigger: ${{ github.event_name }} - skip bump"
echo "should_bump=false" >> $GITHUB_OUTPUT
fi
- name: Установка Python 3.13
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Запуск скрипта сборки (build.py)
run: python build.py
- name: Проверка работоспособности параметров. 1 часть
env:
PYTHONUTF8: "1"
run: |
dist/rupython.exe --install ursina
- name: Проверка работоспособности параметров. 2 часть
env:
PYTHONUTF8: "1"
run: |
dist/rupython.exe test.rupy --build --icon icon.ico --name test --add-data "test.rupy;test.py"
- name: Clean build artifact
run: rm -f dist/test.exe
shell: bash
- name: Установка Node.js (для сборки VS Code расширения)
uses: actions/setup-node@v4
with:
node-version: 20
- name: Сборка расширения VS Code и автоповышение версии
id: vsce_setup
shell: powershell
run: |
[Console]::OutputEncoding = [System.Text.Encoding]::UTF8
$OutputEncoding = [System.Text.Encoding]::UTF8
npm install -g @vscode/vsce
cd rus-python
$json = Get-Content package.json -Raw -Encoding utf8 | ConvertFrom-Json
$shouldBump = "${{ steps.check_changes.outputs.should_bump }}"
if ($json.version) {
$versionParts = $json.version.Split('.')
if ($versionParts.Count -eq 3 -and $shouldBump -eq "true") {
$major = [int]$versionParts[0]
$minor = [int]$versionParts[1]
$patch = [int]$versionParts[2] + 1
$json.version = "${major}.${minor}.${patch}"
Write-Host "Новая версия расширения: $($json.version)"
} else {
Write-Host "Версия не изменена: $($json.version)"
}
} else {
$json | Add-Member -NotePropertyName "version" -NotePropertyValue "1.0.0"
}
echo "ext_version=$($json.version)" >> $env:GITHUB_OUTPUT
if ($json.name -match "suscersal\.") {
$json.name = $json.name -replace "suscersal\.", ""
}
$json.name = $json.name.ToLower()
if (-not $json.publisher) { $json | Add-Member -NotePropertyName "publisher" -NotePropertyValue "suscersal" }
if (-not $json.repository) { $json | Add-Member -NotePropertyName "repository" -NotePropertyValue @{ type = "git"; url = "https://github.com" } }
$jsonString = $json | ConvertTo-Json -Depth 10
$utf8NoBom = New-Object System.Text.UTF8Encoding($false)
[System.IO.File]::WriteAllText((Get-Item package.json).FullName, $jsonString, $utf8NoBom)
[System.IO.File]::WriteAllText((Join-Path (Get-Location) "LICENSE"), "MIT License", $utf8NoBom)
vsce package --no-dependencies
- name: Коммит и Пуш новой версии в репозиторий
shell: powershell
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add rus-python/package.json
$status = git status --porcelain
if ($status) {
git commit -m "chore: bump extension version to ${{ steps.vsce_setup.outputs.ext_version }} [skip ci]"
git push origin HEAD:${{ github.head_ref || github.ref_name }}
} else {
Write-Host "Изменений в package.json не обнаружено."
}
- name: Публикация в VS Code Marketplace
continue-on-error: true
shell: powershell
run: |
cd rus-python
vsce publish --no-dependencies
env:
VSCE_TOKEN: ${{ secrets.VSCE_TOKEN }}
- name: Компиляция инсталлятора (Inno Setup)
run: |
iscc setup.iss
- name: Сохранение готовых файлов в артефакты
if: always()
uses: actions/upload-artifact@v4
with:
name: rupython-artifacts
path: |
dist/
!dist/test.exe
Setup_Build/rupyInstaller.exe
*.exe
*.log
rus-python/*.vsix
if-no-files-found: warn
- name: Создать Релиз и загрузить файлы
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'push'
with:
tag_name: ${{ startsWith(github.ref, 'refs/tags/') && github.ref_name || format('auto-{0}', github.sha) }}
name: ${{ startsWith(github.ref, 'refs/tags/') && format('Релиз {0}', github.ref_name) || format('Автосборка от {0}', steps.datetime.outputs.build_time) }}
generate_release_notes: true
body: |
### Автоматическая сборка проекта
**Информация о сборке:**
- **Дата и время:** ${{ steps.datetime.outputs.build_time }} (UTC раннера)
- **Триггер:** ${{ github.event_name }}
- **Коммит:** ${{ github.sha }}
- **Версия расширения VS Code:** ${{ steps.vsce_setup.outputs.ext_version }}
---
### Что нового:
draft: false
prerelease: ${{ github.event_name != 'create' }}
files: |
dist/*.exe
Setup_Build/rupyInstaller.exe
!dist/test.exe
rus-python/*.vsix
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}