From cb6d140042685bd419444d75ae7cab706cbcee38 Mon Sep 17 00:00:00 2001 From: PeriniM Date: Thu, 2 Jan 2025 17:11:40 +0100 Subject: [PATCH] fix: release workflow --- .github/workflows/release.yml | 47 +++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a8557a9d..0c2c2b51 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,40 +14,52 @@ jobs: run: | sudo apt update sudo apt install -y git + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.10' + - name: Install uv uses: astral-sh/setup-uv@v3 + - name: Install Node Env uses: actions/setup-node@v4 with: node-version: 20 + - name: Checkout uses: actions/checkout@v4.1.1 with: fetch-depth: 0 persist-credentials: false - - name: Build app + + - name: Install dependencies run: | + uv pip install build hatchling hatch-vcs uv sync --frozen - uv build + + - name: Build package + run: python -m build id: build_cache - if: success() - - name: Cache build - uses: actions/cache@v2 + + - name: Cache build artifacts + uses: actions/cache@v3 with: - path: ./dist - key: ${{ runner.os }}-build-${{ hashFiles('dist/**') }} - if: steps.build_cache.outputs.id != '' + path: | + ./dist + ./build + key: ${{ runner.os }}-build-${{ github.sha }} release: name: Release runs-on: ubuntu-latest needs: build environment: development - if: | - github.event_name == 'push' && github.ref == 'refs/heads/main' || - github.event_name == 'push' && github.ref == 'refs/heads/pre/beta' || - github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged && github.event.pull_request.base.ref == 'main' || - github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged && github.event.pull_request.base.ref == 'pre/beta' + if: | + github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/heads/pre/')) || + github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged && + (github.event.pull_request.base.ref == 'main' || startsWith(github.event.pull_request.base.ref, 'pre/')) permissions: contents: write issues: write @@ -59,6 +71,15 @@ jobs: with: fetch-depth: 0 persist-credentials: false + + - name: Restore build artifacts + uses: actions/cache@v3 + with: + path: | + ./dist + ./build + key: ${{ runner.os }}-build-${{ github.sha }} + - name: Semantic Release uses: cycjimmy/semantic-release-action@v4.1.0 with: