@@ -3,14 +3,26 @@ name: Pip Package
33env :
44 DEFAULT_SAMPLES_REVISION : 11.0.0
55on :
6- workflow_dispatch :
6+ workflow_dispatch : # manual triggering
77 inputs :
88 samples-revision :
99 default : 11.0.0
1010 description : khiops-samples repo revision
1111 image-tag :
1212 default : 11.0.0-b.0.0
1313 description : Development Docker Image Tag
14+ publish-to-github :
15+ type : boolean
16+ default : true
17+ description : Legacy publishing mode - github release (PRODUCTION)
18+ publish-to-testpypi :
19+ type : boolean
20+ default : false
21+ description : TestPyPI publishing mode (TEST)
22+ publish-to-pypi :
23+ type : boolean
24+ default : false
25+ description : PyPI publishing mode (PRODUCTION)
1426 pull_request :
1527 paths :
1628 - setup.py
3547 packages : read
3648 steps :
3749 - name : Checkout sources
50+ # no explict branch specified so this step should check out the github.ref branch or tag
3851 uses : actions/checkout@v4
3952 with :
4053 # Get Git tags so that versioneer can function correctly
@@ -51,13 +64,15 @@ jobs:
5164 # Install required Python build dependency
5265 pip install build
5366
54- # Build the package
55- python3 -m build --sdist
56- - name : Upload package as artifact
67+ # Build the packages/distributions :
68+ # a source distribution is built first (sdist) and
69+ # a binary one (wheel) then
70+ python3 -m build
71+ - name : Upload the packages as artifact
5772 uses : actions/upload-artifact@v4
5873 with :
59- name : pip-package
60- path : ./dist/khiops*.tar.gz
74+ name : pip-packages
75+ path : ./dist/
6176 test :
6277 needs : build
6378 runs-on : ubuntu-22.04
@@ -83,14 +98,14 @@ jobs:
8398 ref : ${{ env.SAMPLES_REVISION }}
8499 token : ${{ secrets.GITHUB_TOKEN }}
85100 path : khiops-samples
86- - name : Download package artifact
101+ - name : Download package artifacts
87102 uses : actions/download-artifact@v4
88103 with :
89- name : pip-package
104+ name : pip-packages
90105 - name : Install package
91106 run : |
92107 pip install --upgrade pip
93- pip install $(ls khiops*.tar.gz)
108+ pip install $(ls khiops*.tar.gz) # install the source package
94109 - name : Run tests
95110 env :
96111 KHIOPS_SAMPLES_DIR : ${{ github.workspace }}/khiops-samples
@@ -120,17 +135,19 @@ jobs:
120135 # (as given by khiops_env)
121136 kh-status | grep "MPI command" | grep -vwq "<empty>"
122137 release :
123- if : github.ref_type == 'tag'
138+ if : github.ref_type == 'tag' # only publish on tag pushes
124139 needs : [build, test]
125140 runs-on : ubuntu-22.04
126141 permissions :
127142 contents : write
143+ id-token : write # IMPORTANT: mandatory for trusted publishing on TestPyPI and PyPI
128144 steps :
129145 - name : Download package artifact
130146 uses : actions/download-artifact@v4
131147 with :
132- name : pip-package
133- - name : Upload Pip package to the release
148+ name : pip-packages
149+ - name : Upload Pip source package to the github release (under condition)
150+ if : inputs.publish-to-github
134151 uses : ncipollo/release-action@v1.15.0
135152 with :
136153 allowUpdates : true
@@ -140,3 +157,20 @@ jobs:
140157 makeLatest : false
141158 prerelease : true
142159 updateOnlyUnreleased : true
160+ - name : Publish Python 🐍 distribution 📦 to TestPyPI (under condition)
161+ if : inputs.publish-to-testpypi
162+ env : # required environment variables at step level
163+ name : testpypi
164+ url : https://test.pypi.org/p/khiops
165+ uses : pypa/gh-action-pypi-publish@release/v1
166+ with :
167+ verbose : true
168+ repository-url : https://test.pypi.org/legacy/
169+ - name : Publish Python 🐍 distribution 📦 to PyPI (under condition)
170+ if : inputs.publish-to-pypi
171+ env : # required environment variables at step level
172+ name : pypi
173+ url : https://pypi.org/p/khiops
174+ uses : pypa/gh-action-pypi-publish@release/v1
175+ with :
176+ verbose : true
0 commit comments