Skip to content

Commit 55f8826

Browse files
committed
Updated workflows
1 parent dad00b3 commit 55f8826

File tree

2 files changed

+94
-57
lines changed

2 files changed

+94
-57
lines changed

.github/workflows/publish.yaml

Lines changed: 84 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# From: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/
22
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI
3-
on: push
3+
on:
4+
workflow_dispatch:
5+
push:
6+
tags:
7+
- '*'
48
jobs:
59
build:
610
name: Build Python 📦
@@ -20,86 +24,114 @@ jobs:
2024
with:
2125
name: python-package-distributions
2226
path: dist/
27+
test:
28+
name: Test Python 📦
29+
needs:
30+
- build
31+
runs-on: ubuntu-latest
32+
steps:
33+
- name: Download all the dists
34+
uses: actions/download-artifact@v4
35+
with:
36+
name: python-package-distributions
37+
path: dist
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-python@v5
40+
with:
41+
python-version: 3.12
42+
cache: 'pip'
43+
- name: Install
44+
run: |
45+
find dist -name '*.whl' -exec pip install {} \;
46+
pip install pytest
47+
- name: Test Gymnasium
48+
run: pytest test/test_gymnasium.py
49+
- name: Test PettingZoo
50+
run: pytest test/test_pettingzoo.py
51+
- name: Install torchrl
52+
run: find dist -name '*.whl' -exec pip install {}[torchrl] \;
53+
- name: Test TorchRL
54+
run: pytest test/test_torchrl.py
2355
publish-to-testpypi:
2456
name: Publish Python 🐍 distribution 📦 to TestPyPI
2557
needs:
26-
- build
58+
- test
2759
runs-on: ubuntu-latest
2860
environment:
2961
name: testpypi
3062
url: https://test.pypi.org/p/navground-learning
3163
permissions:
3264
id-token: write # IMPORTANT: mandatory for trusted publishing
3365
steps:
34-
- name: Download all the dists
35-
uses: actions/download-artifact@v4
36-
with:
37-
name: python-package-distributions
38-
path: dist/
39-
- name: Publish distribution 📦 to TestPyPI
40-
uses: pypa/gh-action-pypi-publish@release/v1
41-
with:
42-
repository-url: https://test.pypi.org/legacy/
43-
skip-existing: true
66+
- name: Download all the dists
67+
uses: actions/download-artifact@v4
68+
with:
69+
name: python-package-distributions
70+
path: dist/
71+
- name: Publish distribution 📦 to TestPyPI
72+
uses: pypa/gh-action-pypi-publish@release/v1
73+
with:
74+
repository-url: https://test.pypi.org/legacy/
75+
skip-existing: true
4476
publish-to-pypi:
4577
name: >-
4678
Publish Python 🐍 distribution 📦 to PyPI
4779
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
4880
needs:
49-
- build
81+
- test
5082
runs-on: ubuntu-latest
5183
environment:
5284
name: pypi
5385
url: https://pypi.org/p/navground-learning
5486
permissions:
5587
id-token: write # IMPORTANT: mandatory for trusted publishing
5688
steps:
57-
- name: Download all the dists
58-
uses: actions/download-artifact@v4
59-
with:
60-
name: python-package-distributions
61-
path: dist/
62-
- name: Publish distribution 📦 to PyPI
63-
uses: pypa/gh-action-pypi-publish@release/v1
64-
with:
65-
skip-existing: true
89+
- name: Download all the dists
90+
uses: actions/download-artifact@v4
91+
with:
92+
name: python-package-distributions
93+
path: dist/
94+
- name: Publish distribution 📦 to PyPI
95+
uses: pypa/gh-action-pypi-publish@release/v1
96+
with:
97+
skip-existing: true
6698
github-release:
6799
name: >-
68100
Sign the Python 🐍 distribution 📦 with Sigstore
69101
and upload them to GitHub Release
70102
needs:
71-
- publish-to-pypi
103+
- publish-to-pypi
72104
runs-on: ubuntu-latest
73105
permissions:
74106
contents: write # IMPORTANT: mandatory for making GitHub Releases
75107
id-token: write # IMPORTANT: mandatory for sigstore
76108
steps:
77-
- name: Download all the dists
78-
uses: actions/download-artifact@v4
79-
with:
80-
name: python-package-distributions
81-
path: dist/
82-
- name: Sign the dists with Sigstore
83-
uses: sigstore/gh-action-sigstore-python@v3.0.0
84-
with:
85-
inputs: >-
86-
./dist/*.tar.gz
87-
./dist/*.whl
88-
- name: Create GitHub Release
89-
env:
90-
GITHUB_TOKEN: ${{ github.token }}
91-
run: >-
92-
gh release create
93-
'${{ github.ref_name }}'
94-
--repo '${{ github.repository }}'
95-
--notes ""
96-
- name: Upload artifact signatures to GitHub Release
97-
env:
98-
GITHUB_TOKEN: ${{ github.token }}
99-
# Upload to GitHub Release using the `gh` CLI.
100-
# `dist/` contains the built packages, and the
101-
# sigstore-produced signatures and certificates.
102-
run: >-
103-
gh release upload
104-
'${{ github.ref_name }}' dist/**
105-
--repo '${{ github.repository }}'
109+
- name: Download all the dists
110+
uses: actions/download-artifact@v4
111+
with:
112+
name: python-package-distributions
113+
path: dist/
114+
- name: Sign the dists with Sigstore
115+
uses: sigstore/gh-action-sigstore-python@v3.0.0
116+
with:
117+
inputs: >-
118+
./dist/*.tar.gz
119+
./dist/*.whl
120+
- name: Create GitHub Release
121+
env:
122+
GITHUB_TOKEN: ${{ github.token }}
123+
run: >-
124+
gh release create
125+
'${{ github.ref_name }}'
126+
--repo '${{ github.repository }}'
127+
--notes ""
128+
- name: Upload artifact signatures to GitHub Release
129+
env:
130+
GITHUB_TOKEN: ${{ github.token }}
131+
# Upload to GitHub Release using the `gh` CLI.
132+
# `dist/` contains the built packages, and the
133+
# sigstore-produced signatures and certificates.
134+
run: >-
135+
gh release upload
136+
'${{ github.ref_name }}' dist/**
137+
--repo '${{ github.repository }}'

.github/workflows/test.yaml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: Build and test
22
on:
33
workflow_dispatch:
4+
pull_request:
5+
branches:
6+
- main
7+
- 'releases/**'
8+
push:
9+
branches:
10+
- main
11+
- 'releases/**'
412
jobs:
513
build:
614
name: Build Python 📦
@@ -38,16 +46,13 @@ jobs:
3846
cache: 'pip'
3947
- name: Install
4048
run: |
41-
wheels=( dist/*.whl )
42-
pip install ${wheels[0]}
49+
find dist -name '*.whl' -exec pip install {} \;
4350
pip install pytest
4451
- name: Test Gymnasium
4552
run: pytest test/test_gymnasium.py
4653
- name: Test PettingZoo
4754
run: pytest test/test_pettingzoo.py
4855
- name: Install torchrl
49-
run: |
50-
wheels=( dist/*.whl )
51-
pip install ${wheels[0]}[torchrl]
56+
run: find dist -name '*.whl' -exec pip install {}[torchrl] \;
5257
- name: Test TorchRL
5358
run: pytest test/test_torchrl.py

0 commit comments

Comments
 (0)