-
Notifications
You must be signed in to change notification settings - Fork 25
198 lines (170 loc) · 6.41 KB
/
pypi.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
194
195
196
197
198
name: PyPI Continuous Delivery
# Visit the following page for more details:
# https://packaging.python.org/tutorials/packaging-projects/
on:
release:
types:
- published
- prereleased
# Nightly builds
push:
branches: devel
jobs:
# =============
# SDIST PACKAGE
# =============
sdist:
name: sdist
runs-on: ubuntu-latest
strategy:
matrix:
python_version:
- 3.6
container:
# The sdist is tested using the :ci image tag that should mostly match the developer
# setup with ignition robotics installed from the official ppa
image: diegoferigo/gym-ignition:ci
env:
CC: gcc
CXX: g++
PYTHON_VERSION: ${{ matrix.python_version }}
steps:
- uses: actions/checkout@master
# Validate the last tag accordingly to PEP440
# From https://stackoverflow.com/a/37972030/12150968
- name: Validate Tag for PEP440 compliance
if: github.event_name != 'push'
run: |
apt-get update
apt-get install -y source-highlight
last_tag="$(git describe --abbrev=0 --tags)"
rel_regexp='^(\d+!)?(\d+)(\.\d+)+([\.\-\_])?((a(lpha)?|b(eta)?|c|r(c|ev)?|pre(view)?)\d*)?(\.?(post|dev)\d*)?$'
echo ""
echo $last_tag
echo ""
check-regexp ${rel_regexp} ${last_tag}
match=$(check-regexp ${rel_regexp} ${last_tag} | grep matches | cut -d ' ' -f 5)
test $match -eq 1 && true
# The entrypoint is not called because it is overridden by GH Actions.
# Even using the 'jobs.<job_id>.container.options' does not work because the
# entrypoint of GH Actions overrides the one passed through YAML.
- name: Execute entrypoint
run: . /entrypoint.sh
- name: Setup package name
run: |
if [ "${{ github.event_name == 'push' }}" = "true" ] ; then
sed -i "s/name='gym-ignition'/name='gym-ignition-nightly'/g" setup.py
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git commit -a -m "Renamed for nightly release"
fi
- name: Create sdist
run: python setup.py sdist
- name: Install sdist
run: |
cd dist
pip install *.tar.gz
- name: Python tests
run: |
cd tests/python
pytest
- name: Install Twine
if: github.repository == 'robotology/gym-ignition'
run: pip install twine
- name: PyPI Release
if: github.repository == 'robotology/gym-ignition'
run: twine upload --verbose dist/*
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}
# ===================
# BDIST_WHEEL PACKAGE
# ===================
# The bdist is created using the :pypi image and tested in the ubuntu:bionic
# host that should mostly match the user setup
bdist:
name: bdist_wheel
needs: sdist
strategy:
matrix:
os:
- ubuntu-18.04
python_version:
- 3.6
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
# Validate the last tag accordingly to PEP440
# From https://stackoverflow.com/a/37972030/12150968
- name: Validate Tag for PEP440 compliance
if: github.event_name != 'push'
run: |
sudo apt-get update
sudo apt-get install -y source-highlight
last_tag="$(git describe --abbrev=0 --tags)"
rel_regexp='^(\d+!)?(\d+)(\.\d+)+([\.\-\_])?((a(lpha)?|b(eta)?|c|r(c|ev)?|pre(view)?)\d*)?(\.?(post|dev)\d*)?$'
echo ""
echo $last_tag
echo ""
check-regexp ${rel_regexp} ${last_tag}
match=$(check-regexp ${rel_regexp} ${last_tag} | grep matches | cut -d ' ' -f 5)
test $match -eq 1 && true
- name: Setup package name
run: |
if [ "${{ github.event_name == 'push' }}" == "true" ] ; then
sed -i "s/name='gym-ignition'/name='gym-ignition-nightly'/g" setup.py
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
git commit -a -m "Renamed for nightly release"
fi
# Workaround to export environment variables that persist in next steps
# https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
- name: Setup Environment
run: |
echo "::set-env name=CC::gcc"
echo "::set-env name=CXX::g++"
echo "::set-env name=PYTHON_VERSION::${{ matrix.python_version }}"
env
- name: Download diegoferigo/gym-ignition:pypi
run: 'docker pull diegoferigo/gym-ignition:pypi'
- name: Create container
run: |
docker run \
-d -i --rm --name pypi -v $(pwd):/github -w /github \
-e PYTHON_VERSION=$PYTHON_VERSION -e CC=$CC -e CXX=$CXX \
diegoferigo/gym-ignition:pypi bash
sleep 15
- name: Create bdist_wheel
run: |
docker exec -i pypi sh -c 'python setup.py bdist_wheel'
docker exec -i pypi sh -c 'ls dist/'
- name: Rename wheel
run: |
docker exec -i -w /github/dist pypi \
sh -c 'find -type f -name "*.whl" -exec rename.ul linux manylinux1 {} +'
ls dist/
- name: Download and start clean system
run : |
docker pull diegoferigo/gym-ignition:ci
docker run \
-d -i --name test -e PYTHON_VERSION=$PYTHON_VERSION \
-v $(pwd)/dist:/dist \
diegoferigo/gym-ignition:ci bash
sleep 15
- name: Install bdist
run: docker exec -i -w /dist test sh -c 'pip install *.whl'
- name: Python tests
run: |
docker exec -i test sh -c "git clone https://github.com/robotology/gym-ignition"
docker exec -i test sh -c "cd gym-ignition/tests/python && pytest -v"
- name: Install Twine
if: github.repository == 'robotology/gym-ignition'
run: docker exec -i test sh -c 'pip install twine'
- name: PyPI Release
if: github.repository == 'robotology/gym-ignition'
run: |
docker exec -i -e TWINE_USERNAME -e TWINE_PASSWORD test \
sh -c 'twine upload --verbose dist/*'
env:
TWINE_USERNAME: ${{ secrets.TWINE_USERNAME }}
TWINE_PASSWORD: ${{ secrets.TWINE_PASSWORD }}