Skip to content

Commit 0442d66

Browse files
author
Thierry RAMORASOAVINA
committed
Publish the python library to TestPyPI and PyPI
1 parent 46ff350 commit 0442d66

1 file changed

Lines changed: 73 additions & 0 deletions

File tree

.github/workflows/publish.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
name: Publish
3+
on:
4+
pull_request:
5+
workflow_dispatch:
6+
inputs:
7+
version:
8+
description: Version of the release
9+
jobs:
10+
build:
11+
name: Build distribution 📦
12+
runs-on: ubuntu-22.04
13+
steps:
14+
- name: Checkout sources
15+
uses: actions/checkout@v4
16+
with:
17+
persist-credentials: false
18+
ref: main
19+
# Get Git tags so that versioneer can function correctly
20+
# See issue https://github.com/actions/checkout/issues/701
21+
fetch-depth: 0
22+
- name: Set up Python
23+
uses: actions/setup-python@v5
24+
with:
25+
python-version: 3.x
26+
- name: Install pypa/build
27+
run: >-
28+
python3 -m pip install build --user
29+
- name: Build a binary wheel and a source tarball
30+
run: python3 -m build
31+
- name: Store the distribution packages
32+
uses: actions/upload-artifact@v4
33+
with:
34+
name: python-package-distributions
35+
path: dist/
36+
publish-to-testpypi:
37+
name: Publish Python 🐍 distribution 📦 to TestPyPI
38+
needs: [build]
39+
runs-on: ubuntu-22.04
40+
environment:
41+
name: testpypi
42+
url: https://test.pypi.org/p/khiops
43+
permissions:
44+
id-token: write # IMPORTANT: mandatory for trusted publishing
45+
steps:
46+
- name: Download all the dists
47+
uses: actions/download-artifact@v4
48+
with:
49+
name: python-package-distributions
50+
path: dist/
51+
- name: Publish distribution 📦 to TestPyPI
52+
uses: pypa/gh-action-pypi-publish@release/v1
53+
with:
54+
repository-url: https://test.pypi.org/legacy/
55+
publish-to-pypi:
56+
name: >-
57+
Publish Python 🐍 distribution 📦 to PyPI
58+
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
59+
needs: [build]
60+
runs-on: ubuntu-22.04
61+
environment:
62+
name: pypi
63+
url: https://pypi.org/p/khiops
64+
permissions:
65+
id-token: write # IMPORTANT: mandatory for trusted publishing
66+
steps:
67+
- name: Download all the dists
68+
uses: actions/download-artifact@v4
69+
with:
70+
name: python-package-distributions
71+
path: dist/
72+
- name: Publish distribution 📦 to PyPI
73+
uses: pypa/gh-action-pypi-publish@release/v1

0 commit comments

Comments
 (0)