143 lines (137 loc) · 3.77 KB
/
ci.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
name: CI
on:
push:
branches:
- master
tags:
- v*
pull_request:
workflow_dispatch:
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
env:
PYTEST_ADDOPTS: -vv
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-version:
- 3.7
- 3.8
- 3.9
- '3.10'
steps:
- uses: actions/checkout@v3
- name: Set up Python v${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -m pip install -U pip coveralls tox tox-gh-actions
- name: Run tests
run: tox
- name: Coveralls
run: coveralls
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COVERALLS_SERVICE_NAME: github
- name: Test examples
run: tox -e examples
build-sdist:
if: startsWith(github.ref, 'refs/tags/')
needs: test
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
name: Install Python
with:
python-version: 3.x
- name: Build sdist
run: python setup.py sdist
- uses: actions/upload-artifact@v3
with:
path: dist/*.tar.gz
build-wheel:
if: startsWith(github.ref, 'refs/tags/')
needs: test
name: Build wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
name: Install Python
with:
python-version: 3.x
- name: Install wheel
run: python -m pip install --upgrade wheel
- name: Build wheel
run: python setup.py bdist_wheel
- uses: actions/upload-artifact@v3
with:
path: ./dist/*.whl
pypi-upload:
name: Upload to PyPI
needs:
- build-sdist
- build-wheel
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
# repository_url: https://test.pypi.org/legacy/
skip_existing: true
release:
name: Release
needs:
- build-sdist
- build-wheel
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Get tag metadata
id: tag
run: |
TAG_TITLE=${GITHUB_REF#refs/*/}
echo ::set-output name=title::$TAG_TITLE
git -c protocol.version=2 fetch --prune --progress \
--no-recurse-submodules origin \
+refs/heads/*:refs/remotes/origin/* +refs/tags/*:refs/tags/*
TAG_BODY="$(git tag -l --format='%(contents)' $TAG_TITLE)"
TAG_BODY="${TAG_BODY//'%'/'%25'}"
TAG_BODY="${TAG_BODY//$'\n'/'%0A'}"
TAG_BODY="${TAG_BODY//$'\r'/'%0D'}"
echo ::set-output name=body::$TAG_BODY
- name: Create Release
uses: actions/create-release@v1.1.4
id: create-release
with:
tag_name: ${{ steps.tag.outputs.title }}
release_name: ${{ steps.tag.outputs.title }}
body: ${{ steps.tag.outputs.body }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v3
name: Download builds
with:
name: artifact
path: dist
- uses: shogo82148/actions-upload-release-asset@v1
name: Upload release assets
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: dist/*