-
Notifications
You must be signed in to change notification settings - Fork 12
188 lines (158 loc) · 5.93 KB
/
Copy pathpython-package.yml
File metadata and controls
188 lines (158 loc) · 5.93 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
name: Python Package Build and Release
##on tag creation
on:
push:
tags:
- 'v*' # Run on any tag starting with 'v' (e.g., v1.0.0)
jobs:
build:
name: Build Package
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
python-version: ['3.9', '3.10', '3.11']
exclude:
# Exclude combinations that might not be compatible
- os: macos-latest
python-version: '3.9'
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for proper versioning
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install build wheel setuptools twine
- name: Install package dependencies
run: |
python -m pip install numpy==1.26.4 genesis-world==0.2.1 numba==0.60.0 'robot_descriptions>=1.12' pytest pytest-cov
# Install PyTorch based on OS
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
# For Linux, use CPU-only PyTorch from specific URL
python -m pip install torch==2.0.1+cpu torchvision==0.15.2+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
else
# For macOS, use standard PyTorch package
python -m pip install torch==2.0.1 torchvision==0.15.2
fi
# Verify numpy is installed
python -c "import numpy; print(f'NumPy version: {numpy.__version__}')"
- name: Install package in development mode
run: |
python -m pip install -e .
- name: Run tests
run: |
python -m pytest tests/test_commands_mock.py tests/test_robot_state.py -v
- name: Build package
run: python -m build --sdist --wheel
env:
# Force setuptools_scm to use the tag version
SETUPTOOLS_SCM_PRETEND_VERSION: ${{ github.ref_name }}
- name: Get package version
id: get_version
run: |
# Extract the version from the git tag (e.g., refs/tags/v1.0.0 -> 1.0.0)
VERSION=$(echo ${{ github.ref }} | sed 's/refs\/tags\/v//')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "version=$VERSION" >> $GITHUB_OUTPUT
shell: bash
- name: Rename wheel for architecture and Python version
run: |
mkdir -p dist_renamed
cd dist
for wheel in *.whl; do
# Extract Python version tag (e.g., py3 -> cp39, cp310, etc.)
PY_SHORT="${{ matrix.python-version }}"
# Remove the dot (e.g., 3.9 -> 39, 3.10 -> 310)
PY_VER_NO_DOT="${PY_SHORT//./}"
# Create Python tag (e.g., cp39)
PY_TAG="cp${PY_VER_NO_DOT}"
# Extract the platform tag
if [[ "${{ matrix.os }}" == "ubuntu-latest" ]]; then
PLATFORM_TAG="manylinux2014_x86_64"
elif [[ "${{ matrix.os }}" == "macos-latest" ]]; then
PLATFORM_TAG="macosx_11_0_universal2"
# Windows platform tag removed since it's not supported
fi
# Rename wheel with correct platform tag and Python version
NEW_NAME=$(echo $wheel | sed -E "s/-py3-none-any.whl/-${PY_TAG}-${PY_TAG}-$PLATFORM_TAG.whl/")
cp $wheel ../dist_renamed/$NEW_NAME
done
shell: bash
- name: Upload built packages as artifacts
uses: actions/upload-artifact@v4
with:
name: python-package-${{ matrix.os }}-${{ matrix.python-version }}
path: |
dist_renamed/*.whl
dist/*.tar.gz
publish:
name: Publish Release
needs: build
runs-on: ubuntu-latest
permissions:
contents: write # Needed to create releases
id-token: write # Needed for trusted publishing to PyPI
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare packages for release
run: |
mkdir -p release_packages
find artifacts -name "*.whl" -o -name "*.tar.gz" | xargs -I{} cp {} release_packages/
- name: Get release info
id: get_release_info
run: |
# Extract tag name from GITHUB_REF (e.g., refs/tags/v1.0.0 -> v1.0.0)
TAG=${GITHUB_REF#refs/tags/}
echo "tag=$TAG" >> $GITHUB_OUTPUT
# Extract version without 'v' prefix (e.g., v1.0.0 -> 1.0.0)
VERSION=${TAG#v}
echo "version=$VERSION" >> $GITHUB_OUTPUT
shell: bash
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ steps.get_release_info.outputs.tag }}
name: Release ${{ steps.get_release_info.outputs.tag }}
draft: false
prerelease: false
files: release_packages/*
body: |
# franka-sim ${{ steps.get_release_info.outputs.version }}
A high-fidelity Genesis simulation server that communicates with the Franka robot's network protocol, enabling seamless switching between simulation and hardware.
## Installation
```bash
pip install franka-sim==${{ steps.get_release_info.outputs.version }}
```
## Documentation
See the [README](https://github.com/BarisYazici/libfranka-sim#readme) for more information.
pypi:
name: Publish to PyPI
needs: [build, publish]
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare packages for PyPI
run: |
mkdir -p dist
find artifacts -name "*.whl" -o -name "*.tar.gz" | xargs -I{} cp {} dist/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
skip-existing: true