1- name : Bindings Python
1+ name : Python Package Release
22
33on :
4- # # uncomment it when bendpy is enabled
54 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"
185 workflow_call :
196 inputs :
207 version :
@@ -33,9 +20,43 @@ permissions:
3320 packages : write
3421
3522jobs :
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+
3656 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]
3960 runs-on :
4061 - self-hosted
4162 - X64
@@ -52,79 +73,103 @@ jobs:
5273 # No version means development build with tests
5374
5475 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]
5779 runs-on :
5880 - self-hosted
5981 - " ${{ matrix.runner }}"
6082 - Linux
6183 - 4c16g
6284 - aws
6385 strategy :
86+ fail-fast : false
6487 matrix :
6588 include :
6689 - { arch: x86_64, runner: X64 }
67- # - { arch: aarch64, runner: ARM64 }
90+ - { arch: aarch64, runner: ARM64 }
6891 steps :
6992 - uses : actions/checkout@v4
7093 with :
7194 fetch-depth : 0
7295 - uses : ./.github/actions/build_bindings_python
7396 with :
7497 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
78100 uses : actions/upload-artifact@v4
79101 with :
80102 name : python-linux-${{ matrix.arch }}
81103 path : src/bendpy/dist/*.whl
104+ retention-days : 7
82105
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
104140
105141 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]
109145 runs-on : ubuntu-latest
110- permissions :
111- id-token : write
112- pull-requests : write
113- contents : read
114- packages : write
115146 steps :
116147 - uses : actions/checkout@v4
117148 - uses : actions/download-artifact@v4
118149 with :
119150 pattern : python-*
120151 merge-multiple : true
121152 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)"
122161
123162 - name : Publish to PyPI
124163 timeout-minutes : 10
125164 run : |
126165 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
128173 env :
129174 TWINE_USERNAME : __token__
130175 TWINE_PASSWORD : ${{ secrets.PYPI_API_TOKEN }}
0 commit comments