fix pyproject.toml (#84) #97
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: | |
push: | |
branches: | |
- main | |
jobs: | |
release: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the repository | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
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: Check if version is already published | |
id: check_version | |
run: | | |
VERSION=$(poetry version -s) | |
if python -m pip search dataservice==$VERSION; then | |
echo "Version $VERSION is already published. Skipping." | |
exit 0 | |
else | |
echo "Version $VERSION is not published yet. Proceeding." | |
fi | |
- name: Build package | |
if: ${{ steps.check_version.outcome == 'success' }} | |
run: | | |
poetry build | |
- name: Publish to PyPI | |
if: ${{ steps.check_version.outcome == 'success' }} | |
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 | |
if: ${{ steps.check_version.outcome == 'success' }} | |
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 | |
if: ${{ steps.check_version.outcome == 'success' }} | |
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 |