Skip to content

Update build_and_package.yml #8

Update build_and_package.yml

Update build_and_package.yml #8

name: Build and Package PyGitHubRipper
on:
push:
branches:
- main
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyinstaller requests beautifulsoup4 streamlit
- name: Clean up old build artifacts
run: |
if (Test-Path -Path dist) { Remove-Item -Recurse -Force dist }
if (Test-Path -Path build) { Remove-Item -Recurse -Force build }
if (Test-Path -Path __pycache__) { Remove-Item -Recurse -Force __pycache__ }
if (Test-Path -Path launch.spec) { Remove-Item -Force launch.spec }
if (Test-Path -Path launch.exe) { Remove-Item -Force launch.exe }
if (Test-Path -Path builds) { Remove-Item -Recurse -Force builds }
if (Test-Path -Path icon.ico) { Remove-Item -Force icon.ico }
- name: Copy icon
run: |
Copy-Item .\icons\icon.png .\icon.ico
- name: Build launch.exe
run: |
pyinstaller --onefile --icon=icon.ico launch.py
Move-Item -Path dist\launch.exe -Destination .\launch.exe
- 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: Create builds directory
run: |
New-Item -ItemType Directory -Force -Path builds
- name: Package files
run: |
Compress-Archive -Path launch.exe,git-ripperv3.py -DestinationPath builds\PyGitHubRipper-v-${{ steps.increment_version.outputs.new_version }}.zip
- name: Commit changes
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
git add .
git commit -m "Build and package version ${{ steps.increment_version.outputs.new_version }}"
git tag "v${{ steps.increment_version.outputs.new_version }}"
git push origin main --tags
- name: Final clean up
run: |
if (Test-Path -Path dist) { Remove-Item -Recurse -Force dist }
if (Test-Path -Path build) { Remove-Item -Recurse -Force build }
if (Test-Path -Path __pycache__) { Remove-Item -Recurse -Force __pycache__ }
if (Test-Path -Path launch.spec) { Remove-Item -Force launch.spec }
if (Test-Path -Path launch.exe) { Remove-Item -Force launch.exe }
if (Test-Path -Path icon.ico) { Remove-Item -Force icon.ico }