Skip to content

Commit 8fee27f

Browse files
committed
Update PyPI publish workflow
1 parent 159df61 commit 8fee27f

File tree

1 file changed

+37
-24
lines changed

1 file changed

+37
-24
lines changed
Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
1-
name: Publish Python distributions to PyPI and TestPyPI
1+
name: Publish Python 🐍 distribution 📦 to PyPI
22

33
on:
44
release:
5-
types: [published]
6-
5+
types: [created]
76

87
jobs:
9-
build-n-publish:
10-
name: Build and publish Python distributions to PyPI and TestPyPI
11-
runs-on: ubuntu-20.04
8+
build:
9+
name: Build distribution 📦
10+
runs-on: ubuntu-latest
1211
steps:
13-
- uses: actions/checkout@master
14-
- name: Set up Python 3.10
15-
uses: actions/setup-python@v1
12+
- uses: actions/checkout@v4
13+
- name: Set up Python
14+
uses: actions/setup-python@v4
1615
with:
17-
python-version: "3.10"
16+
python-version: "3.x"
1817
- name: Install pypa/build
19-
run: python -m pip install build hatch --user
18+
run: >-
19+
python3 -m
20+
pip install
21+
build
22+
--user
2023
- name: Build a binary wheel and a source tarball
21-
run: python -m build --sdist --wheel --outdir dist/
22-
23-
# Publish the package to test.pypi for every rc version
24-
- name: Publish distribution to Test PyPI
25-
if: "startsWith(github.ref, 'refs/tags') && contains(github.ref, 'rc')"
26-
uses: pypa/gh-action-pypi-publish@master
24+
run: python3 -m build
25+
- name: Store the distribution packages
26+
uses: actions/upload-artifact@v3
2727
with:
28-
password: ${{ secrets.test_pypi_password }}
29-
repository_url: http://test.pypi.org/legacy/
28+
name: python-package-distributions
29+
path: dist/
3030

31-
# Publish a tagged version on PyPI for non-release candidates
32-
- name: Publish distribution to PyPI
33-
if: "startsWith(github.ref, 'refs/tags') && !contains(github.ref, 'rc')"
34-
uses: pypa/gh-action-pypi-publish@master
31+
publish-to-pypi:
32+
name: >-
33+
Publish Python 🐍 distribution 📦 to PyPI
34+
needs:
35+
- build
36+
runs-on: ubuntu-latest
37+
environment:
38+
name: pypi
39+
url: https://pypi.org/p/era5cli
40+
permissions:
41+
id-token: write # IMPORTANT: mandatory for trusted publishing
42+
steps:
43+
- name: Download all the dists
44+
uses: actions/download-artifact@v3
3545
with:
36-
password: ${{ secrets.pypi_password }}
46+
name: python-package-distributions
47+
path: dist/
48+
- name: Publish distribution 📦 to PyPI
49+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)