From 305fd875dad3926e851f9790e2b166d82c209427 Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 19 Dec 2023 00:03:28 +0100 Subject: [PATCH] feat: extract ci tasks to generic actions --- .forgejo/workflows/package.yml | 67 ++++++++-------------------------- 1 file changed, 16 insertions(+), 51 deletions(-) diff --git a/.forgejo/workflows/package.yml b/.forgejo/workflows/package.yml index 63bb9d3..245bd44 100644 --- a/.forgejo/workflows/package.yml +++ b/.forgejo/workflows/package.yml @@ -9,67 +9,32 @@ jobs: build_wheel: runs-on: docker - env: - API_USERNAME: "${{ secrets.API_USERNAME }}" - API_PASSWORD: "${{ secrets.API_PASSWORD }}" - API_REPOSITORY_PYPI: "${{ secrets.API_REPOSITORY_PYPI }}" steps: - uses: https://code.forgejo.org/actions/checkout@v4 - - name: build_wheel + - name: Build Python wheel run: | apt update; apt install -y python3-pip pip3 install --break-system-packages -e .[test] python3 setup.py egg_info bdist_wheel - cat > ~/.pypirc <" - API_USERNAME: "${{ secrets.API_USERNAME }}" - API_PASSWORD: "${{ secrets.API_PASSWORD }}" - API_REPOSITORY_DEB: "${{ secrets.API_REPOSITORY_DEB }}" steps: - uses: https://code.forgejo.org/actions/checkout@v4 - - name: build_debian + - name: Prepare package run: | - apt update; apt install -y python3-pip lintian rsync sudo curl - 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 '" | 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 + mkdir -p package/debian/prometheus-tlsrpt-exporter/usr/share/prometheus-tlsrpt-exporter 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 - cd package/debian - mkdir -p prometheus-tlsrpt-exporter/usr/lib/python3/dist-packages/ - rsync -a prometheus-tlsrpt-exporter/usr/local/lib/python3.11/dist-packages/ prometheus-tlsrpt-exporter/usr/lib/python3/dist-packages/ - mv prometheus-tlsrpt-exporter/usr/local/bin/prometheus-tlsrpt-exporter prometheus-tlsrpt-exporter/usr/bin/ - rm -rf prometheus-tlsrpt-exporter/usr/local/lib/ prometheus-tlsrpt-exporter/usr/local/bin/ - find prometheus-tlsrpt-exporter/usr/lib/python3/dist-packages -name __pycache__ -exec rm -r {} \; 2>/dev/null || true - find prometheus-tlsrpt-exporter/usr/lib/python3/dist-packages -name '*.pyc' -exec rm {} \; - find prometheus-tlsrpt-exporter -type f -exec chmod 0644 {} \; - find prometheus-tlsrpt-exporter -type d -exec chmod 755 {} \; - chmod +x prometheus-tlsrpt-exporter/usr/bin/prometheus-tlsrpt-exporter prometheus-tlsrpt-exporter/DEBIAN/postinst prometheus-tlsrpt-exporter/DEBIAN/prerm - 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} + - name: Build Debian package + uses: https://git.kabelsalat.ch/s3lph/forgejo-action-python-debian-package@v1 + with: + python_module: tlsrpt_exporter + package_name: prometheus-tlsrpt-exporter + package_root: package/debian/prometheus-tlsrpt-exporter + package_output_path: package/debian + - name: Upload Debian package + uses: https://git.kabelsalat.ch/s3lph/forgejo-action-python-debian-package@v1 + with: + deb: "package/debian/*.deb"