-
Notifications
You must be signed in to change notification settings - Fork 0
193 lines (172 loc) · 5.69 KB
/
push.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
name: Push
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
PROJECT_NAME: flogging
VERSION_FILE: flogging/version.py
DEFAULT_BRANCH: main
BOT_NAME: fragile-bot
BOT_EMAIL: bot@fragile.tech
BOT_AUTH_TOKEN: ${{ secrets.BOT_AUTH_TOKEN }}
TEST_PYPI_PASS: ${{ secrets.TEST_PYPI_PASS }}
PYPI_PASS: ${{ secrets.PYPI_PASS }}
DOCKER_ORG: fragiletech
DOCKER_USERNAME: ${{ secrets.DOCKERHUB_LOGIN }}
DOCKER_PASSWORD: ${{ secrets.DOCKERHUB_PASS }}
jobs:
Style-check:
if: "!contains(github.event.head_commit.message, 'Bump version')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: "3.8"
- name: Install lint dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements-lint.txt ]; then pip install -r requirements-lint.txt; fi
- name: Run style check and linter
run: |
make check
Pytest:
needs: Style-check
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.9']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install test and package dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements-test.txt ]; then pip install -r requirements-test.txt; fi
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
pip install .
- name: Test with pytest
run: |
pytest --cov=./ --cov-report=xml
- name: Upload coverage report
if: ${{ matrix.python-version=='3.8' }}
uses: codecov/codecov-action@v1
Build-pypi:
needs: Style-check
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel bumpversion
- name: Create unique version for test.pypi
run: |
set -e
git pull --no-edit origin $DEFAULT_BRANCH
current_version=$(grep __version__ $VERSION_FILE | cut -d\" -f2)
ts=$(date +%s)
new_version="$current_version$ts"
bumpversion --current-version $current_version --new-version $new_version patch $VERSION_FILE
- name: Build package
run: |
python setup.py --version
python setup.py bdist_wheel sdist --format=gztar
twine check dist/*
- name: Publish package to TestPyPI
if: "'$TEST_PYPI_PASS' != ''"
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.TEST_PYPI_PASS }}
repository_url: https://test.pypi.org/legacy/
skip_existing: true
Test-pypi:
if: "'$TEST_PYPI_PASS' != ''"
needs: Build-pypi
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple $PROJECT_NAME
python -m pip install -r requirements-test.txt
- name: Test package
run: |
mv $PROJECT_NAME/tests ./tests
rm -rf $PROJECT_NAME
pytest
Bump-version:
if: "!contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/main' && '$BOT_AUTH_TOKEN' != ''"
needs:
- Test-pypi
- Pytest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 100
persist-credentials: false
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependencies
run: |
git config --global user.name "${BOT_NAME}"
git config --global user.email "${BOT_EMAIL}"
git config --global pull.rebase false
pip install bump2version
- name: Run bump version
run: |
set -x
git pull --no-edit origin $DEFAULT_BRANCH
current_version=$(grep __version__ $VERSION_FILE | cut -d\" -f2)
bumpversion --tag --current-version $current_version --commit patch $VERSION_FILE
git remote add ${BOT_NAME}-remote https://${BOT_NAME}:${BOT_AUTH_TOKEN}@github.com/$GITHUB_REPOSITORY
git push --tags ${BOT_NAME}-remote HEAD:$DEFAULT_BRANCH
set +e
Release-package:
if: "contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/main' && '$PYPI_PASS' != ''"
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- run: |
git fetch --prune --unshallow
- name: Set up Python 3.8
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install -U pip
python -m pip install -U setuptools twine wheel
- name: Build package
run: |
python setup.py --version
python setup.py bdist_wheel sdist --format=gztar
twine check dist/*
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_PASS }}