build-publish.yml: add skip-existing to testpypi #63
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
name: Build and Publish Release via PyPi | |
on: push | |
jobs: | |
build: | |
name: Build distribution π¦ | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository π | |
uses: actions/checkout@v4 | |
- name: Update version in pyproject.toml β¬οΈ | |
uses: brettdorrans/[email protected] | |
with: | |
filename: 'pyproject.toml' | |
placeholder: '1.0.0.dev1' | |
- name: Set up Python 3.12 π | |
uses: actions/setup-python@v5 | |
with: | |
python-version: "3.12" | |
- name: Install and configure Poetry π | |
uses: snok/install-poetry@v1 | |
with: | |
virtualenvs-create: false | |
- name: Build & Package project π· | |
run: poetry build | |
- name: Store the distribution packages | |
uses: actions/upload-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
publish-to-pypi: | |
name: >- | |
Publish Python π distribution π¦ to PyPI | |
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: pypi | |
url: https://pypi.org/p/withings-sync | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution π¦ to PyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
password: ${{ secrets.PYPI_API_TOKEN }} # LEAVING THIS HERE UNTIL TRUSTED PUBLISHING IS IN PLACE | |
publish-to-testpypi: | |
name: Publish Python π distribution π¦ to TestPyPI | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: testpypi | |
url: https://test.pypi.org/p/withings-sync | |
permissions: | |
id-token: write # IMPORTANT: mandatory for trusted publishing | |
steps: | |
- name: Download all the dists | |
uses: actions/download-artifact@v4 | |
with: | |
name: python-package-distributions | |
path: dist/ | |
- name: Publish distribution π¦ to TestPyPI | |
uses: pypa/gh-action-pypi-publish@release/v1 | |
with: | |
repository-url: https://test.pypi.org/legacy/ | |
skip-existing: true |