feat: extract ci tasks to generic actions
Some checks failed
/ build_wheel (push) Failing after 3s
/ build_debian (push) Failing after 16s
/ test (push) Successful in 41s
/ codestyle (push) Successful in 39s

This commit is contained in:
s3lph 2023-12-19 00:03:28 +01:00
parent c1588633cf
commit 305fd875da
Signed by: s3lph
GPG key ID: 0AA29A52FB33CFB5

View file

@ -9,67 +9,32 @@ jobs:
build_wheel: build_wheel:
runs-on: docker runs-on: docker
env:
API_USERNAME: "${{ secrets.API_USERNAME }}"
API_PASSWORD: "${{ secrets.API_PASSWORD }}"
API_REPOSITORY_PYPI: "${{ secrets.API_REPOSITORY_PYPI }}"
steps: steps:
- uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/checkout@v4
- name: build_wheel - name: Build Python wheel
run: | run: |
apt update; apt install -y python3-pip apt update; apt install -y python3-pip
pip3 install --break-system-packages -e .[test] pip3 install --break-system-packages -e .[test]
python3 setup.py egg_info bdist_wheel python3 setup.py egg_info bdist_wheel
cat > ~/.pypirc <<EOF - name: Upload Python wheel
[distutils] uses: https://git.kabelsalat.ch/s3lph/forgejo-action-wheel-package-upload@v2
index-servers = gitea
[gitea]
repository = ${API_REPOSITORY_PYPI}
username = ${API_USERNAME}
password = ${API_PASSWORD}
EOF
python3 -m twine upload --repository gitea dist/*.whl
build_debian: build_debian:
runs-on: docker runs-on: docker
env:
PACKAGE_AUTHOR: "s3lph <s3lph@kabelsalat.ch>"
API_USERNAME: "${{ secrets.API_USERNAME }}"
API_PASSWORD: "${{ secrets.API_PASSWORD }}"
API_REPOSITORY_DEB: "${{ secrets.API_REPOSITORY_DEB }}"
steps: steps:
- uses: https://code.forgejo.org/actions/checkout@v4 - uses: https://code.forgejo.org/actions/checkout@v4
- name: build_debian - name: Prepare package
run: | run: |
apt update; apt install -y python3-pip lintian rsync sudo curl mkdir -p package/debian/prometheus-tlsrpt-exporter/usr/share/prometheus-tlsrpt-exporter
export EXPORTER_VERSION=$(python3 -c 'import tlsrpt_exporter; print(tlsrpt_exporter.__version__)')
echo -n > package/debian/prometheus-tlsrpt-exporter/usr/share/doc/prometheus-tlsrpt-exporter/changelog
for version in "$(cat CHANGELOG.md | grep '<!-- BEGIN CHANGES' | cut -d ' ' -f 4)"; do
echo -e "prometheus-tlsrpt-exporter (${version}-1); urgency=medium\n" >> package/debian/prometheus-tlsrpt-exporter/usr/share/doc/prometheus-tlsrpt-exporter/changelog
cat CHANGELOG.md | grep -A 1000 "<"'!'"-- BEGIN CHANGES ${version} -->" | grep -B 1000 "<"'!'"-- END CHANGES ${version} -->" | tail -n +2 | head -n -1 | sed -re 's/^-/ */g' >> package/debian/prometheus-tlsrpt-exporter/usr/share/doc/prometheus-tlsrpt-exporter/changelog
echo -e "\n -- ${PACKAGE_AUTHOR} $(date -R)\n" >> package/debian/prometheus-tlsrpt-exporter/usr/share/doc/prometheus-tlsrpt-exporter/changelog
done
gzip -9n package/debian/prometheus-tlsrpt-exporter/usr/share/doc/prometheus-tlsrpt-exporter/changelog
mkdir -p package/debian/prometheus-tlsrpt-exporter/usr/share/prometheus-tlsrpt-exporter \
package/debian/prometheus-tlsrpt-exporter/usr/bin
cp -r templates/ package/debian/prometheus-tlsrpt-exporter/usr/share/prometheus-tlsrpt-exporter/templates/ cp -r templates/ package/debian/prometheus-tlsrpt-exporter/usr/share/prometheus-tlsrpt-exporter/templates/
python3 setup.py egg_info install --root=package/debian/prometheus-tlsrpt-exporter/ --prefix=/usr/local --optimize=1 - name: Build Debian package
cd package/debian uses: https://git.kabelsalat.ch/s3lph/forgejo-action-python-debian-package@v1
mkdir -p prometheus-tlsrpt-exporter/usr/lib/python3/dist-packages/ with:
rsync -a prometheus-tlsrpt-exporter/usr/local/lib/python3.11/dist-packages/ prometheus-tlsrpt-exporter/usr/lib/python3/dist-packages/ python_module: tlsrpt_exporter
mv prometheus-tlsrpt-exporter/usr/local/bin/prometheus-tlsrpt-exporter prometheus-tlsrpt-exporter/usr/bin/ package_name: prometheus-tlsrpt-exporter
rm -rf prometheus-tlsrpt-exporter/usr/local/lib/ prometheus-tlsrpt-exporter/usr/local/bin/ package_root: package/debian/prometheus-tlsrpt-exporter
find prometheus-tlsrpt-exporter/usr/lib/python3/dist-packages -name __pycache__ -exec rm -r {} \; 2>/dev/null || true package_output_path: package/debian
find prometheus-tlsrpt-exporter/usr/lib/python3/dist-packages -name '*.pyc' -exec rm {} \; - name: Upload Debian package
find prometheus-tlsrpt-exporter -type f -exec chmod 0644 {} \; uses: https://git.kabelsalat.ch/s3lph/forgejo-action-python-debian-package@v1
find prometheus-tlsrpt-exporter -type d -exec chmod 755 {} \; with:
chmod +x prometheus-tlsrpt-exporter/usr/bin/prometheus-tlsrpt-exporter prometheus-tlsrpt-exporter/DEBIAN/postinst prometheus-tlsrpt-exporter/DEBIAN/prerm deb: "package/debian/*.deb"
sed -re "s/__VERSION__/${EXPORTER_VERSION}-1/g" -i prometheus-tlsrpt-exporter/DEBIAN/control
dpkg-deb --build prometheus-tlsrpt-exporter
mv "prometheus-tlsrpt-exporter.deb" "prometheus-tlsrpt-exporter_${EXPORTER_VERSION}-1_all.deb"
sudo -u nobody lintian "prometheus-tlsrpt-exporter_${EXPORTER_VERSION}-1_all.deb" || true
curl \
--user "${API_USERNAME}:${API_PASSWORD}" \
--upload-file "prometheus-tlsrpt-exporter_${EXPORTER_VERSION}-1_all.deb" \
${API_REPOSITORY_DEB}