Skip to content

Commit 7d36860

Browse files
authored
Refactor CI/CD (#744)
* bump to aiomysql 0.0.21 * refactor CI/CD
1 parent 5435155 commit 7d36860

File tree

9 files changed

+482
-515
lines changed

9 files changed

+482
-515
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,6 @@ insert_final_newline = false
1919

2020
[Makefile]
2121
indent_style = tab
22+
23+
[.github/workflows/*.yml]
24+
indent_size = 2

.github/workflows/cd.yml

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches:
6+
- "master"
7+
- "ci"
8+
tags:
9+
- "v[0-9]+.[0-9]+"
10+
- "v[0-9]+.[0-9]+.[0-9]+"
11+
12+
jobs:
13+
create-virtualenv:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: source code
17+
uses: actions/checkout@v2
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v2
21+
22+
- name: virtualenv cache
23+
uses: syphar/restore-virtualenv@v1
24+
id: cache-virtualenv
25+
26+
- name: pip cache
27+
uses: syphar/restore-pip-download-cache@v1
28+
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
29+
30+
- name: Install Python dependencies
31+
if: steps.cache-virtualenv.outputs.cache-hit != 'true'
32+
env:
33+
POETRY_VERSION: 1.1.4
34+
run: |
35+
pip install pip==20.3.1 setuptools==50.3.2
36+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
37+
source $HOME/.poetry/env
38+
poetry install --no-interaction
39+
40+
- name: Log currently installed packages and versions
41+
run: pip list
42+
43+
build-docs:
44+
needs: create-virtualenv
45+
runs-on: ubuntu-latest
46+
strategy:
47+
matrix:
48+
language: [ 'en', 'zh' ]
49+
steps:
50+
- name: source code
51+
uses: actions/checkout@v2
52+
53+
- name: Set up Python
54+
uses: actions/setup-python@v2
55+
56+
- name: virtualenv cache
57+
uses: syphar/restore-virtualenv@v1
58+
59+
- name: Download latest translations
60+
if: matrix.language != 'en'
61+
run: |
62+
sphinx-intl create-transifexrc
63+
make -C docs -e LOC="${{ matrix.language }}" pull
64+
env:
65+
SPHINXINTL_TRANSIFEX_USERNAME: api
66+
SPHINXINTL_TRANSIFEX_PASSWORD: ${{ secrets.TRANSIFEX_TOKEN }}
67+
LOC: ${{ matrix.language }}
68+
69+
- name: Build the documentation
70+
run: |
71+
make -C docs -e SPHINXOPTS="-D language='${{ matrix.language }}' -A GAID='${{ secrets.GAID }}' -A VERSION='${{ github.ref }}'" html
72+
73+
- name: Add current version to versions.json
74+
shell: python
75+
env:
76+
LOC: ${{ matrix.language }}
77+
run: |
78+
import os, json
79+
try:
80+
with open('docs/versions.json') as f:
81+
versions = json.load(f)
82+
except Exception:
83+
versions = {}
84+
by_loc = versions.setdefault(os.environ['LOC'], [])
85+
by_loc.append(os.environ['GITHUB_REF'].split('/')[-1])
86+
by_loc.sort()
87+
with open('docs/versions.json', 'w') as f:
88+
json.dump(versions, f)
89+
print(versions)
90+
91+
- name: Publish to GitHub Pages
92+
if: github.ref != 'refs/heads/ci'
93+
uses: python-gino/ghaction-github-pages@master
94+
with:
95+
repo: python-gino/python-gino.org
96+
target_branch: master
97+
target_path: docs/${{ matrix.language }}/${{ github.ref }}
98+
keep_history: true
99+
allow_empty_commit: true
100+
build_dir: docs/_build/html
101+
commit_message: Update docs/${{ matrix.language }}/${{ github.ref }} @ ${{ github.sha }}
102+
env:
103+
GITHUB_PAT: ${{ secrets.GITHUB_PAT }}
104+
105+
release:
106+
runs-on: ubuntu-latest
107+
steps:
108+
- name: source code
109+
if: startsWith(github.ref, 'refs/tags/')
110+
uses: actions/checkout@v2
111+
112+
- name: Set up Python
113+
if: startsWith(github.ref, 'refs/tags/')
114+
uses: actions/setup-python@v2
115+
116+
- name: Release to PyPI
117+
if: startsWith(github.ref, 'refs/tags/')
118+
env:
119+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
120+
POETRY_VERSION: 1.1.4
121+
run: |
122+
pip install pip==20.3.1 setuptools==50.3.2
123+
curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python -
124+
source $HOME/.poetry/env
125+
poetry build
126+
poetry publish --username __token__ --password ${{ secrets.PYPI_TOKEN }}

0 commit comments

Comments
 (0)