diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index dce20db..255410e 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -7,26 +7,45 @@ on: release: types: [published] -jobs: - deploy: - runs-on: windows-latest +jobs: + build: + name: Build distribution + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v2 + uses: actions/setup-python@v5 with: - python-version: '3.x' - - name: Install dependencies - run: | - python -m pip install --upgrade pip - python -m pip install --user --upgrade setuptools wheel - python setup.py sdist bdist_wheel - pip install setuptools wheel twine - - name: Build and publish + python-version: "3.x" + - name: Install pypa/build + run: python3 -m pip install build + - name: Build a binary wheel and a source tarball + run: python3 -m build + - name: Store the distribution packages + uses: actions/upload-artifact@v3 + with: + name: python-package-distributions + path: dist/ + + pypi-publish: + name: Publish Python distribution to PyPI + runs-on: ubuntu-latest + environment: + name: pypi + url: https://pypi.org/p/cm-text-sdk-python + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + contents: read # Add the contents permission for accessing repository contents + steps: + - name: Download all the dists + uses: actions/download-artifact@v3 + with: + name: python-package-distributions + path: dist/ + - name: Publish package distributions to PyPI env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + TWINE_USERNAME: __token__ + TWINE_PASSWORD: ${{ secrets.PYPI_API_PUBLISH_TOKEN }} run: | - python setup.py sdist bdist_wheel - python -m pip install --user --upgrade twine - python -m twine upload --repository pypi dist/* + python3 -m pip install twine + twine upload dist/* \ No newline at end of file