This repository has been archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
153 lines (151 loc) · 5.53 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
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/procfs-sensor
jobs:
check_release:
name: Check release and version correspondance
runs-on: ubuntu-latest
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__ procfs_sensor/__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/procfs-sensor:latest, powerapi/procfs-sensor:${{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 || echo "Ok"
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 procfs_sensor
- name: Create source package
run: |
apt install -y python3-setuptools python3-stdeb python3-numpy
mkdir package
mv LICENSE README.md contributing.md procfs_sensor setup.* package/
tar czvf procfs_sensor.tar.gz package
py2dsc procfs_sensor.tar.gz
sed -i '/Depends: ${misc:Depends}, ${python3:Depends}/a Suggests: python3-libvirt,python3-pymongo,python3-prometheus-client,python3-influxdb' ./deb_dist/procfs-sensor-${{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/procfs-sensor-$VERSION
DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage
mkdir -p ~/deb
cp ../python3-procfs-sensor_$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/*