Files
WinDeckHelper/.github/workflows/main.yml
T
Kvintilyanov Aleksandr 5b3e9adbdf Update main.yml
2025-03-13 14:24:53 +03:00

106 lines
3.9 KiB
YAML

name: Build and Deploy
on:
workflow_dispatch: # Ручной запуск
push:
branches:
- main # Запуск при пуше в ветку main
pull_request:
types: [opened, synchronize] # Запуск при создании или обновлении PR
release:
types: [published] # Запуск при создании релиза вручную через интерфейс GitHub
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install WinRAR
run: |
choco install winrar -y
- name: Create self-extracting archive with WinRAR
run: |
$archiveName = "WindeckHelper.exe"
$sourceFiles = Get-ChildItem -Path . -Recurse -Exclude .git, .github | ForEach-Object { $_.FullName }
$iconPath = Resolve-Path -Path "Windeckicon.ico" # Полный путь к иконке
$sfxConfig = @"
Path=%TEMP%\Windeckhelper
Silent=1
Overwrite=1
Setup=PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& .\Windeckhelper.ps1"
TempMode=1
Title=WindeckHelper Installer
Icon=$iconPath
"@
Set-Content -Path "sfxconfig.txt" -Value $sfxConfig
& "C:\Program Files\WinRAR\WinRAR.exe" a -r -sfx -iicon"$iconPath" -z"sfxconfig.txt" -ep1 $archiveName $sourceFiles
Remove-Item -Path "sfxconfig.txt"
- name: Verify installer creation
run: |
$archiveName = "WindeckHelper.exe"
if (-Not (Test-Path -Path $archiveName)) {
Write-Error "Установщик не создан!"
exit 1
}
- name: Upload artifact (for push or PR)
if: github.event_name == 'push' || github.event_name == 'pull_request'
uses: actions/upload-artifact@v4
with:
name: WindeckHelper.exe
path: WindeckHelper.exe
release:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'workflow_dispatch' || github.event_name == 'release' # Только для ручного запуска или создания релиза
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Get release version
id: get_version
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
# Если workflow запущен вручную, создаём новую версию
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
VERSION=$(echo $LATEST_TAG | awk -F. '{printf "v%d.%d.%d", $1, $2, $3+1}')
else
# Если релиз создан вручную через интерфейс GitHub, используем его версию
VERSION="${{ github.event.release.tag_name }}"
fi
echo "Version: $VERSION"
echo "::set-output name=version::$VERSION"
- name: Rename archive to include version
run: |
mv WindeckHelper.exe "WindeckHelper-${{ steps.get_version.outputs.version }}.exe"
- name: Create release (only for workflow_dispatch)
if: github.event_name == 'workflow_dispatch'
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.version }}
release_name: Release ${{ steps.get_version.outputs.version }}
draft: false
prerelease: false
- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url || steps.create_release.outputs.upload_url }}
asset_path: WindeckHelper-${{ steps.get_version.outputs.version }}.exe
asset_name: WindeckHelper-${{ steps.get_version.outputs.version }}.exe
asset_content_type: application/octet-stream