@@ -24,8 +24,8 @@ permissions:
2424# A workflow run is made up of one or more jobs that can run sequentially or in parallel
2525jobs :
2626 build_and_test_python :
27- continue-on-error : true
2827 strategy :
28+ fail-fast : false
2929 matrix :
3030 python-version : ['3.8', '3.9', '3.10', '3.11', '3.12']
3131 compiler : ['gcc', 'clang']
@@ -48,57 +48,145 @@ jobs:
4848
4949 # Steps represent a sequence of tasks that will be executed as part of the job
5050 steps :
51- # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
52- - uses : actions/checkout@v4
53-
54- - name : Set up Python ${{ matrix.python-version }}
55- uses : actions/setup-python@v5
56- with :
57- python-version : ${{ matrix.python-version }}
58-
59- - name : Install dependencies
60- run : |
61- python -m pip install --upgrade pip
62- pip install setuptools wheel
63- shell : bash
64-
65- - name : build
66- run : CC=${COMPILER} LDSHARED="${COMPILER} -shared" python setup.py build sdist
67- shell : bash
68-
69- - name : install
70- run : pip install dist/*.gz
71- shell : bash
72-
73- - name : test
74- run : |
75- python -m unittest discover -v -s tests -p '*.py'
76- shell : bash
77-
78- publish_wheels :
51+ # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
52+ - uses : actions/checkout@v4
53+
54+ - name : Set up Python ${{ matrix.python-version }}
55+ uses : actions/setup-python@v5
56+ with :
57+ python-version : ${{ matrix.python-version }}
58+
59+ - name : Install dependencies
60+ run : |
61+ python -m pip install --upgrade pip
62+ pip install --upgrade build setuptools wheel
63+ shell : bash
64+
65+ - name : build
66+ run : CC=${COMPILER} LDSHARED="${COMPILER} -shared" python setup.py build sdist
67+ shell : bash
68+
69+ - name : install
70+ run : pip install dist/*.gz
71+ shell : bash
72+
73+ - name : test
74+ run : |
75+ python -m unittest discover -v -s tests -p '*.py'
76+ shell : bash
77+
78+ build_bin_wheels :
7979 needs : build_and_test_python
80- if : github.event_name == 'release' && github.event.action == 'created'
80+ runs-on : ubuntu-latest
81+ permissions :
82+ packages : write
83+ env :
84+ PY_VER : ${{ matrix.python-version }}
85+ BASE_IMAGE : quay.io/pypa/manylinux_2_28:latest
86+ GHCR_REPO : ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}
87+ strategy :
88+ fail-fast : false
89+ matrix :
90+ python-version : ['3.8', '3.9', '3.11', '3.12']
91+ steps :
92+ - name : Set up Python ${{ env.PY_VER }}
93+ uses : actions/setup-python@v5
94+ with :
95+ python-version : ${{ env.PY_VER }}
96+
97+ - uses : actions/checkout@v4
98+
99+ - name : Set up QEMU
100+ uses : docker/setup-qemu-action@v3
101+
102+ - name : Set up Docker Buildx
103+ uses : docker/setup-buildx-action@v3
104+
105+ - name : Login to GitHub Container Registry
106+ uses : docker/login-action@v3
107+ with :
108+ registry : ghcr.io
109+ username : ${{ github.repository_owner }}
110+ password : ${{ secrets.GITHUB_TOKEN }}
111+
112+ - name : Set dynamic environment
113+ id : set-env
114+ run : |
115+ PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \
116+ jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \
117+ sort -u | grep -v unknown | paste -sd ','`"
118+ GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
119+ GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
120+ BUILD_IMAGE="${GHCR_REPO}:${GIT_BRANCH}-py${PY_VER}"
121+ echo "Platforms: ${PLATFORMS}"
122+ echo "Build Image: ${BUILD_IMAGE}"
123+ echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
124+ echo "BUILD_IMAGE=${BUILD_IMAGE}" >> $GITHUB_ENV
125+
126+ - name : Build Docker image
127+ uses : docker/build-push-action@v6
128+ env :
129+ CACHE_SPEC : " type=registry,ref=${{ env.BUILD_IMAGE }}-buildcache"
130+ with :
131+ context : .
132+ file : ./docker/Dockerfile.python_wheels
133+ build-args : |
134+ BASE_IMAGE=${{ env.BASE_IMAGE }}
135+ PY_VER=${{ env.PY_VER }}
136+ platforms : ${{ env.PLATFORMS }}
137+ push : false
138+ outputs : type=local,dest=dist_out
139+ cache-from : ${{ env.CACHE_SPEC }}
140+ cache-to : ${{ env.CACHE_SPEC }},mode=max
141+
142+ - name : Collect Wheels
143+ run : |
144+ mkdir dist
145+ mv `find dist_out -type f -name \*.whl` dist
146+ rm -r dist_out
147+
148+ - name : Upload built wheels
149+ uses : actions/upload-artifact@v4
150+ with :
151+ name : dist-${{ env.PY_VER }}
152+ path : dist
153+
154+ publish_pypi :
155+ needs : build_bin_wheels
81156 runs-on : ubuntu-latest
82157 environment :
83158 name : pypi
84159 url : https://pypi.org/p/asyncproxy
85160 permissions :
86161 id-token : write
162+ actions : read
163+ contents : read
87164 steps :
88- - uses : actions/checkout@v4
89-
90- - name : Set up Python
91- uses : actions/setup-python@v5
92- with :
93- python-version : ' 3.12'
94-
95- - name : Install dependencies
96- run : |
97- python -m pip install --upgrade pip
98- pip install setuptools wheel
99-
100- - name : build
101- run : python setup.py build sdist
102-
103- - name : Publish package distributions to PyPI
104- uses : pypa/gh-action-pypi-publish@release/v1
165+ - uses : actions/checkout@v4
166+
167+ - name : Download all wheel artifacts
168+ uses : actions/download-artifact@v4
169+ with :
170+ path : dist
171+ pattern : dist-*
172+ merge-multiple : true
173+
174+ - name : Set up Python
175+ uses : actions/setup-python@v5
176+ with :
177+ python-version : ' 3.x'
178+
179+ - name : Install dependencies
180+ run : |
181+ python -m pip install --upgrade pip
182+ pip install --upgrade build setuptools wheel
183+
184+ - name : build
185+ run : python setup.py build sdist
186+
187+ - name : Show context tree
188+ run : ls -R dist
189+
190+ - name : Publish package distributions to PyPI
191+ if : github.event_name == 'release' && github.event.action == 'created'
192+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments