-
Notifications
You must be signed in to change notification settings - Fork 4
221 lines (218 loc) · 7.65 KB
/
release.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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
name: Release workflow
on:
push:
tags:
- "v*" # Push events to matching v*, i.e. v1.0, v20.15.10
env:
repository: https://github.com/powerapi-ng/rapl-formula
jobs:
lint_and_test:
name: Lint and test
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
services:
mongo:
image: mongo:latest
ports:
- 27017:27017
influx:
image: influxdb:1.8
ports:
- 8086:8086
steps:
- name: Install tools
run: |
sudo apt update
sudo apt install -y libvirt-dev procps
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Convert to python3.6 code
if: ${{ matrix.python-version == 3.6 }}
run: |
wget https://raw.githubusercontent.com/powerapi-ng/powerapi-ci-env/main/to_36.sh
/bin/bash to_36.sh rapl_formula
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Install dependencies
run: |
python -m pip install --upgrade pip
sudo pip install flake8 pylint
- name: install powerapi
if: ${{ matrix.python-version == 3.6 }}
run: |
VERSION=$(grep "powerapi " setup.cfg | cut -d = -f 2)
sudo pip install thespian
wget https://github.com/powerapi-ng/powerapi/releases/download/1.0.0/python3-powerapi_1.0.0-1_all.deb
sudo dpkg -i python3-powerapi_1.0.0-1_all.deb || echo ok
sudo apt install -f -y
sudo py3compile -p python3-powerapi -V 3.3-
sudo pip freeze
- name: install rapl_formula
run: |
sudo pip install .
- name: Test with pytest
run: |
sudo python setup.py pytest
- name: Lint with flake8
if: ${{ matrix.python-version != 3.6 }}
run: |
sudo flake8 rapl_formula
- name: Lint with pylint
if: ${{ matrix.python-version != 3.6 }}
run: |
sudo pylint rapl_formula
check_release:
name: Check release and version correspondance
runs-on: ubuntu-latest
needs: lint_and_test
outputs:
version: ${{ steps.step2.outputs.version }}
steps:
- uses: actions/checkout@v2
- name: Check tag and package version
id: step2
run: |
export GIT_TAG=$(echo $GITHUB_REF | sed -e 's/refs\/tags\/v//g')
test $GIT_TAG == $(grep __version__ rapl_formula/__init__.py | cut -d \" -f 2)
echo "::set-output name=version::$GIT_TAG"
build_pypi:
name: Push package on pypi
runs-on: ubuntu-latest
env:
PYPI_PASS: ${{ secrets.PYPI_PASS }}
needs: check_release
steps:
- uses: actions/checkout@v2
- name: Prepare environement
run: pip install -U pip twine
- name: Init .pypirc
run: |
echo -e "[pypi]" >> ~/.pypirc
echo -e "username = powerapi" >> ~/.pypirc
echo -e "password = $PYPI_PASS" >> ~/.pypirc
- name: Generate package
run: |
python3 -m venv venv
. venv/bin/activate
python3 -m pip install wheel
python3 setup.py sdist bdist_wheel
- name: Upload to pypi
run: twine upload dist/*
build_and_push_to_dockerHub:
name: Build and push docker image to DockerHub
runs-on: ubuntu-latest
needs: check_release
steps:
- uses: actions/checkout@v2
- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Build and push Cpython image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: .
push: true
file: Dockerfile-cpython
tags: powerapi/rapl-formula:latest, powerapi/rapl-formula:${{needs.check_release.outputs.version}}
build_deb_package:
name: Build debian binary package
runs-on: ubuntu-latest
needs: check_release
container:
image: powerapi/powerapi-build-deb
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
- name: Cache pip
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Remove tests
run: |
rm -R ./tests
sed -i 's/setup_requires =//g' setup.cfg
sed -i 's/pytest-runner >=3.9.2//g' setup.cfg
sed -i 's/test = pytest//g' setup.cfg
sed -i 's/\[aliases\]//g' setup.cfg
sed -i 's/test_suite = tests//g' setup.cfg
sed -i 's/tests_require =//g' setup.cfg
sed -i 's/pytest >=3.9.2//g' setup.cfg
sed -i 's/pytest-asyncio >=0.14.0//g' setup.cfg
sed -i 's/requests >=2.0//g' setup.cfg
- name: Convert to python3.6 code
run: |
wget https://raw.githubusercontent.com/powerapi-ng/powerapi-ci-env/main/to_36.sh
/bin/bash to_36.sh rapl_formula
- name: Create source package
run: |
apt install -y python3-setuptools python3-stdeb python3-numpy
mkdir package
mv LICENSE README.md contributing.md rapl_formula setup.* package/
tar czvf rapl_formula.tar.gz package
py2dsc rapl_formula.tar.gz
sed -i '/Depends: ${misc:Depends}, ${python3:Depends}/a Suggests: python3-libvirt,python3-pymongo,python3-prometheus-client,python3-influxdb' ./deb_dist/rapl-formula-${{needs.check_release.outputs.version}}/debian/control
- name: Build binary package and upload it github release page
env:
VERSION: ${{needs.check_release.outputs.version}}
run: |
cd ./deb_dist/rapl-formula-$VERSION
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage
mkdir -p ~/deb
cp ../python3-rapl-formula_$VERSION-1_all.deb ~/deb/
ls ~/deb/
- uses: actions/upload-artifact@v2
with:
name: deb_package
path: ~/deb/
publish_release:
name: Publish release on github
runs-on: ubuntu-latest
needs: [check_release, build_deb_package]
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: deb_package
path: ~/deb
- name: Create pre-changelog
id: pre-changelog
uses: TriPSs/conventional-changelog-action@v3
with:
github-token: ${{ secrets.github_token }}
preset: angular
output-file: ~/pre-changelog.md
release-count: 2
- name: Create Changelog
env:
CHANGELOG_CONTENT: ${{ steps.changelog.outputs.clean_changelog }}
run: |
sudo apt install -y npm
sudo npm install -g conventional-changelog-cli
conventional-changelog -p angular -r 2 | grep -v "^# \[\]" | sed 's/^#//g' > ~/final-changelog.md
cat ~/final-changelog.md
cat ~/final-changelog.md >> CHANGELOG.md
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{needs.check_release.outputs.version}}
run: gh release create $VERSION -d -t $VERSION -F ~/final-changelog.md ~/deb/*