Skip to content

Pack Python application #64

Pack Python application

Pack Python application #64

Workflow file for this run

name: Pack Python application
on:
push:
paths-ignore:
- '**.md'
- 'LICENSE'
workflow_dispatch:
inputs:
doRelease:
description: 'Publish new release'
type: boolean
default: false
required: false
jobs:
build:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: mkdir dist
run: |
mkdir dist > $null
- name: Update BBDown_GUI version
run: |
$version = ""
if ( $${{ github.event.inputs.doRelease == 'true' }} ) {
$version = "$(git describe --tags --abbrev=0)"
} else {
$version = "$(git describe --tags --always)"
}
Write-Host BBDown_GUI-Version: $version
# Replace BBDown_GUI version in ui_about.py
$filePath = "./BBDown_GUI/UI/ui_about.py"
(Get-Content $filePath) | Foreach-Object {$_ -replace '\$bbdown-gui-version\$', "$version"} | Set-Content $filePath
- name: Update FFmpeg version
run: |
# Get latest ffmpeg version and website
$url = "https://api.github.com/repos/BtbN/FFmpeg-Builds/releases/latest"
$response = Invoke-WebRequest -Uri $url | ConvertFrom-Json
$version = $response.name
$tag = $version
$tag = $tag.Replace("Latest Auto-Build (", "autobuild-")
$tag = $tag.Replace(" ", "-")
$tag = $tag.Replace(":", "-")
$tag = $tag.Replace(")", "")
$website = "https://github.com/BtbN/FFmpeg-Builds/releases/tag/$tag"
Write-Host FFmpeg-Version: $version
Write-Host FFmpeg-Version-Website: $website
# Replace ffmpeg version in ui_about.py
$filePath = "./BBDown_GUI/UI/ui_about.py"
(Get-Content $filePath) | Foreach-Object {$_ -replace '\$ffmpeg-version\$', "$version"} | Set-Content $filePath
(Get-Content $filePath) | Foreach-Object {$_ -replace '\$ffmpeg-version-url\$', "$website"} | Set-Content $filePath
# Download ffmpeg
mkdir temp > $null
$browser_download_url = "https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip"
Write-Host FFmpeg-Download-Url: $browser_download_url
Invoke-WebRequest -Uri $browser_download_url -OutFile temp/ffmpeg-master-latest-win64-gpl.zip
Expand-Archive -Path temp/ffmpeg-master-latest-win64-gpl.zip -DestinationPath ./temp
mv temp/ffmpeg-master-latest-win64-gpl/bin/ffmpeg.exe dist/ffmpeg.exe
Remove-Item -Recurse -Force ./temp
- name: Update BBDown version
run: |
# Get latest BBDown version and website
$url = "https://api.github.com/repos/nilaoda/BBDown/releases/latest"
$response = Invoke-WebRequest -Uri $url | ConvertFrom-Json
$version = $response.name
$website = $response.html_url
Write-Host BBDown-Version: $version
Write-Host BBDown-Version-Website: $website
# Replace BBDown version in ui_about.py
$filePath = "./BBDown_GUI/UI/ui_about.py"
(Get-Content $filePath) | Foreach-Object {$_ -replace '\$bbdown-version\$', "$version"} | Set-Content $filePath
(Get-Content $filePath) | Foreach-Object {$_ -replace '\$bbdown-version-url\$', "$website"} | Set-Content $filePath
# Download BBDown
mkdir temp > $null
$url = "https://api.github.com/repos/nilaoda/BBDown/releases/latest"
$response = Invoke-WebRequest -Uri $url | ConvertFrom-Json
$asset = $response.assets | Where-Object { $_.name -like "*win-x64*" }
$browser_download_url = $asset.browser_download_url
Write-Host BBDown-Download-Url: $browser_download_url
Invoke-WebRequest -Uri $browser_download_url -OutFile temp/BBDown_win-x64.zip
Expand-Archive -Path temp/BBDown_win-x64.zip -DestinationPath ./temp
mv temp/BBDown.exe dist/BBDown.exe
Remove-Item -Recurse -Force ./temp
- name: Update aria2 version
run: |
# Get latest aria2 version and website
$url = "https://api.github.com/repos/aria2/aria2/releases/latest"
$response = Invoke-WebRequest -Uri $url | ConvertFrom-Json
$version = $response.name
$website = $response.html_url
Write-Host Aria2-Version: $version
Write-Host Aria2-Version-Website: $website
# Replace aria2 version in ui_about.py
$filePath = "./BBDown_GUI/UI/ui_about.py"
(Get-Content $filePath) | Foreach-Object {$_ -replace '\$aria2c-version\$', "$version"} | Set-Content $filePath
(Get-Content $filePath) | Foreach-Object {$_ -replace '\$aria2c-version-url\$', "$website"} | Set-Content $filePath
# Download aria2
mkdir temp > $null
$url = "https://api.github.com/repos/aria2/aria2/releases/latest"
$response = Invoke-WebRequest -Uri $url | ConvertFrom-Json
$asset = $response.assets | Where-Object { $_.name -like "*win-64bit*" }
$browser_download_url = $asset.browser_download_url
Write-Host Aria2-Download-Url: $browser_download_url
Invoke-WebRequest -Uri $browser_download_url -OutFile temp/aria2-win-64bit.zip
Expand-Archive -Path temp/aria2-win-64bit.zip -DestinationPath ./temp
mv temp/aria2-*/aria2c.exe dist/aria2c.exe
Remove-Item -Recurse -Force ./temp
- name: Set up Python 3.10
uses: actions/setup-python@v3
with:
python-version: "3.10"
- name: Install dependencies
run: |
pip install -r requirements.txt
pip install pyinstaller
- name: build py to exe
run: |
pyinstaller --noconfirm --onefile --noconsole --icon "./BBDown_GUI/UI/favicon.ico" --add-data "./BBDown_GUI/UI/favicon.ico;./UI" "./build-to-exe.py"
mv ./dist/build-to-exe.exe ./dist/BBDown_GUI.exe
- name: Upload a Build Artifact (Full)
uses: actions/upload-artifact@v3.1.2
with:
name: BBDown_GUI
path: dist
- name: Upload a Build Artifact (Single File)
uses: actions/upload-artifact@v3.1.2
with:
name: BBDown_GUI_single_file
path: dist/BBDown_GUI.exe
- name: Compress the Full
if: ${{ github.event.inputs.doRelease == 'true' }}
run: |
Compress-Archive -Path dist/* -DestinationPath ./BBDown_GUI_Full.zip
- name: GH Release
if: ${{ github.event.inputs.doRelease == 'true' }}
uses: softprops/action-gh-release@v0.1.15
with:
files: |
dist/BBDown_GUI.exe
BBDown_GUI_Full.zip
draft: true
generate_release_notes: true