From 672b1c3aa7190d0994f8a21b12a923669f95155e Mon Sep 17 00:00:00 2001 From: grouazel Date: Thu, 14 Dec 2023 12:24:26 +0100 Subject: [PATCH] change the publish.yml (inspired from cdsodatacli) to enable the pypi push --- .github/workflows/publish.yml | 50 +++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dd7b3d9..ac38884 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,32 +1,54 @@ -name: Upload package to PyPI +name: Upload Package to PyPI on: release: types: [created] jobs: - publish: - name: Publish to PyPI + build: + name: Build packages runs-on: ubuntu-latest + if: github.repository == 'umr-lops/L2A-wind-direction-processor' steps: - - uses: actions/checkout@v4 + - name: Checkout + uses: actions/checkout@v4 - name: Set up Python - uses: actions/setup-python@v4 + uses: actions/setup-python@v5 with: - python-version: '3.x' + python-version: "3.x" - name: Install dependencies run: | - python -m pip install --upgrade pip build twine + python -m pip install --upgrade pip + python -m pip install build twine - name: Build run: | - python -m build --sdist --wheel . + python -m build --sdist --outdir dist/ . - name: Check the built archives run: | twine check dist/* - pip install dist/*.whl - - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@release/v1 + - name: Upload build artifacts + uses: actions/upload-artifact@v3 with: - password: ${{ secrets.pypi_token }} - repository_url: https://upload.pypi.org/legacy/ - verify_metadata: true \ No newline at end of file + name: packages + path: dist/* + + pypi-publish: + name: Upload to PyPI + runs-on: ubuntu-latest + needs: build + + environment: + name: pypi + url: https://pypi.org/p/l2awinddirection + permissions: + id-token: write + + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: packages + path: dist/ + + - name: Publish to PyPI + uses: pypa/gh-action-pypi-publish@2f6f737ca5f74c637829c0f5c3acd0e29ea5e8bf