Skip to content

Commit 7c9a795

Browse files
author
Thierry RAMORASOAVINA
committed
Publish the python library to TestPyPI and PyPI
- publish to PyPI only if github.ref is a tag
1 parent be078f9 commit 7c9a795

1 file changed

Lines changed: 78 additions & 0 deletions

File tree

.github/workflows/publish.yml

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

0 commit comments

Comments
 (0)