Publish Python Package #42
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: Publish Python Package | |
on: | |
workflow_run: | |
workflows: [Run CI] | |
types: | |
- completed | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Poetry | |
run: | | |
curl -sSL https://install.python-poetry.org | python3 - | |
export PATH="$HOME/.local/bin:$PATH" | |
- name: Install dependencies | |
run: | | |
poetry install --no-root -E playwright | |
- name: Build package | |
run: | | |
poetry build | |
- name: Publish to PyPI | |
env: | |
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.DS_PYPI_API_TOKEN }} | |
run: | | |
poetry config http-basic.pypi "__token__" "${POETRY_PYPI_TOKEN_PYPI}" | |
poetry publish | |
- name: Get the version from pyproject.toml | |
id: get_version | |
run: | | |
echo "::set-output name=version::$(poetry version -s)" | |
- name: Create Git tag | |
env: | |
GITHUB_TOKEN: ${{ secrets.CI_TOKEN }} | |
run: | | |
git config user.name "github-actions" | |
git config user.email "[email protected]" | |
git tag -a v${{ steps.get_version.outputs.version }} -m "Release version ${{ steps.get_version.outputs.version }}" | |
git push https://x-access-token:${GITHUB_TOKEN}@github.com/lucaromagnoli/dataservice.git v${{ steps.get_version.outputs.version }} | |
- name: Create GitHub Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: v${{ steps.get_version.outputs.version }} | |
name: "Release ${{ steps.get_version.outputs.version }}" | |
body: "New release version ${{ steps.get_version.outputs.version }} is published" | |
draft: false | |
prerelease: false |