Update build_and_package.yml #28
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Package Streamlit App | |
on: | |
push: | |
branches: | |
- main # ajuste conforme sua branch principal | |
jobs: | |
build: | |
runs-on: windows-latest | |
steps: | |
- name: Clean up old build artifacts | |
run: | | |
Remove-Item -Recurse -Force dist -ErrorAction SilentlyContinue | |
Remove-Item -Recurse -Force builds -ErrorAction SilentlyContinue | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' # ajuste conforme sua versão de Python | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
python -m pip install pyinstaller requests beautifulsoup4 streamlit | |
- name: Build launch.exe with PyInstaller | |
run: | | |
pyinstaller --onefile --icon=icon.ico launch.py | |
$buildsDir = "builds" | |
if (!(Test-Path $buildsDir)) { | |
New-Item -ItemType Directory -Force -Path $buildsDir | |
} | |
Move-Item -Path dist\launch.exe -Destination "$buildsDir\launch.exe" -Force | |
- name: Increment version | |
id: increment_version | |
run: | | |
$versionFile = "VERSION" | |
if (Test-Path $versionFile) { | |
$version = Get-Content $versionFile | |
} else { | |
$version = "0.0.0" | |
} | |
$addr = $version -split '\.' | |
$patch = [int]$addr[2] + 1 | |
$newVersion = "$($addr[0]).$($addr[1]).$patch" | |
$newVersion > $versionFile | |
echo "::set-output name=new_version::$newVersion" | |
- name: Package files | |
run: | | |
$zipFileName = "PyStreamlitApp-v-${{ steps.increment_version.outputs.new_version }}.zip" | |
Compress-Archive -Path "builds\launch.exe" -DestinationPath $zipFileName | |
- name: Configure Git | |
run: | | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
- name: Pull latest changes | |
run: git pull origin main | |
- name: Commit and push application files | |
if: success() | |
run: | | |
git add $zipFileName | |
git commit -m "Add executable zip for version ${{ steps.increment_version.outputs.new_version }}" | |
git push origin main |