-
Notifications
You must be signed in to change notification settings - Fork 29
159 lines (138 loc) · 4.49 KB
/
build.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
name: Build
on:
pull_request:
branches:
- "*"
# Cancel in-progress workflow runs on new PR commits.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
test-library:
name: Build library
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.7.5
uses: actions/setup-python@v3
with:
python-version: "3.7.5"
- name: Install tox
run: |
# Install tox
pip install tox==3.20.1
- name: Run tests using tox
run: |
# Go inside the surround library
cd surround
# Remove generated tox directory
rm -rf .tox
# Run tests through tox
tox
test-cli:
name: Build cli
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.7.5
uses: actions/setup-python@v3
with:
python-version: "3.7.5"
- name: Install tox
run: |
# Install tox
pip install tox==3.20.1
- name: Run tests using tox
run: |
# Go inside the surround cli
cd surround_cli
# Remove generated tox directory
rm -rf .tox
# Run tests through tox
tox
# Run examples
pip install ../surround
python setup.py install
cd ..
find examples/ -iname "*.py" | xargs pylint
ls examples/ | xargs -n 1 -I '{}' python3 examples/'{}'/main.py
release-library:
name: Release library
runs-on: ubuntu-20.04
needs:
- test-library
if: >-
github.event_name != 'pull_request' &&
github.ref_type == 'tag' &&
startsWith(github.ref_name, 'surround-v')
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.7.5
uses: actions/setup-python@v3
with:
python-version: "3.7.5"
- name: Publish
run: |
cd surround
# Remove generated files from last release
rm -rf dist
# Install required packages
python -m pip install --user --upgrade setuptools wheel twine
# Setup Pypi config
echo "[distutils]" >> ~/.pypirc
echo "index-servers =" >> ~/.pypirc
echo "pypi" >> ~/.pypirc
echo "surround" >> ~/.pypirc
echo "" >> ~/.pypirc
echo "[pypi]" >> ~/.pypirc
echo "username=__token__" >> ~/.pypirc
echo "password=${{ secrets.PYPI_API_LIB_TOKEN }}" >> ~/.pypirc
echo "" >> ~/.pypirc
echo "[surround]" >> ~/.pypirc
echo "repository = https://upload.pypi.org/legacy/" >> ~/.pypirc
echo "username=__token__" >> ~/.pypirc
echo "password=${{ secrets.PYPI_API_LIB_TOKEN }}" >> ~/.pypirc
# Build package
python setup.py sdist bdist_wheel
# Upload package for distribution
python -m twine upload --repository pypi dist/*
release-cli:
name: Release library
runs-on: ubuntu-20.04
needs:
- test-cli
if: >-
github.event_name != 'pull_request' &&
github.ref_type == 'tag' &&
startsWith(github.ref_name, 'surround-cli-v')
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.7.5
uses: actions/setup-python@v3
with:
python-version: "3.7.5"
- name: Publish
run: |
cd surround_cli
# Remove generated files from last release
rm -rf dist
# Install required packages
python -m pip install --user --upgrade setuptools wheel twine
# Setup Pypi config
echo "[distutils]" >> ~/.pypirc
echo "index-servers =" >> ~/.pypirc
echo "pypi" >> ~/.pypirc
echo "surround-cli" > ~/.pypirc
echo "" >> ~/.pypirc
echo "[pypi]" >> ~/.pypirc
echo "username=__token__" >> ~/.pypirc
echo "password=${{ secrets.PYPI_API_CLI_TOKEN }}" >> ~/.pypirc
echo "" >> ~/.pypirc
echo "[surround-cli]" >> ~/.pypirc
echo "repository = https://upload.pypi.org/legacy/" >> ~/.pypirc
echo "username=__token__" >> ~/.pypirc
echo "password=${{ secrets.PYPI_API_CLI_TOKEN }}" >> ~/.pypirc
# Build package
python setup.py sdist bdist_wheel
# Upload package for distribution
python -m twine upload --repository pypi dist/*