Skip to content

Commit

Permalink
🎨 尝试缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
wling-art committed Feb 9, 2024
1 parent d741754 commit 165c281
Showing 1 changed file with 63 additions and 18 deletions.
81 changes: 63 additions & 18 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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=$(<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=$(<version)" >> $GITHUB_ENV

Expand Down

0 comments on commit 165c281

Please sign in to comment.