From ea6c2d7ff9d5b5ac004736cc6f2b2dfe94de5f10 Mon Sep 17 00:00:00 2001 From: garnajee <62147746+garnajee@users.noreply.github.com> Date: Wed, 10 Dec 2025 16:51:14 +0100 Subject: [PATCH] auto relase on pyproject modification --- .github/workflows/build_release.yml | 44 ++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_release.yml b/.github/workflows/build_release.yml index 4dd33fa..8ccd6ee 100644 --- a/.github/workflows/build_release.yml +++ b/.github/workflows/build_release.yml @@ -5,30 +5,60 @@ on: branches: [ main ] tags: - 'v*' - paths-ignore: - - "README.md" + paths: + - "pyproject.toml" +permissions: + contents: write # to create tag jobs: - build: + deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 + # 1. tag extraction of pyproject.toml + - name: Extract version from pyproject.toml + id: get_version + run: | + VERSION=$(grep -m 1 'version = "' pyproject.toml | cut -d '"' -f 2) + echo "Detected version: $VERSION" + echo "VERSION=$VERSION" >> $GITHUB_ENV + + # 2. tag verification + - name: Check if tag exists + uses: mukunku/tag-exists-action@v1.2.0 + id: check_tag + with: + tag: 'v${{ env.VERSION }}' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + # 3. Setup environnement (if tag doesn't exist) - name: Set up Python + if: steps.check_tag.outputs.exists == 'false' uses: actions/setup-python@v4 with: python-version: "3.9" - name: Install dependencies + if: steps.check_tag.outputs.exists == 'false' run: | python -m pip install --upgrade pip pip install build + # 4. Compilation (.whl and .tar.gz) - name: Build package + if: steps.check_tag.outputs.exists == 'false' run: python -m build - - name: Archive artifacts - uses: actions/upload-artifact@v4 + # 5. auto creation of tag and github release + - name: Create Release and Upload Assets + if: steps.check_tag.outputs.exists == 'false' + uses: softprops/action-gh-release@v1 with: - name: dist - path: dist/ + tag_name: v${{ env.VERSION }} # Ex: v1.0.2 + name: Release v${{ env.VERSION }} # release title + files: dist/* # files to upload + generate_release_notes: true # generate changelog data + draft: false + prerelease: false