Skip to content

Commit

Permalink
Publish releases to pypi
Browse files Browse the repository at this point in the history
  • Loading branch information
HSZemi committed Nov 6, 2024
1 parent 7dbf7f7 commit f3f51fc
Showing 1 changed file with 55 additions and 3 deletions.
58 changes: 55 additions & 3 deletions .github/workflows/python-lib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ permissions:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Fetch test files
Expand All @@ -24,7 +22,7 @@ jobs:
- name: List test files
run: |
find tests/testdata/ -iname '*.dat'
- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.11"
Expand All @@ -36,3 +34,57 @@ jobs:
- name: Run test script
run: |
./test
- name: Build distribution
run: |
python3 -m pip install --upgrade build
python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution πŸ“¦ to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: release
url: https://pypi.org/p/genieutils-py
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution πŸ“¦ to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

publish-to-testpypi:
name: Publish Python 🐍 distribution πŸ“¦ to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/<package-name>

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution πŸ“¦ to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

0 comments on commit f3f51fc

Please sign in to comment.