Skip to content

Commit

Permalink
Fix pypi CI (#58)
Browse files Browse the repository at this point in the history
* separate testpypi and pypi jobs

* syntax

* shorter job name

* allow release ??

* ggg

* quick test

* verified and revert

* fixes for pypi
  • Loading branch information
kaiyu-zheng committed Mar 13, 2024
1 parent fead318 commit c12f38c
Showing 1 changed file with 48 additions and 7 deletions.
55 changes: 48 additions & 7 deletions .github/workflows/pypi_deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -49,22 +51,61 @@ 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__
password: ${{ secrets.TEST_PYPI_TOKEN }}
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
Expand Down

0 comments on commit c12f38c

Please sign in to comment.