-
Notifications
You must be signed in to change notification settings - Fork 13
173 lines (143 loc) · 4.53 KB
/
ci.yml
File metadata and controls
173 lines (143 loc) · 4.53 KB
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
name: CI
on:
push:
branches:
- master
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
pull_request:
branches:
- '*'
jobs:
tests:
name: Tests
# Pin to 20.04 as we still require Python 3.6
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install Tox
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run Tox
run: tox -e py
if: ${{matrix.python-version != 3.6 }}
- name: Run Tox with coverage
run: tox -e clean,py,stats_xml
if: ${{ matrix.python-version == 3.6 }}
- name: Upload to CodeCov
uses: codecov/codecov-action@v1
with:
file: ./coverage.xml
if: ${{ matrix.python-version == 3.6 }}
docs:
name: Docs
# Pin to 20.04 as we still require Python 3.6
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install Tox
run: |
python -m pip install --upgrade pip
pip install tox
- name: Generate Docs
run: tox -e docs
lint:
name: Lint
# Pin to 20.04 as we still require Python 3.6
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install Tox
run: |
python -m pip install --upgrade pip
pip install tox
- name: Lint
run: tox -e lint
build-and-publish:
name: Build and Publish
# Pin to 20.04 as we still require Python 3.6
runs-on: ubuntu-20.04
needs: [tests, docs, lint]
if: startsWith(github.ref, 'refs/tags')
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Install pypa/build
run: |
python -m pip install build --user
- name: Build binary wheel and source tarball
run: |
python -m build --sdist --wheel --outdir dist/
- name: Get tag version
id: get_tag_version
run: |
echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
echo ::set-output name=VERSION_NO_PREFIX::${GITHUB_REF#refs/tags/v}
- name: Create Release Message
id: release_message
run: |
# Substitutions required to get multi-line working.
# See https://github.community/t/set-output-truncates-multiline-strings/16852
MESSAGE="$(git --no-pager log -1 --pretty=format:'%b')"
MESSAGE="${MESSAGE//'%'/'%25'}"
MESSAGE="${MESSAGE//$'\n'/'%0A'}"
MESSAGE="${MESSAGE//$'\r'/'%0D'}"
echo ::set-output name=BODY::$MESSAGE
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_tag_version.outputs.VERSION }}
release_name: ${{ steps.get_tag_version.outputs.VERSION }}
body: ${{ steps.release_message.outputs.BODY }}
draft: true
prerelease: false
- name: Upload Release tar gzip
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/transcriptic-${{ steps.get_tag_version.outputs.VERSION_NO_PREFIX }}.tar.gz
asset_name: transcriptic-${{ steps.get_tag_version.outputs.VERSION_NO_PREFIX }}.tar.gz
asset_content_type: application/gzip
- name: Upload Release wheel
id: upload-release-asset-wheel
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/transcriptic-${{ steps.get_tag_version.outputs.VERSION_NO_PREFIX }}-py3-none-any.whl
asset_name: transcriptic-${{ steps.get_tag_version.outputs.VERSION_NO_PREFIX }}-py3-none-any.whl
asset_content_type: application/x-wheel+zip
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.PYPI_API_TOKEN }}