diff --git a/.github/workflows/publish-to-testpypi.yml b/.github/workflows/publish-to-testpypi.yml new file mode 100644 index 00000000..944e1d04 --- /dev/null +++ b/.github/workflows/publish-to-testpypi.yml @@ -0,0 +1,51 @@ +name: Publish to TestPyPI on release PR + +on: + pull_request: + branches: + - main + types: + - opened + - synchronize + +jobs: + build: + name: Build package + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - run: pip install --upgrade build + + - name: Build package + run: python -m build + + - uses: actions/upload-artifact@v4 + with: + name: dist + path: dist + overwrite: true + if-no-files-found: error + retention-days: 1 + + publish-to-testpypi: + name: Publish to TestPyPI + needs: build + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Download package + uses: actions/download-artifact@v4 + with: + name: dist + path: dist + + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5814bf93..5ac72e42 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -11,10 +11,13 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: python-version: '3.x' + - run: pip install --upgrade build + - name: Build package run: pyproject-build - uses: actions/upload-artifact@v7 @@ -25,9 +28,27 @@ jobs: if-no-files-found: error retention-days: 1 + publish-to-testpypi: + name: Publish to TestPyPI + needs: build + runs-on: ubuntu-latest + permissions: + id-token: write + steps: + - name: Download package + uses: actions/download-artifact@v8 + with: + name: dist + path: dist + + - name: Publish to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + publish: name: Upload release to PyPI - needs: build + needs: publish-to-testpypi runs-on: ubuntu-latest permissions: id-token: write @@ -37,5 +58,6 @@ jobs: with: name: dist path: dist + - name: Publish package distributions to PyPI uses: pypa/gh-action-pypi-publish@release/v1