@@ -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,147 @@ 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+ if : github.event_name != 'pull_request'
108+ with :
109+ registry : ghcr.io
110+ username : ${{ github.repository_owner }}
111+ password : ${{ secrets.GITHUB_TOKEN }}
112+
113+ - name : Set dynamic environment
114+ id : set-env
115+ run : |
116+ PLATFORMS="`docker manifest inspect ${{ env.BASE_IMAGE }} | \
117+ jq -r '.manifests[] | "\(.platform.os)/\(.platform.architecture)\(if .platform.variant != null then "/\(.platform.variant)" else "" end)"' | \
118+ sort -u | grep -v unknown | paste -sd ','`"
119+ GIT_BRANCH="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
120+ GIT_BRANCH="${GIT_BRANCH#refs/tags/}"
121+ BUILD_IMAGE="${GHCR_REPO}:${GIT_BRANCH}-py${PY_VER}"
122+ test "${{ github.event_name }}" != 'pull_request' && \
123+ CACHE_SPEC="type=registry,ref=${BUILD_IMAGE}-buildcache" || \
124+ CACHE_SPEC="gha"
125+ echo "Platforms: ${PLATFORMS}"
126+ echo "Build Image: ${BUILD_IMAGE}"
127+ echo "PLATFORMS=${PLATFORMS}" >> $GITHUB_ENV
128+ echo "CACHE_SPEC=${CACHE_SPEC}" >> $GITHUB_ENV
129+
130+ - name : Build Binary Wheels
131+ uses : docker/build-push-action@v6
132+ with :
133+ context : .
134+ file : ./docker/Dockerfile.python_wheels
135+ build-args : |
136+ BASE_IMAGE=${{ env.BASE_IMAGE }}
137+ PY_VER=${{ env.PY_VER }}
138+ platforms : ${{ env.PLATFORMS }}
139+ push : false
140+ outputs : type=local,dest=dist_out
141+ cache-from : ${{ env.CACHE_SPEC }}
142+ cache-to : ${{ env.CACHE_SPEC }},mode=max
143+
144+ - name : Collect Wheels
145+ run : |
146+ mkdir dist
147+ mv `find dist_out -type f -name \*.whl` dist
148+ rm -r dist_out
149+
150+ - name : Upload built wheels
151+ uses : actions/upload-artifact@v4
152+ with :
153+ name : dist-${{ env.PY_VER }}
154+ path : dist
155+
156+ publish_pypi :
157+ needs : build_bin_wheels
81158 runs-on : ubuntu-latest
82159 environment :
83160 name : pypi
84161 url : https://pypi.org/p/asyncproxy
85162 permissions :
86163 id-token : write
164+ actions : read
165+ contents : read
87166 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
167+ - uses : actions/checkout@v4
168+
169+ - name : Download all wheel artifacts
170+ uses : actions/download-artifact@v4
171+ with :
172+ path : dist
173+ pattern : dist-*
174+ merge-multiple : true
175+
176+ - name : Set up Python
177+ uses : actions/setup-python@v5
178+ with :
179+ python-version : ' 3.x'
180+
181+ - name : Install dependencies
182+ run : |
183+ python -m pip install --upgrade pip
184+ pip install --upgrade build setuptools wheel
185+
186+ - name : build
187+ run : python setup.py build sdist
188+
189+ - name : Show context tree
190+ run : ls -R dist
191+
192+ - name : Publish package distributions to PyPI
193+ if : github.event_name == 'release' && github.event.action == 'created'
194+ uses : pypa/gh-action-pypi-publish@release/v1
0 commit comments