diff --git a/.github/workflows/pypi_deployment.yml b/.github/workflows/pypi_deployment.yml index a074385..5ce143d 100644 --- a/.github/workflows/pypi_deployment.yml +++ b/.github/workflows/pypi_deployment.yml @@ -10,8 +10,11 @@ concurrency: cancel-in-progress: true jobs: - pypi-publish: + testpypi-publish: + name: publish to Test PyPi runs-on: ubuntu-latest + if: ${{ github.ref == 'refs/tags/vdev-latest' }} + strategy: fail-fast: true matrix: @@ -21,13 +24,12 @@ jobs: url: https://test.pypi.org/p/pomdp-py/ permissions: id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + contents: write steps: - name: Set Variables if: startsWith(github.ref, 'refs/tags/v') - run: | # Run the command within a multiline string - echo "VERSION=\"Version ${{ github.ref_name }}\"" >> $GITHUB_ENV - echo "TRIGGER_FOR_TEST_PYPI=${{ github.ref == 'refs/tags/vdev-latest' }}" >> $GITHUB_ENV + run: echo "VERSION=\"Version ${{ github.ref_name }}\"" >> $GITHUB_ENV - uses: actions/setup-python@v5 with: @@ -49,7 +51,6 @@ jobs: - name: Upload to Test PyPi uses: pypa/gh-action-pypi-publish@release/v1 - if: ${{ env.TRIGGER_FOR_TEST_PYPI }} with: # This will upload stuff under dist/ to PyPI user: __token__ @@ -57,14 +58,54 @@ jobs: repository_url: https://test.pypi.org/legacy/ skip-existing: true + - name: Release artifact + uses: softprops/action-gh-release@v1 + with: + name: ${{ env.VERSION }} + files: dist/*.whl + + + pypi-publish: + name: publish to PyPi + runs-on: ubuntu-latest + if: ${{ github.ref != 'refs/tags/vdev-latest' }} + strategy: + fail-fast: true + matrix: + python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + environment: + name: pypi + url: https://pypi.org/p/pomdp-py/ + permissions: + id-token: write # IMPORTANT: this permission is mandatory for trusted publishing + contents: write + + steps: + - name: Set Variables + if: startsWith(github.ref, 'refs/tags/v') + run: echo "VERSION=\"Version ${{ github.ref_name }}\"" >> $GITHUB_ENV + + - uses: actions/setup-python@v5 + with: + python-version: ${{ matrix.python-version }} + + - name: Install dependencies + run: | + python -m pip install --upgrade pip + + - name: Run release script + working-directory: . + run: | + cd scripts + ./pomdp_py_release.sh ${{ vars.RELEASE_ATTEMPT_COUNT }} + - name: Upload to PyPi uses: pypa/gh-action-pypi-publish@release/v1 - if: ${{ ! env.TRIGGER_FOR_TEST_PYPI }} with: # This will upload stuff under dist/ to PyPI user: __token__ password: ${{ secrets.PYPI_TOKEN }} - repository_url: https://test.pypi.org/legacy/ + repository_url: https://pypi.org/ skip-existing: true - name: Release artifact