From ced5d88dca25b0a1b998218fc1b192003128a8e0 Mon Sep 17 00:00:00 2001 From: Tim Vink Date: Tue, 16 Apr 2024 19:08:52 +0000 Subject: [PATCH] update gh action for deployment --- .github/workflows/pythonpublish.yml | 31 +++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pythonpublish.yml b/.github/workflows/pythonpublish.yml index 6f0615c..9b8eedf 100644 --- a/.github/workflows/pythonpublish.yml +++ b/.github/workflows/pythonpublish.yml @@ -1,31 +1,46 @@ name: Upload Python Package on: + workflow_dispatch: release: types: [created] + jobs: deploy: runs-on: ubuntu-latest + environment: release + permissions: + # IMPORTANT: this permission is mandatory for trusted publishing + id-token: write + contents: write steps: - - uses: actions/checkout@master + - uses: actions/checkout@v4 + with: + fetch-depth: '0' - name: Set up Python - uses: actions/setup-python@master + uses: actions/setup-python@v4 with: python-version: '3.x' - name: Install dependencies run: | python -m pip install --upgrade pip pip install setuptools wheel twine + - name: Make sure unit tests succeed run: | + git config --global user.name "Github Action" + git config --global user.email "githubaction@gmail.com" pip install -r tests/test_requirements.txt - pip install -e . + pip install . pytest - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + + + - name: Build run: | python setup.py sdist bdist_wheel - twine upload dist/* \ No newline at end of file + + # See https://docs.pypi.org/trusted-publishers/using-a-publisher/ + - name: Publish package distributions to PyPI + uses: pypa/gh-action-pypi-publish@release/v1 +