From f535a918e06afb48c7b32ae55eefa28d483b9785 Mon Sep 17 00:00:00 2001 From: ElliottKasoar Date: Tue, 6 Feb 2024 17:02:34 +0000 Subject: [PATCH] Update publishing for poetry --- .github/workflows/publish-on-pypi.yml | 46 +++++++++++++++++---------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/.github/workflows/publish-on-pypi.yml b/.github/workflows/publish-on-pypi.yml index f9c11d07..ef2d0290 100644 --- a/.github/workflows/publish-on-pypi.yml +++ b/.github/workflows/publish-on-pypi.yml @@ -9,25 +9,37 @@ on: jobs: publish: runs-on: ubuntu-latest - if: github.repository == 'aiidateam/aiida-mlip' && startsWith(github.ref, 'refs/tags/v') + if: github.repository == 'stfc/aiida-mlip' && startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 - - name: Set up Python 3.10 - uses: actions/setup-python@v1 + - name: Install poetry + run: pipx install poetry + + - name: Set up Python 3.11 + uses: actions/setup-python@v5 with: - python-version: '3.10' - - - name: Install flit - run: | - python -m pip install --upgrade pip - python -m pip install flit~=3.4 - - - name: Build and publish - run: | - flit publish - env: - FLIT_USERNAME: __token__ - FLIT_PASSWORD: ${{ secrets.pypi_token }} + python-version: 3.11 + + - name: Build project for distribution + run: poetry build + + - name: Check Version + id: check-version + run: | + [[ "$(poetry version --short)" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || echo prerelease=true >> $GITHUB_OUTPUT + + - name: Create Release + uses: ncipollo/release-action@v1 + with: + artifacts: "dist/*" + token: ${{ secrets.GITHUB_TOKEN }} + draft: false + prerelease: steps.check-version.outputs.prerelease == 'true' + + - name: Publish to PyPI + env: + POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }} + run: poetry publish