diff --git a/.github/actions/publish-package/action.yml b/.github/actions/publish-package/action.yml deleted file mode 100644 index 2b4c16328..000000000 --- a/.github/actions/publish-package/action.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: Publish package to PyPI or TestPyPI - -inputs: - test: - description: Whether to publish to TestPyPI - required: true - -runs: - using: "composite" - steps: - - name: Install uv - uses: astral-sh/setup-uv@v3 - - # - name: Set up Python - # run: uv python install - # shell: bash - - - name: Build a binary wheel and a source tarball - run: uv build - shell: bash - - - name: Publish package to TestPyPI - if: ${{ inputs.test }} == true - uses: pypa/gh-action-pypi-publish@release/v1 - with: - repository-url: https://test.pypi.org/legacy/ - verbose: true - skip-existing: true - - - name: Publish package to PyPI - if: ${{ inputs.test }} == false - run: echo "Publishing to PyPI" - shell: bash - # uses: pypa/gh-action-pypi-publish@release/v1 - # with: - # verbose: true diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index a26f26ef0..6dae387ef 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -2,25 +2,45 @@ name: Publish on: push -permissions: - id-token: write - jobs: - Build-and-publish: - name: Build and publish if needed + build: + name: Build the package runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Publish TorchIO to TestPyPI - uses: ./.github/actions/publish-package - with: - test: true + - name: Install uv + uses: astral-sh/setup-uv@v3 + + - name: Build a binary wheel and a source tarball + run: uv build - # Publish only tagged commits - - name: Publish TorchIO to PyPI if commit is tagged - if: startsWith(github.ref, 'refs/tags') - uses: ./.github/actions/publish-package + - name: Upload dist directory + uses: actions/upload-artifact@v2 with: - test: false + path: dist + + publish: + name: Publish the package + runs-on: ubuntu-latest + permissions: + id-token: write + + steps: + - name: Download all workflow run artifacts + uses: actions/download-artifact@v4 + + - name: Publish package to TestPyPI + uses: pypa/gh-action-pypi-publish@release/v1 + with: + repository-url: https://test.pypi.org/legacy/ + verbose: true + skip-existing: true + + - name: Publish TorchIO to PyPI if commit is tagged + # Publish only tagged commits + if: startsWith(github.ref, 'refs/tags') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + verbose: true