|
| 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/ |
0 commit comments