Repository navigation
65 lines (55 loc) · 1.76 KB
/
Copy pathpython-client-release.yaml
File metadata and controls
65 lines (55 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: release-python-client
on:
workflow_dispatch:
permissions:
contents: read
jobs:
build:
name: Build Python Client
runs-on: ubuntu-latest
steps:
- name: Error if not a tag
uses: actions/github-script@v9
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
with:
script: core.setFailed('This action can only be run on tags')
- name: Checkout
uses: actions/checkout@v6
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.x"
- name: Set version from tag
working-directory: clients/kuberay-client
run: |
python -m pip install packaging
VERSION=$(python -c 'import os; from packaging.version import Version; print(Version(os.environ["GITHUB_REF_NAME"]))')
sed -i "s/^version = .*/version = \"${VERSION}\"/" pyproject.toml
sed -i "s/^__version__ = .*/__version__ = \"${VERSION}\"/" kuberay_client/__init__.py
- name: Build
working-directory: clients/kuberay-client
run: |
python -m pip install build
python -m build
- name: Upload Artifact Python Client
uses: actions/upload-artifact@v7
with:
name: kuberay_client_dist
path: clients/kuberay-client/dist/
publish-pypi:
name: Publish Python Client to PyPI
needs: build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/kuberay-client
permissions:
id-token: write
steps:
- name: Download Artifact Python Client
uses: actions/download-artifact@v8
with:
name: kuberay_client_dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1