diff --git a/.chglog.yml b/.chglog.yml new file mode 100644 index 0000000..9e47090 --- /dev/null +++ b/.chglog.yml @@ -0,0 +1,7 @@ +conventional-commits: false +deb: + distribution: stable + urgency: stable +debug: false +owner: Benjamin Renard <brenard@zionetrix.net> +package-name: aptly-publish diff --git a/.forgejo/workflows/release.yaml b/.forgejo/workflows/release.yaml new file mode 100644 index 0000000..968ea04 --- /dev/null +++ b/.forgejo/workflows/release.yaml @@ -0,0 +1,91 @@ +--- +name: Build and publish Debian package +on: [create] +jobs: + build: + runs-on: docker + container: + image: docker.io/brenard/nfpm:latest + steps: + - name: Check out repository code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Build Debian package + run: | + echo "${{ secrets.GPG_KEY }}" | base64 -d > key.gpg + VERSION="$( git describe --tags | sed 's/^[^0-9]*//' )" yq eval '.version = strenv(VERSION)' nfpm.yaml -i + yq eval '.deb.signature.key_file = "key.gpg"' nfpm.yaml -i + yq eval '.maintainer = "${{ vars.MAINTAINER_NAME }} <${{ vars.MAINTAINER_EMAIL }}>"' nfpm.yaml -i + yq eval '.deb.distribution = "${{ vars.DEBIAN_CODENAME }}"' .chglog.yml -i + cat nfpm.yaml + chglog init + mkdir dist + chglog format --template release -o dist/release_notes.md + nfpm -f nfpm.yaml package --packager deb --target dist + cp aptly-publish dist + - name: Upload Debian package files + uses: actions/upload-artifact@v3 + with: + name: dist + path: | + dist + + publish-forgejo: + runs-on: docker + container: + image: docker.io/brenard/debian-python-deb:latest + needs: + - build + steps: + - name: Download Debian package files + uses: actions/download-artifact@v3 + with: + name: dist + + - name: Create the release + id: create-release + shell: bash + run: | + mkdir release + mv *.deb release/ + mv aptly-publish release/ + md5sum release/* > md5sum.txt + sha512sum release/* > sha512sum.txt + mv md5sum.txt sha512sum.txt release/ + { + echo 'release_note<<EOF' + cat release_notes.md | sed 's/"/\\"/g' + echo 'EOF' + } >> "$GITHUB_OUTPUT" + + - name: Publish release on Forgejo + uses: actions/forgejo-release@v2 + with: + direction: upload + url: https://gitea.zionetrix.net + token: ${{ secrets.forgejo_token }} + release-dir: release + release-notes: ${{ steps.create-release.outputs.release_note }} + + publish-aptly: + runs-on: docker + container: + image: docker.io/brenard/aptly-publish:latest + needs: + - build + steps: + - name: "Download Debian package files" + uses: actions/download-artifact@v3 + with: + name: dist + + - name: "Publish Debian package on Aptly repository" + uses: https://gitea.zionetrix.net/bn8/aptly-publish@master + with: + api_url: ${{ vars.apt_api_url }} + api_username: ${{ vars.apt_api_username }} + api_password: ${{ secrets.apt_api_password }} + repo_name: ${{ vars.apt_repo_name }} + path: "./" + source_name: ${{ vars.apt_source_name }} diff --git a/.forgejo/workflows/tests.yaml b/.forgejo/workflows/tests.yaml index d5f692a..eda0c60 100644 --- a/.forgejo/workflows/tests.yaml +++ b/.forgejo/workflows/tests.yaml @@ -5,13 +5,17 @@ jobs: test-precommit: runs-on: docker container: - image: docker.io/brenard/python-pre-commit:latest + image: docker.io/library/node:16-alpine steps: - name: Check out repository code uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Install python dependencies - run: python3 -m pip install --break-system-packages debian-parser requests urllib3 + - name: Install tests dependencies + run: apk -Uuv add python3 py3-requests py3-urllib3 py3-pip py3-debian py3-chardet py3-pylint git bash + - name: Install pre-commit + run: pip install pre-commit - name: Run pre-commit - run: pre-commit run --all-files + run: | + git config --global --add safe.directory "$(pwd)" + pre-commit run --all-files || cat /root/.cache/pre-commit/pre-commit.log diff --git a/.gitignore b/.gitignore index 3d0d534..444786d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ *~ /venv /dist +/changelog.yml +*.gpg diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c710eb1..7417a22 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -50,7 +50,7 @@ repos: hooks: - id: pylint name: pylint - entry: pylint + entry: python3 -m pylint language: system types: [python] require_serial: true diff --git a/nfpm.yaml b/nfpm.yaml new file mode 100644 index 0000000..42de359 --- /dev/null +++ b/nfpm.yaml @@ -0,0 +1,23 @@ +# yaml-language-server: $schema=https://nfpm.goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +name: aptly-publish +arch: all +platform: linux +version: 2025.2.1 +section: devel +priority: optional +depends: + - python3 + - python3-requests + - python3-urllib3 + - python3-debian +maintainer: Benjamin Renard <brenard@zionetrix.net> +description: Tool to publish one (or more) Debian package on a Aptly repository using its API +homepage: https://gitea.zionetrix.net/bn8/aptly-publish +license: GPL-3 +# Changelog YAML file, see: https://github.com/goreleaser/chglog +changelog: changelog.yml +contents: + - src: ./aptly-publish + dst: /usr/bin