From 165c281da97965ac21144b7d4c96ca6992602798 Mon Sep 17 00:00:00 2001 From: wling Date: Fri, 9 Feb 2024 13:55:20 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20=E5=B0=9D=E8=AF=95=E7=BC=93?= =?UTF-8?q?=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build_and_release.yml | 81 +++++++++++++++++++------ 1 file changed, 63 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build_and_release.yml b/.github/workflows/build_and_release.yml index 2334fc7e..7e29e446 100644 --- a/.github/workflows/build_and_release.yml +++ b/.github/workflows/build_and_release.yml @@ -8,47 +8,92 @@ on: workflow_dispatch: {} jobs: - build: - name: Build and Release - runs-on: ${{ matrix.os }} - - strategy: - matrix: - os: [windows-latest, ubuntu-latest] - python-version: ["3.11"] + build_windows: + name: Build and Release for Windows + runs-on: windows-latest steps: - name: Checkout code uses: actions/checkout@v3 - - name: Set up Python ${{ matrix.python-version }} + - name: Set up Python uses: actions/setup-python@v2 with: - python-version: ${{ matrix.python-version }} + python-version: "3.11" - name: Cache dependencies uses: actions/cache@v2 with: - path: ~/.poetry/cache - key: ${{ runner.os }}-poetry-${{ hashFiles('**/poetry.lock') }} + path: ~/.poetry + key: windows-poetry-${{ hashFiles('**/poetry.lock') }} restore-keys: | - ${{ runner.os }}-poetry- + windows-poetry- + + - name: Check if Poetry is installed + run: | + if (-Not (Test-Path $env:USERPROFILE\.poetry\bin\poetry)) { + Write-Output "Poetry not installed" + choco install poetry + } else { + Write-Output "Poetry already installed" + } - name: Install Dependencies run: | - pip install poetry - poetry add pyinstaller poetry config virtualenvs.create true poetry install --no-root - name: Build + run: poetry run pyinstaller -F main.py -n ToolDelta.exe -i logo.png + + - name: Get version + run: echo "VERSION=$(> $GITHUB_ENV + + - name: Release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.VERSION }} + name: ${{ env.VERSION }} + files: dist/* + + build_linux: + name: Build and Release for Linux + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v2 + with: + python-version: "3.11" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ~/.poetry + key: linux-poetry-${{ hashFiles('**/poetry.lock') }} + restore-keys: | + linux-poetry- + + - name: Check if Poetry is installed run: | - if [ "${{ runner.os }}" == 'Windows' ]; then - poetry run pyinstaller -F main.py -n ToolDelta.exe -i logo.png + if [ ! -f ~/.poetry/bin/poetry ]; then + echo "Poetry not installed" + curl -sSL https://install.python-poetry.org | python3 - else - poetry run pyinstaller -F main.py -n ToolDelta -i logo.png + echo "Poetry already installed" fi + - name: Install Dependencies + run: | + poetry config virtualenvs.create true + poetry install --no-root + + - name: Build + run: poetry run pyinstaller -F main.py -n ToolDelta -i logo.png + - name: Get version run: echo "VERSION=$(> $GITHUB_ENV