|
| 1 | +name: Build and Release AudioShelf |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build Windows App |
| 14 | + runs-on: windows-latest |
| 15 | + |
| 16 | + steps: |
| 17 | + - name: Checkout code |
| 18 | + uses: actions/checkout@v4 |
| 19 | + |
| 20 | + - name: Setup Python |
| 21 | + uses: actions/setup-python@v5 |
| 22 | + with: |
| 23 | + python-version: '3.14' |
| 24 | + cache: 'pip' |
| 25 | + |
| 26 | + - name: Install Dependencies |
| 27 | + run: | |
| 28 | + python -m pip install --upgrade pip |
| 29 | + pip install -r requirements.txt |
| 30 | + pip install pyinstaller |
| 31 | +
|
| 32 | + - name: Read Version from File |
| 33 | + id: get_version |
| 34 | + shell: powershell |
| 35 | + run: | |
| 36 | + $ver = Get-Content VERSION |
| 37 | + echo "VERSION=$ver" >> $env:GITHUB_ENV |
| 38 | + Write-Host "Detected Version: $ver" |
| 39 | +
|
| 40 | + - name: Update Changelog and Push |
| 41 | + run: | |
| 42 | + python update_changelog.py $env:VERSION |
| 43 | + |
| 44 | + git config --global user.name "GitHub Action" |
| 45 | + git config --global user.email "[email protected]" |
| 46 | + |
| 47 | + git add CHANGELOG.md |
| 48 | + git commit -m "Auto-update Changelog for version $env:VERSION [skip ci]" || Write-Host "No changes to commit" |
| 49 | + git push |
| 50 | +
|
| 51 | + - name: Generate Version Info for Exe |
| 52 | + run: | |
| 53 | + python create_version.py $env:VERSION |
| 54 | +
|
| 55 | + - name: Build with PyInstaller |
| 56 | + run: | |
| 57 | + python -m PyInstaller AudioShelf.spec |
| 58 | +
|
| 59 | + - name: Create Portable Zip |
| 60 | + run: | |
| 61 | + $ZIP_NAME = "AudioShelf-$env:VERSION-Win64-Portable.zip" |
| 62 | + |
| 63 | + New-Item -ItemType Directory -Force -Path "PortableStaging\AudioShelf" |
| 64 | + Copy-Item -Path "dist\AudioShelf\*" -Destination "PortableStaging\AudioShelf" -Recurse |
| 65 | + New-Item -Path "PortableStaging\AudioShelf\_libs\.portable" -ItemType File |
| 66 | + |
| 67 | + Compress-Archive -Path "PortableStaging\AudioShelf" -DestinationPath "$ZIP_NAME" |
| 68 | + |
| 69 | + echo "PORTABLE_ZIP_NAME=$ZIP_NAME" >> $env:GITHUB_ENV |
| 70 | +
|
| 71 | + - name: Setup NSIS |
| 72 | + run: choco install nsis |
| 73 | + |
| 74 | + - name: Build Installer |
| 75 | + run: | |
| 76 | + & "C:\Program Files (x86)\NSIS\makensis.exe" setup.nsi |
| 77 | + |
| 78 | + $SETUP_NAME = "AudioShelf-$env:VERSION-Win64-Setup.exe" |
| 79 | + |
| 80 | + if (Test-Path $SETUP_NAME) { |
| 81 | + Write-Host "Installer created: $SETUP_NAME" |
| 82 | + echo "SETUP_EXE_NAME=$SETUP_NAME" >> $env:GITHUB_ENV |
| 83 | + } else { |
| 84 | + Write-Error "Installer file not found!" |
| 85 | + exit 1 |
| 86 | + } |
| 87 | +
|
| 88 | + - name: Create GitHub Release |
| 89 | + uses: softprops/action-gh-release@v1 |
| 90 | + if: startsWith(github.ref, 'refs/tags/') |
| 91 | + with: |
| 92 | + files: | |
| 93 | + ${{ env.PORTABLE_ZIP_NAME }} |
| 94 | + ${{ env.SETUP_EXE_NAME }} |
| 95 | + body_path: CHANGELOG.md |
| 96 | + env: |
| 97 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments