-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
159df61
commit 8fee27f
Showing
1 changed file
with
37 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,49 @@ | ||
name: Publish Python distributions to PyPI and TestPyPI | ||
name: Publish Python 🐍 distribution 📦 to PyPI | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
types: [created] | ||
|
||
jobs: | ||
build-n-publish: | ||
name: Build and publish Python distributions to PyPI and TestPyPI | ||
runs-on: ubuntu-20.04 | ||
build: | ||
name: Build distribution 📦 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Set up Python 3.10 | ||
uses: actions/setup-python@v1 | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.10" | ||
python-version: "3.x" | ||
- name: Install pypa/build | ||
run: python -m pip install build hatch --user | ||
run: >- | ||
python3 -m | ||
pip install | ||
build | ||
--user | ||
- name: Build a binary wheel and a source tarball | ||
run: python -m build --sdist --wheel --outdir dist/ | ||
|
||
# Publish the package to test.pypi for every rc version | ||
- name: Publish distribution to Test PyPI | ||
if: "startsWith(github.ref, 'refs/tags') && contains(github.ref, 'rc')" | ||
uses: pypa/gh-action-pypi-publish@master | ||
run: python3 -m build | ||
- name: Store the distribution packages | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
password: ${{ secrets.test_pypi_password }} | ||
repository_url: http://test.pypi.org/legacy/ | ||
name: python-package-distributions | ||
path: dist/ | ||
|
||
# Publish a tagged version on PyPI for non-release candidates | ||
- name: Publish distribution to PyPI | ||
if: "startsWith(github.ref, 'refs/tags') && !contains(github.ref, 'rc')" | ||
uses: pypa/gh-action-pypi-publish@master | ||
publish-to-pypi: | ||
name: >- | ||
Publish Python 🐍 distribution 📦 to PyPI | ||
needs: | ||
- build | ||
runs-on: ubuntu-latest | ||
environment: | ||
name: pypi | ||
url: https://pypi.org/p/era5cli | ||
permissions: | ||
id-token: write # IMPORTANT: mandatory for trusted publishing | ||
steps: | ||
- name: Download all the dists | ||
uses: actions/download-artifact@v3 | ||
with: | ||
password: ${{ secrets.pypi_password }} | ||
name: python-package-distributions | ||
path: dist/ | ||
- name: Publish distribution 📦 to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 |