Skip to content

Workflow file for this run

name: Build and Release Python Executable
on:
push:
branches:
- main
jobs:
build:
runs-on: ${{ matrix.os }}
outputs:
python_changed: ${{ steps.check_python.outputs.python_changed }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Checkout repository
run: |
git clone https://github.com/RetroCyber/thcrap_patch_mirror.git
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Check for Python changes
id: check_python
shell: bash
run: |
cd thcrap_patch_mirror
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q '\.py$' ; then
echo "Python files were changed."
echo "python_changed=true" >> $GITHUB_OUTPUT
else
echo "No Python files were changed."
echo "python_changed=false" >> $GITHUB_OUTPUT
fi
- name: Install dependencies
if: steps.check_python.outputs.python_changed == 'true'
run: |
cd thcrap_patch_mirror
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller
- name: Build executables
if: steps.check_python.outputs.python_changed == 'true'
run: |
cd thcrap_patch_mirror
pyinstaller --onefile add_patch.py
pyinstaller --onefile mirror_repo.py
- name: Package executables on Windows
if: runner.os == 'Windows'
run: |
mkdir -p dist/win
Move-Item -Path 'dist/add_patch.exe', 'dist/mirror_repo.exe' -Destination 'dist/win/'
shell: pwsh
working-directory: thcrap_patch_mirror
- name: Package executables on Linux
if: runner.os == 'Linux'
run: |
mkdir -p dist/linux
mv dist/add_patch dist/mirror_repo dist/linux/
shell: bash
working-directory: thcrap_patch_mirror
- name: Package executables on macOS
if: runner.os == 'macOS'
run: |
mkdir -p dist/macos
mv dist/add_patch dist/mirror_repo dist/macos/
shell: bash
working-directory: thcrap_patch_mirror
- name: Set Platform Name
id: set_platform_name
run: |
PLATFORM_NAME="${{ matrix.os }}"
if [[ "${PLATFORM_NAME}" == "ubuntu-latest" ]]; then
PLATFORM_NAME="linux"
elif [[ "${PLATFORM_NAME}" == "windows-latest" ]]; then
PLATFORM_NAME="win"
elif [[ "${PLATFORM_NAME}" == "macos-latest" ]]; then
PLATFORM_NAME="macos"
fi
echo "PLATFORM_NAME=${PLATFORM_NAME}" >> $GITHUB_ENV
shell: bash
- name: Upload Package
if: steps.check_python.outputs.python_changed == 'true'
uses: actions/upload-artifact@v4
with:
name: thpatch_mirror-${{ env.PLATFORM_NAME }}
path: |
thcrap_patch_mirror/dist/win/*
thcrap_patch_mirror/dist/linux/*
thcrap_patch_mirror/dist/macos/*
release:
runs-on: ubuntu-latest
needs: build
if: ${{ needs.build.outputs.python_changed }} == 'true'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
- run: ls -l dist
# - name: Download win
# uses: actions/download-artifact@v4
# with:
# name: thpatch_mirror-win
# - name: Download linux
# uses: actions/download-artifact@v4
# with:
# name: thpatch_mirror-linux
# - name: Download macOS
# uses: actions/download-artifact@v4
# with:
# name: thpatch_mirror-macos
# - name: Create Release
# uses: softprops/action-gh-release@v2
# with:
# files: |
# thpatch_mirror-win.zip
# thpatch_mirror-linux.zip
# thpatch_mirror-macos.zip
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}