-
Notifications
You must be signed in to change notification settings - Fork 23
145 lines (112 loc) · 3.88 KB
/
python.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
name: Python CI/CD
on:
push:
branches: ['**']
tags-ignore: ['**']
pull_request:
release:
types:
- published
jobs:
build_sdist:
name: Build source distribution
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- run: git fetch --prune --unshallow
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Make sure to use an updated pip
run: python -m pip install --upgrade pip
- name: Install pypa/build
run: pip install build
- name: Build sdist
run: python -m build --sdist --outdir dist/ tools/pip
- name: Install sdist
run: pip -v install dist/ycm_cmake_modules-*.tar.gz
- name: Test import
run: python -c 'import ycm_cmake_modules'
- name: Remove external wheels
run: find dist/ -type f -not -name 'ycm_cmake_modules-*' -delete -print
- name: Inspect dist folder
run: ls -lah dist/
- uses: actions/upload-artifact@v2
with:
name: dist
path: dist/*.tar.gz
build_wheel:
name: Build wheel
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master
- run: git fetch --prune --unshallow
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8
- name: Install pypa/build
run: pip install build
- name: Build wheel
run: python -m build --wheel --outdir dist/ tools/pip
- name: Remove external wheels
run: find dist/ -type f -not -name 'ycm_cmake_modules-*' -delete -print
# setuptools thinks that the package is OS-dependent because it uses a
# build extension, but instead it does not contain any compiled code.
- name: Rename wheel
run: |
sudo apt update
sudo apt install -y rename
find . -type f -name "*.whl" -exec rename -v "s/cp(\d)(\d)-cp(\d)(\d)-linux_x86_64/py3-none-any/g" {} +
- name: Install wheel
run: pip install dist/ycm_cmake_modules-*.whl
- name: Test import
run: python -c 'import ycm_cmake_modules'
- name: Inspect dist folder
run: ls -lah dist/
- uses: actions/upload-artifact@v2
with:
name: dist
path: ./dist/*.whl
upload_pypi:
needs:
- build_sdist
- build_wheel
runs-on: ubuntu-latest
# Branch master produces pre-releases.
# GitHub Releases 'vX.Y.Z' produce stable releases.
steps:
- uses: actions/checkout@master
- run: git fetch --prune --unshallow
- uses: actions/download-artifact@v2
with:
name: dist
path: dist
- name: Inspect dist folder
run: ls -lah dist/
# Validate the tag accordingly to PEP440
# From https://stackoverflow.com/a/37972030/12150968
- name: Check PEP440 compliance
if: github.event_name == 'release'
run: |
sudo apt-get update
sudo apt-get install -y source-highlight
last_tag_with_v="$(git describe --abbrev=0 --tags)"
last_tag=${last_tag_with_v#v}
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
- uses: pypa/gh-action-pypi-publish@master
if: |
github.repository == 'robotology/ycm' &&
((github.event_name == 'release' && github.event.action == 'published') ||
(github.event_name == 'push' && github.ref == 'refs/heads/master'))
with:
user: __token__
password: ${{ secrets.PYPI_TOKEN }}
skip_existing: true