-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (86 loc) · 2.94 KB
/
Copy pathpython-ci.yml
File metadata and controls
110 lines (86 loc) · 2.94 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
name: Python Client CI
on:
push:
branches: [main]
paths:
- 'clients/python/**'
- 'spec/**'
- '.github/workflows/python-ci.yml'
pull_request:
branches: [main]
paths:
- 'clients/python/**'
- 'spec/**'
- '.github/workflows/python-ci.yml'
jobs:
build-and-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: clients/python
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install pipx
run: pip install pipx
- name: Generate client from spec
working-directory: .
run: ./scripts/generate.sh
- name: Copy generated code into package
run: rm -rf src/ros2_medkit_client/_generated && cp -r generated src/ros2_medkit_client/_generated
- name: Install package with dev deps
run: pip install -e '.[dev]'
- name: Test
run: python -m pytest -v
- name: Lint
run: ruff check src/ tests/
- name: Format check
run: ruff format --check src/ tests/
publish:
needs: build-and-test
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: write
defaults:
run:
working-directory: clients/python
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install build tools
run: pip install pipx build
- name: Generate client from spec
working-directory: .
run: ./scripts/generate.sh
- name: Copy generated code into package
run: rm -rf src/ros2_medkit_client/_generated && cp -r generated src/ros2_medkit_client/_generated
- name: Build wheel
run: python -m build
- name: Read version
id: version
run: |
VERSION=$(python3 -c "import re, pathlib; text = pathlib.Path('pyproject.toml').read_text(); m = re.search(r'^version\s*=\s*\"([^\"]+)\"', text, re.MULTILINE); print(m.group(1))")
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Publish wheel to GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TAG="py-v${{ steps.version.outputs.version }}"
# Delete existing release if same version (overwrite)
gh release delete "$TAG" --yes 2>/dev/null || true
# Create release and upload wheel
gh release create "$TAG" \
--title "Python client v${{ steps.version.outputs.version }}" \
--notes "Install: \`pip install https://github.com/selfpatch/ros2_medkit_clients/releases/download/${TAG}/$(ls dist/*.whl | head -1 | xargs basename)\`" \
dist/*.whl