Skip to content

Commit 778627c

Browse files
committed
Add release workflow
This is mostly a copy of asyncpg/release workflow
1 parent 311997e commit 778627c

13 files changed

+406
-64
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
3+
set -e -x
4+
5+
PY_MAJOR=${PYTHON_VERSION%%.*}
6+
PY_MINOR=${PYTHON_VERSION#*.}
7+
8+
ML_PYTHON_VERSION="cp${PY_MAJOR}${PY_MINOR}-cp${PY_MAJOR}${PY_MINOR}"
9+
if [ "${PY_MAJOR}" -lt "4" -a "${PY_MINOR}" -lt "8" ]; then
10+
ML_PYTHON_VERSION+="m"
11+
fi
12+
13+
# Compile wheels
14+
PYTHON="/opt/python/${ML_PYTHON_VERSION}/bin/python"
15+
PIP="/opt/python/${ML_PYTHON_VERSION}/bin/pip"
16+
"${PIP}" install --upgrade setuptools pip wheel
17+
cd "${GITHUB_WORKSPACE}"
18+
make clean
19+
"${PYTHON}" setup.py bdist_wheel
20+
21+
# Bundle external shared libraries into the wheels.
22+
for whl in "${GITHUB_WORKSPACE}"/dist/*.whl; do
23+
auditwheel repair $whl -w "${GITHUB_WORKSPACE}"/dist/
24+
rm "${GITHUB_WORKSPACE}"/dist/*-linux_*.whl
25+
done

.github/workflows/release.yml

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
name: Release
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- "master"
7+
- "ci"
8+
- "[0-9]+.[0-9x]+*"
9+
paths:
10+
- "uvloop/_version.py"
11+
12+
jobs:
13+
validate-release-request:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Validate release PR
17+
uses: edgedb/action-release/validate-pr@master
18+
id: checkver
19+
with:
20+
require_team: Release Managers
21+
require_approval: no
22+
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
23+
version_file: uvloop/_version.py
24+
version_line_pattern: |
25+
__version__\s*=\s*(?:['"])([[:PEP440:]])(?:['"])
26+
27+
- name: Stop if not approved
28+
if: steps.checkver.outputs.approved != 'true'
29+
run: |
30+
echo ::error::PR is not approved yet.
31+
exit 1
32+
33+
- name: Store release version for later use
34+
env:
35+
VERSION: ${{ steps.checkver.outputs.version }}
36+
run: |
37+
mkdir -p dist/
38+
echo "${VERSION}" > dist/VERSION
39+
40+
- uses: actions/upload-artifact@v1
41+
with:
42+
name: dist
43+
path: dist/
44+
45+
build-sdist:
46+
needs: validate-release-request
47+
runs-on: ubuntu-latest
48+
49+
steps:
50+
- uses: actions/checkout@v1
51+
with:
52+
fetch-depth: 50
53+
submodules: true
54+
55+
- name: Set up Python 3.7
56+
uses: actions/setup-python@v1
57+
with:
58+
python-version: 3.7
59+
60+
- name: Build source distribution
61+
run: |
62+
pip install -U setuptools wheel pip
63+
python setup.py sdist
64+
65+
- uses: actions/upload-artifact@v1
66+
with:
67+
name: dist
68+
path: dist/
69+
70+
build-wheels:
71+
needs: validate-release-request
72+
runs-on: ${{ matrix.os }}
73+
strategy:
74+
matrix:
75+
python-version: [3.5, 3.6, 3.7, 3.8, 3.9]
76+
os: [ubuntu-20.04, macos-latest]
77+
arch: [x86_64, aarch64]
78+
exclude:
79+
- os: macos-latest
80+
arch: aarch64
81+
82+
defaults:
83+
run:
84+
shell: bash
85+
86+
steps:
87+
- uses: actions/checkout@v1
88+
with:
89+
fetch-depth: 50
90+
submodules: true
91+
92+
- uses: actions/download-artifact@v1
93+
with:
94+
name: dist
95+
path: dist/
96+
97+
- name: Extract Release Version
98+
id: relver
99+
run: |
100+
set -e
101+
echo ::set-output name=version::$(cat dist/VERSION)
102+
rm dist/*
103+
104+
- name: Set up QEMU
105+
if: matrix.arch == 'aarch64'
106+
uses: docker/setup-qemu-action@v1
107+
108+
- name: Set up Python ${{ matrix.python-version }}
109+
uses: actions/setup-python@v1
110+
with:
111+
python-version: ${{ matrix.python-version }}
112+
113+
- name: Install Python deps
114+
run: |
115+
python -m pip install --upgrade setuptools pip wheel
116+
117+
- name: Install macOS deps
118+
if: startsWith(matrix.os, 'macos')
119+
run: |
120+
brew install gnu-sed libtool autoconf automake
121+
122+
- name: Build Wheels (linux)
123+
if: startsWith(matrix.os, 'ubuntu')
124+
env:
125+
PYTHON_VERSION: ${{ matrix.python-version }}
126+
ARCH: ${{ matrix.arch }}
127+
run: |
128+
case "${ARCH}" in
129+
x86_64)
130+
mlimg=manylinux2010_x86_64
131+
;;
132+
aarch64)
133+
mlimg=manylinux2014_aarch64
134+
;;
135+
*)
136+
echo "Unsupported wheel arch: ${ARCH}" >&2
137+
exit 1
138+
;;
139+
esac
140+
141+
docker run --rm \
142+
-v "${GITHUB_WORKSPACE}":/github/workspace:rw \
143+
--workdir=/github/workspace \
144+
-e GITHUB_WORKSPACE=/github/workspace \
145+
-e PYTHON_VERSION="${PYTHON_VERSION}" \
146+
--entrypoint=/github/workspace/.github/workflows/build-manylinux-wheels.sh \
147+
quay.io/pypa/${mlimg}
148+
149+
- name: Build Wheels (non-linux)
150+
if: "!startsWith(matrix.os, 'ubuntu')"
151+
run: |
152+
make clean
153+
python setup.py bdist_wheel
154+
155+
- name: Test Wheels (native)
156+
timeout-minutes: 10
157+
if: |
158+
!contains(github.event.pull_request.labels.*.name, 'skip wheel tests')
159+
&& matrix.arch == 'x86_64'
160+
env:
161+
OS: ${{ matrix.os }}
162+
PKG_VERSION: ${{ steps.relver.outputs.version }}
163+
run: |
164+
"${GITHUB_WORKSPACE}/.github/workflows/test-wheels.sh"
165+
166+
- name: Test Wheels (emulated)
167+
timeout-minutes: 30
168+
if: |
169+
!contains(github.event.pull_request.labels.*.name, 'skip wheel tests')
170+
&& matrix.arch != 'x86_64'
171+
env:
172+
PYTHON_VERSION: ${{ matrix.python-version }}
173+
ARCH: ${{ matrix.arch }}
174+
PKG_VERSION: ${{ steps.relver.outputs.version }}
175+
run: |
176+
case "${ARCH}" in
177+
aarch64)
178+
img="docker.io/arm64v8/python:${PYTHON_VERSION}-buster"
179+
;;
180+
*)
181+
echo "Unsupported wheel arch: ${ARCH}" >&2
182+
exit 1
183+
;;
184+
esac
185+
186+
docker run --rm \
187+
-v "${GITHUB_WORKSPACE}":/github/workspace:rw \
188+
-e GITHUB_WORKSPACE=/github/workspace \
189+
-e PKG_VERSION="${PKG_VERSION}" \
190+
--workdir=/github/workspace/ \
191+
${img} \
192+
/bin/bash -ex -c ' \
193+
echo GITHUB_WORKSPACE=${GITHUB_WORKSPACE} >> /etc/environment \
194+
&& echo PKG_VERSION=${PKG_VERSION} >> /etc/environment \
195+
&& echo ENVIRON_FILE /etc/environment >> /etc/login.defs \
196+
&& useradd -m -s /bin/bash test \
197+
&& su -l test /github/workspace/.github/workflows/test-wheels.sh \
198+
'
199+
200+
- uses: actions/upload-artifact@v1
201+
with:
202+
name: dist
203+
path: dist/
204+
205+
publish:
206+
needs: [build-sdist, build-wheels]
207+
runs-on: ubuntu-latest
208+
209+
steps:
210+
- uses: actions/checkout@v1
211+
with:
212+
fetch-depth: 5
213+
submodules: false
214+
215+
- uses: actions/download-artifact@v1
216+
with:
217+
name: dist
218+
path: dist/
219+
220+
- name: Extract Release Version
221+
id: relver
222+
run: |
223+
set -e
224+
echo ::set-output name=version::$(cat dist/VERSION)
225+
rm dist/VERSION
226+
227+
- name: Merge and tag the PR
228+
uses: edgedb/action-release/merge@master
229+
with:
230+
github_token: ${{ secrets.RELEASE_BOT_GITHUB_TOKEN }}
231+
ssh_key: ${{ secrets.RELEASE_BOT_SSH_KEY }}
232+
gpg_key: ${{ secrets.RELEASE_BOT_GPG_KEY }}
233+
gpg_key_id: "5C468778062D87BF!"
234+
tag_name: v${{ steps.relver.outputs.version }}
235+
236+
- name: Publish Github Release
237+
uses: elprans/gh-action-create-release@master
238+
env:
239+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
240+
with:
241+
tag_name: v${{ steps.relver.outputs.version }}
242+
release_name: v${{ steps.relver.outputs.version }}
243+
target: ${{ github.event.pull_request.base.ref }}
244+
body: ${{ github.event.pull_request.body }}
245+
draft: false
246+
247+
- run: |
248+
ls -al dist/
249+
250+
- name: Upload to PyPI
251+
uses: pypa/gh-action-pypi-publish@master
252+
with:
253+
user: __token__
254+
password: ${{ secrets.PYPI_TOKEN }}
255+
# password: ${{ secrets.TEST_PYPI_TOKEN }}
256+
# repository_url: https://test.pypi.org/legacy/

.github/workflows/test-requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/test-wheels.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
3+
set -Eexuo pipefail
4+
shopt -s nullglob
5+
6+
pip install -f "file:///${GITHUB_WORKSPACE}/dist" "uvloop[test]==${PKG_VERSION}"
7+
make -C "${GITHUB_WORKSPACE}" testinstalled

.github/workflows/tests.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,23 @@ jobs:
4444
run: |
4545
brew install gnu-sed libtool autoconf automake
4646
47-
- uses: syphar/restore-virtualenv@v1
48-
if: steps.release.outputs.version == 0
49-
id: cache-virtualenv
50-
with:
51-
requirement_files: .github/workflows/test-requirements.txt
52-
5347
- name: Install Python Deps
54-
if: steps.release.outputs.version == 0 && steps.cache-virtualenv.outputs.cache-hit != 'true'
48+
if: steps.release.outputs.version == 0
5549
run: |
56-
pip install --upgrade setuptools pip wheel
57-
pip install -U -r .github/workflows/test-requirements.txt
50+
pip install -e .[test]
5851
5952
- name: Test
6053
if: steps.release.outputs.version == 0
6154
run: |
6255
make distclean && make && make test
6356
make distclean && make debug && make test
57+
58+
# This job exists solely to act as the test job aggregate to be
59+
# targeted by branch policies.
60+
regression-tests:
61+
name: "Regression Tests"
62+
needs: [test]
63+
runs-on: ubuntu-20.04
64+
65+
steps:
66+
- run: echo OK

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ docs/_build
3030
uvloop/loop.*.pyd
3131
/.pytest_cache/
3232
/.mypy_cache/
33-
33+
/.vscode
34+
/.eggs

Makefile

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
PYTHON ?= python
5+
ROOT = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))
56

67

78
_default: compile
@@ -51,8 +52,4 @@ test:
5152

5253

5354
testinstalled:
54-
$(PYTHON) tests/__init__.py
55-
56-
57-
release: distclean compile test
58-
$(PYTHON) setup.py sdist bdist_wheel upload
55+
cd "$${HOME}" && $(PYTHON) $(ROOT)/tests/__init__.py

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ To build uvloop, you'll need Python 3.5 or greater:
9292

9393
.. code::
9494
95-
$ pip install -r requirements.dev.txt
95+
$ pip install -e .[dev]
9696
9797
4. Build and run tests:
9898

requirements.dev.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)