Workflow file for this run
This file contains hidden or 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: Publish Python distribution to PyPI | |
| on: | |
| release: | |
| types: [ prereleased, released ] | |
| jobs: | |
| build: | |
| name: Build distribution π¦ | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: "3.8" | |
| - name: Install poetry | |
| uses: abatilo/actions-poetry@v2 | |
| with: | |
| poetry-version: "1.6" | |
| - name: Setup a local virtual environment (if no poetry.toml file) | |
| run: | | |
| poetry config virtualenvs.create true --local | |
| poetry config virtualenvs.in-project true --local | |
| - uses: actions/cache@v3 | |
| name: Define a cache for the virtual environment based on the dependencies lock file | |
| with: | |
| path: ./.venv | |
| key: venv-${{ hashFiles('poetry.lock') }} | |
| - name: Set deckhouse version | |
| env: | |
| TAG: ${{ github.event.release.tag_name }} | |
| run: | | |
| version=$(echo ${TAG} | sed -nre 's/v?([0-9]+\.[0-9]+\.[0-9]+)/\1/p') | |
| poetry version ${version} | |
| - name: Install the project dependencies | |
| run: poetry install | |
| - name: Test sources | |
| run: make test | |
| - name: Build a binary wheel and a source tarball | |
| run: make build | |
| - name: Store the distribution packages | |
| uses: actions/upload-artifact@v3 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| publish-to-pypi: | |
| name: >- | |
| Publish Python π distribution π¦ to PyPI | |
| if: '!github.event.release.prerelease' | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/p/deckhouse | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v3 | |
| with: | |
| name: python-package-distributions | |
| path: dist/ | |
| - name: Publish distribution π¦ to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| publish-to-testpypi: | |
| name: Publish Python π distribution π¦ to TestPyPI | |
| needs: | |
| - build | |
| runs-on: ubuntu-latest | |
| if: 'github.event.release.prerelease' | |
| environment: | |
| name: testpypi | |
| url: https://test.pypi.org/p/deckhouse | |
| permissions: | |
| id-token: write # IMPORTANT: mandatory for trusted publishing | |
| steps: | |
| - name: Download all the dists | |
| uses: actions/download-artifact@v3 | |
| 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/ |