mirror of
https://github.com/barkeser2002/VMD-Motion-Optimizer.git
synced 2026-09-25 01:50:14 +03:00
pytest artık derlemeden önce çalışan ayrı bir iş; pull request'lerde de. Compress-Archive "dist/VMDOptimizer/*" yerine "dist/VMDOptimizer": arşivin kökünde tek bir klasör oluyor. Önceden "Extract Here" diyen kullanıcı VMDOptimizer.exe ile birlikte ~700 dosyalık _internal ağacını Downloads klasörüne saçıyordu. Sürüm değişmediyse yayın adımı atlanıyor. Önceden bir README düzeltmesi workflow'u tetikliyor, tag zaten var diye atlanıyor ama release yine de güncellenip mevcut ZIP'in yerine BAŞKA bir commit'ten derlenmiş bir ZIP konuyordu. Ek olarak: SHA256 sağlama dosyası, generate_release_notes, fail_on_unmatched_files, exe üretildi mi kontrolü, pip önbelleği ve arka arkaya push'larda tag çakışmasını önleyen concurrency grubu. ~700 dosyalık ham dist ağacının artifact'a yüklenmesi kaldırıldı.
154 lines
5.0 KiB
YAML
154 lines
5.0 KiB
YAML
name: Release
|
||
|
||
on:
|
||
push:
|
||
branches: [ main, master ]
|
||
paths:
|
||
- 'version.txt'
|
||
- 'scripts/**'
|
||
- 'tests/**'
|
||
- 'README*'
|
||
- 'requirements.txt'
|
||
- 'requirements-dev.txt'
|
||
- 'build_exe.bat'
|
||
- 'build_exe.ps1'
|
||
- 'logo.png'
|
||
- 'icon.ico'
|
||
- '.github/workflows/release.yml'
|
||
pull_request:
|
||
branches: [ main, master ]
|
||
workflow_dispatch:
|
||
|
||
permissions:
|
||
contents: write
|
||
|
||
# Arka arkaya iki push'ta ikinci "git push origin <tag>" çakışıp işi düşürüyordu
|
||
concurrency:
|
||
group: release-${{ github.ref }}
|
||
cancel-in-progress: false
|
||
|
||
jobs:
|
||
test:
|
||
runs-on: windows-latest
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
|
||
- name: Set up Python
|
||
uses: actions/setup-python@v5
|
||
with:
|
||
python-version: '3.12'
|
||
cache: 'pip'
|
||
|
||
- name: Install dependencies
|
||
run: |
|
||
python -m pip install --upgrade pip
|
||
pip install -r requirements.txt -r requirements-dev.txt
|
||
|
||
- name: Run tests
|
||
env:
|
||
QT_QPA_PLATFORM: offscreen
|
||
run: python -m pytest tests -q
|
||
|
||
build-and-release:
|
||
needs: test
|
||
if: github.event_name != 'pull_request'
|
||
runs-on: windows-latest
|
||
steps:
|
||
- name: Checkout
|
||
uses: actions/checkout@v4
|
||
with:
|
||
fetch-depth: 0
|
||
|
||
- name: Set up Python
|
||
uses: actions/setup-python@v5
|
||
with:
|
||
python-version: '3.12'
|
||
cache: 'pip'
|
||
|
||
- name: Install dependencies
|
||
run: |
|
||
python -m pip install --upgrade pip
|
||
pip install -r requirements.txt -r requirements-dev.txt
|
||
|
||
- name: Read version
|
||
id: ver
|
||
shell: bash
|
||
run: |
|
||
VER=$(cat version.txt | tr -d '\r\n')
|
||
echo "version=$VER" >> $GITHUB_OUTPUT
|
||
if git rev-parse "v$VER" >/dev/null 2>&1; then
|
||
echo "Tag v$VER already exists - release will be skipped"
|
||
echo "is_new=false" >> $GITHUB_OUTPUT
|
||
else
|
||
echo "is_new=true" >> $GITHUB_OUTPUT
|
||
fi
|
||
|
||
- name: Create tag
|
||
if: steps.ver.outputs.is_new == 'true'
|
||
shell: bash
|
||
run: |
|
||
TAG="v${{ steps.ver.outputs.version }}"
|
||
git config user.name "github-actions"
|
||
git config user.email "github-actions@github.com"
|
||
git tag "$TAG"
|
||
git push origin "$TAG"
|
||
|
||
- name: Build (PyInstaller)
|
||
shell: pwsh
|
||
run: |
|
||
$opts = @('--noconfirm','--clean','--name','VMDOptimizer','--onedir','--windowed')
|
||
$extra = @('--add-data','scripts;scripts','--add-data','version.txt;.')
|
||
if (Test-Path 'logo.png') { $extra += @('--add-data','logo.png;.') }
|
||
if (Test-Path 'icon.ico') { $extra += @('--add-data','icon.ico;.','--icon','icon.ico') }
|
||
python -m PyInstaller @opts @extra scripts/app.py
|
||
if ($LASTEXITCODE -ne 0) { throw "PyInstaller failed with $LASTEXITCODE" }
|
||
|
||
- name: Smoke test built exe
|
||
shell: pwsh
|
||
run: |
|
||
if (-not (Test-Path 'dist/VMDOptimizer/VMDOptimizer.exe')) {
|
||
throw "VMDOptimizer.exe üretilmedi"
|
||
}
|
||
|
||
- name: Archive build as ZIP
|
||
shell: pwsh
|
||
run: |
|
||
$ver = '${{ steps.ver.outputs.version }}'
|
||
$zip = "VMDOptimizer-$ver.zip"
|
||
if (Test-Path $zip) { Remove-Item $zip -Force }
|
||
# "dist/VMDOptimizer" (sonunda /* YOK): arşivin kökünde tek bir klasör
|
||
# olsun. Aksi halde "Extract Here" ~700 dosyayı Downloads'a saçıyordu.
|
||
Compress-Archive -Path "dist/VMDOptimizer" -DestinationPath $zip
|
||
(Get-FileHash $zip -Algorithm SHA256).Hash.ToLower() + " " + $zip |
|
||
Out-File -FilePath "$zip.sha256" -Encoding ascii
|
||
|
||
- name: Upload artifact (workflow)
|
||
uses: actions/upload-artifact@v4
|
||
with:
|
||
name: VMDOptimizer-${{ steps.ver.outputs.version }}
|
||
path: |
|
||
VMDOptimizer-${{ steps.ver.outputs.version }}.zip
|
||
VMDOptimizer-${{ steps.ver.outputs.version }}.zip.sha256
|
||
|
||
- name: Create GitHub Release
|
||
# Sürüm değişmediyse yayınlama: bir README düzeltmesi, farklı bir
|
||
# commit'ten derlenmiş ZIP ile mevcut sürümün varlığını değiştiriyordu.
|
||
if: steps.ver.outputs.is_new == 'true'
|
||
uses: softprops/action-gh-release@v2
|
||
with:
|
||
tag_name: v${{ steps.ver.outputs.version }}
|
||
name: VMD Motion Optimizer by Barış Keser (barkeser2002) v${{ steps.ver.outputs.version }}
|
||
generate_release_notes: true
|
||
fail_on_unmatched_files: true
|
||
body: |
|
||
VMD Motion Optimizer by Barış Keser (barkeser2002)
|
||
|
||
**Kurulum:** ZIP'i indirin, açın ve `VMDOptimizer/VMDOptimizer.exe` dosyasını çalıştırın.
|
||
Kullanım için README'ye bakın. `.sha256` dosyası ile indirmeyi doğrulayabilirsiniz.
|
||
files: |
|
||
VMDOptimizer-${{ steps.ver.outputs.version }}.zip
|
||
VMDOptimizer-${{ steps.ver.outputs.version }}.zip.sha256
|
||
env:
|
||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|