1
- name : Bindings Python
1
+ name : Python Package Release
2
2
3
3
on :
4
- # # uncomment it when bendpy is enabled
5
4
workflow_dispatch :
6
- inputs :
7
- version :
8
- description : Version to release (optional for testing)
9
- required : false
10
- type : string
11
- default : " test-build"
12
- pull_request :
13
- branches :
14
- - main
15
- paths :
16
- - " src/**"
17
- - " .github/workflows/bindings.python.yml"
18
5
workflow_call :
19
6
inputs :
20
7
version :
@@ -33,9 +20,43 @@ permissions:
33
20
packages : write
34
21
35
22
jobs :
23
+ get-version :
24
+ name : Determine Version
25
+ if : (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
26
+ runs-on : ubuntu-latest
27
+ outputs :
28
+ version : ${{ steps.version.outputs.version }}
29
+ steps :
30
+ - uses : actions/checkout@v4
31
+ with :
32
+ fetch-depth : 0
33
+ - name : Get and validate version
34
+ id : version
35
+ shell : bash
36
+ run : |
37
+ if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
38
+ VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.1.0")
39
+ echo "Using latest tag for manual trigger: $VERSION"
40
+ elif [[ "${{ github.event_name }}" == "workflow_call" && -n "${{ inputs.version }}" ]]; then
41
+ VERSION="${{ inputs.version }}"
42
+ echo "Using provided version from workflow_call: $VERSION"
43
+ else
44
+ echo "Error: No version provided for workflow_call"
45
+ exit 1
46
+ fi
47
+
48
+ # Validate version format
49
+ if [[ ! $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+.*$ ]]; then
50
+ echo "Warning: Version $VERSION may not follow semantic versioning (vX.Y.Z)"
51
+ fi
52
+
53
+ echo "Final version: $VERSION"
54
+ echo "version=$VERSION" >> $GITHUB_OUTPUT
55
+
36
56
test :
37
- # Run tests on all PRs and workflow dispatches
38
- if : github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
57
+ name : Run Tests
58
+ if : (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
59
+ needs : [get-version]
39
60
runs-on :
40
61
- self-hosted
41
62
- X64
@@ -52,79 +73,103 @@ jobs:
52
73
# No version means development build with tests
53
74
54
75
linux :
55
- # Only run for version builds (releases)
56
- if : inputs.version
76
+ name : Build Linux Wheels
77
+ if : (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
78
+ needs : [get-version, test]
57
79
runs-on :
58
80
- self-hosted
59
81
- " ${{ matrix.runner }}"
60
82
- Linux
61
83
- 4c16g
62
84
- aws
63
85
strategy :
86
+ fail-fast : false
64
87
matrix :
65
88
include :
66
89
- { arch: x86_64, runner: X64 }
67
- # - { arch: aarch64, runner: ARM64 }
90
+ - { arch: aarch64, runner: ARM64 }
68
91
steps :
69
92
- uses : actions/checkout@v4
70
93
with :
71
94
fetch-depth : 0
72
95
- uses : ./.github/actions/build_bindings_python
73
96
with :
74
97
target : ${{ matrix.arch }}-unknown-linux-gnu
75
- version : ${{ inputs.version }}
76
- - name : upload
77
- if : inputs.version
98
+ version : ${{ needs.get-version.outputs.version }}
99
+ - name : Upload Linux wheel
78
100
uses : actions/upload-artifact@v4
79
101
with :
80
102
name : python-linux-${{ matrix.arch }}
81
103
path : src/bendpy/dist/*.whl
104
+ retention-days : 7
82
105
83
- # macos:
84
- # if: inputs.version
85
- # runs-on: macos-latest
86
- # strategy:
87
- # matrix:
88
- # arch:
89
- # - aarch64
90
- # steps:
91
- # - uses: actions/checkout@v4
92
- # with:
93
- # fetch-depth: 0
94
- # - uses: ./.github/actions/build_bindings_python
95
- # with:
96
- # target: ${{ matrix.arch }}-apple-darwin
97
- # version: ${{ inputs.version }}
98
- # - name: upload
99
- # if: inputs.version
100
- # uses: actions/upload-artifact@v4
101
- # with:
102
- # name: python-macos-${{ matrix.arch }}
103
- # path: src/bendpy/dist/*.whl
106
+ macos :
107
+ name : Build macOS Wheels
108
+ if : (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
109
+ needs : [get-version, test]
110
+ runs-on : macos-latest
111
+ continue-on-error : true
112
+ strategy :
113
+ matrix :
114
+ target : [x86_64-apple-darwin, aarch64-apple-darwin]
115
+ steps :
116
+ - uses : actions/checkout@v4
117
+ with :
118
+ fetch-depth : 0
119
+
120
+ - name : Install dependencies
121
+ run : |
122
+ # Install OpenSSL and necessary tools
123
+ brew install openssl@3
124
+
125
+ # Use vendored OpenSSL to avoid cross-compilation issues
126
+ echo "OPENSSL_STATIC=1" >> $GITHUB_ENV
127
+ echo "OPENSSL_VENDORED=1" >> $GITHUB_ENV
128
+ echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV
129
+
130
+ - uses : ./.github/actions/build_bindings_python
131
+ with :
132
+ target : ${{ matrix.target }}
133
+ version : ${{ needs.get-version.outputs.version }}
134
+ - name : Upload macOS wheel
135
+ uses : actions/upload-artifact@v4
136
+ with :
137
+ name : python-macos-${{ matrix.target }}
138
+ path : src/bendpy/dist/*.whl
139
+ retention-days : 7
104
140
105
141
publish :
106
- if : inputs.version
107
- name : Publish
108
- needs : [linux]
142
+ name : Publish to PyPI
143
+ if : (github.event_name == 'workflow_call' && inputs.version != '') || github.event_name == 'workflow_dispatch'
144
+ needs : [get-version, test, linux]
109
145
runs-on : ubuntu-latest
110
- permissions :
111
- id-token : write
112
- pull-requests : write
113
- contents : read
114
- packages : write
115
146
steps :
116
147
- uses : actions/checkout@v4
117
148
- uses : actions/download-artifact@v4
118
149
with :
119
150
pattern : python-*
120
151
merge-multiple : true
121
152
path : src/bendpy/dist
153
+ continue-on-error : true
154
+
155
+ - name : Show packages to publish
156
+ run : |
157
+ echo "Publishing packages for version: ${{ needs.get-version.outputs.version }}"
158
+ echo "Packages found:"
159
+ ls -la src/bendpy/dist/ || echo "No packages found"
160
+ echo "Total packages: $(ls src/bendpy/dist/*.whl 2>/dev/null | wc -l)"
122
161
123
162
- name : Publish to PyPI
124
163
timeout-minutes : 10
125
164
run : |
126
165
pip install twine
127
- twine upload --skip-existing --verbose src/bendpy/dist/*.whl
166
+ echo "Publishing to PyPI..."
167
+ if [ -n "$(find src/bendpy/dist -name "*.whl" 2>/dev/null)" ]; then
168
+ twine upload --skip-existing --verbose src/bendpy/dist/*.whl
169
+ else
170
+ echo "No wheel files found to publish"
171
+ exit 1
172
+ fi
128
173
env :
129
174
TWINE_USERNAME : __token__
130
175
TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments