11name : build
22
33on :
4- pull_request :
5- push :
6- tags :
7- - ' v*'
4+ workflow_call :
5+ inputs :
6+ registry-name :
7+ description : ' Name of the registry (e.g., pypi, testpypi)'
8+ required : true
9+ type : string
10+ registry-url :
11+ description : ' URL of the registry'
12+ required : true
13+ type : string
14+ package-name :
15+ description : ' Name of the package'
16+ required : true
17+ type : string
18+ python-versions :
19+ description : ' Python versions to build for'
20+ required : false
21+ type : string
22+ default : |
23+ 3.9
24+ 3.10
25+ 3.11
26+ 3.12
27+ 3.13
28+ runner-os :
29+ description : ' Runner operating systems'
30+ required : false
31+ type : string
32+ default : ' ["ubuntu-latest", "ubuntu-24.04-arm", "windows-latest", "macos-13", "macos-latest"]'
833
934jobs :
1035 build_wheels :
1136 name : Build wheels on ${{ matrix.os }}
1237 runs-on : ${{ matrix.os }}
1338 strategy :
1439 matrix :
15- os : [ubuntu-latest, ubuntu-24.04-arm, windows-latest, macos-13, macos-latest]
40+ os : ${{ fromJson(inputs.runner-os) }}
1641
1742 steps :
1843 - uses : actions/checkout@v4
1944
2045 - uses : actions/setup-python@v5
46+ with :
47+ python-version : ${{ inputs.python-versions }}
48+
49+ - name : Update package name in setup.py and cli
50+ if : ${{ inputs.package-name != 'science-synapse' }}
51+ run : |
52+ if [ -f "setup.py" ]; then
53+ sed -i "s/science-synapse/${{ inputs.package-name }}/g" setup.py
54+ fi
55+ if [ -f "synapse/cli/__main__.py" ]; then
56+ sed -i "s/science-synapse/${{ inputs.package-name }}/g" synapse/cli/__main__.py
57+ fi
2158
2259 - name : Install cibuildwheel
2360 run : python -m pip install cibuildwheel==2.22.0
@@ -27,32 +64,31 @@ jobs:
2764
2865 - uses : actions/upload-artifact@v4
2966 with :
30- name : cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
67+ name : cibw-wheels-${{ inputs.package-name }}-${{ matrix.os }}-${{ strategy.job-index }}
3168 path : ./wheelhouse/*.whl
3269
3370 publish :
34- name : Upload wheels to PyPI
71+ name : Upload wheels to ${{ inputs.registry-name }}
3572 needs : [build_wheels]
3673 runs-on : ubuntu-latest
3774 environment :
38- name : testpypi
39- url : https://testpypi.org/p/science-synapse
75+ name : ${{ inputs.registry-name }}
76+ url : ${{ inputs.registry-url }}/${{ inputs.package-name }}
4077 permissions :
4178 id-token : write
42- if : false
4379 # if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
4480
4581 steps :
4682 - uses : actions/download-artifact@v4
4783 with :
48- pattern : cibw-wheels-*
84+ pattern : cibw-wheels-${{ inputs.package-name }} *
4985 path : dist
5086 merge-multiple : true
5187
5288 - name : List wheels
5389 run : ls -la dist/
5490
55- - name : Publish package distributions to PyPI
91+ - name : Publish package distributions to ${{ inputs.registry-name }}
5692 uses : pypa/gh-action-pypi-publish@release/v1
5793 with :
58- repository-url : https://test.pypi.org/legacy/
94+ repository-url : ${{ inputs.registry-url }}
0 commit comments