Repository navigation
93 lines (79 loc) · 2.8 KB
/
Copy pathpython-bindings.yml
File metadata and controls
93 lines (79 loc) · 2.8 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Python Bindings
on:
push:
branches: [ main ]
tags: [ v** ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
ci_checks:
name: Build checks
uses: ./.github/workflows/ci-checks.yml
build:
name: Build Python bindings
needs: ci_checks
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Cache build dependencies
uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
env:
cache-name: makefile-deps
with:
path: ~/.cache/fabric-protos
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Makefile') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('Makefile') }}
${{ runner.os }}-${{ env.cache-name }}-
- uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.12'
- name: Run make
run: make pythonbindings
- name: Set prerelease version
if: needs.ci_checks.outputs.publish_release != 'true'
working-directory: bindings/python
env:
BINDING_VERSION: ${{ needs.ci_checks.outputs.binding_version }}
GITHUB_RUN_ID: ${{ github.run_id }}
GITHUB_RUN_ATTEMPT: ${{ github.run_attempt }}
run: |
python - <<'PY'
import os
from pathlib import Path
pyproject = Path('pyproject.toml')
content = pyproject.read_text(encoding='utf-8')
version = (
f"{os.environ['BINDING_VERSION']}.dev"
f"{os.environ['GITHUB_RUN_ID']}{os.environ['GITHUB_RUN_ATTEMPT']}"
)
pyproject.write_text(content.replace(
f"version = \"{os.environ['BINDING_VERSION']}\"",
f"version = \"{version}\"",
1,
), encoding='utf-8')
print(version)
PY
- name: Install build dependencies
run: python -m pip install --upgrade build twine
- name: Build package
working-directory: bindings/python
run: python -m build
- name: Validate distribution metadata
working-directory: bindings/python
run: python -m twine check dist/*
- name: Publish to PyPI
if: github.ref == 'refs/heads/main' || needs.ci_checks.outputs.publish_release == 'true'
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
with:
packages-dir: bindings/python/dist
- name: Upload build artifact
if: github.ref != 'refs/heads/main' && needs.ci_checks.outputs.publish_release != 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: python-bindings-dist
path: bindings/python/dist/*