Skip to content

Commit d7bf43d

Browse files
committed
ci: publish to testpypi
1 parent aadecb1 commit d7bf43d

3 files changed

Lines changed: 76 additions & 34 deletions

File tree

.github/workflows/build.yml

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,60 @@
11
name: build
22

33
on:
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

934
jobs:
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 }}

.github/workflows/main.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,8 @@ jobs:
3434
run: |
3535
pytest -v
3636
37-
test-examples:
38-
runs-on: ubuntu-latest
39-
40-
steps:
41-
- name: Checkout code
42-
uses: actions/checkout@v3
43-
with:
44-
submodules: recursive
45-
token: ${{ secrets.GH_TOKEN }}
46-
47-
- name: Set up Python
48-
uses: actions/setup-python@v4
49-
with:
50-
python-version: "3.12"
51-
52-
- name: Install dependencies
37+
- name: Run examples
5338
run: |
54-
python -m pip install --upgrade pip
55-
pip install -r requirements.txt
56-
make
57-
pip install -e .
58-
5939
synapse-sim --iface-ip 127.0.0.1 --rpc-port 50051 &
6040
6141
sleep 2

.github/workflows/release.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: main
2+
3+
on:
4+
pull_request:
5+
push:
6+
tags:
7+
- 'v*'
8+
9+
permissions:
10+
id-token: write
11+
12+
jobs:
13+
test-pypi-release:
14+
uses: ./.github/workflows/build.yml
15+
with:
16+
registry-name: 'testpypi'
17+
registry-url: 'https://test.pypi.org/legacy/'
18+
package-name: 'test-science-synapse'
19+
20+
# pypi-release:
21+
# uses: ./.github/workflows/build.yml
22+
# with:
23+
# registry-name: 'pypi'
24+
# registry-url: 'https://upload.pypi.org/legacy/'
25+
# package-name: 'science-synapse'
26+
# needs: test-pypi-release

0 commit comments

Comments
 (0)