From f1dc7bea1968c84e65a814a89caf3179fb1bea75 Mon Sep 17 00:00:00 2001 From: Pierre Sassoulas Date: Mon, 2 Jan 2023 21:18:19 +0100 Subject: [PATCH] Add github action to be able to release on published tag (#582) * Add github action to be able to release on published tag * Use the pypi-prod environnement for releasing the package * Upgrade to use an environnement * handle the two environnement * Remove pypi-dev that made no sense, we should create another workflow * Take review comment into account See https://github.com/PyCQA/pydocstyle/pull/582\#discussion_r1060145450 --- .github/workflows/release.yml | 43 +++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..61626a6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,43 @@ +name: Release + +on: + release: + types: + - published + +env: + DEFAULT_PYTHON: "3.11" + +permissions: + contents: read + +jobs: + release-pypi: + name: Upload release to PyPI + runs-on: ubuntu-latest + environment: + name: pypi-prod + url: https://pypi.org/project/pydocstyle/ + steps: + - name: Check out code from Github + uses: actions/checkout@v3.2.0 + - name: Set up Python ${{ env.DEFAULT_PYTHON }} + id: python + uses: actions/setup-python@v4.4.0 + with: + python-version: ${{ env.DEFAULT_PYTHON }} + check-latest: true + - name: Install requirements + run: | + python -m pip install twine build + - name: Build distributions + run: | + python -m build + - name: Upload to PyPI + if: github.event_name == 'release' && startsWith(github.ref, 'refs/tags') + env: + TWINE_REPOSITORY: pypi + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }} + run: | + twine upload --verbose dist/*