From 84c55a2108ae595e24c3c7bc5ac789fb0a18349d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20P=C3=A9rez-Garc=C3=ADa?= Date: Sun, 17 Nov 2024 22:53:05 +0000 Subject: [PATCH] Improve things --- .github/actions/publish-package/action.yml | 36 ---------------- .github/workflows/publish.yml | 48 +++++++++++++++------- 2 files changed, 34 insertions(+), 50 deletions(-) delete mode 100644 .github/actions/publish-package/action.yml diff --git a/.github/actions/publish-package/action.yml b/.github/actions/publish-package/action.yml deleted file mode 100644 index 2b4c1632..00000000 --- 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 a26f26ef..6dae387e 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