From 0aa52e1a251b2c5fbe37caf6c3e75cc23dcacc05 Mon Sep 17 00:00:00 2001 From: Michael Prokop Date: Thu, 5 Feb 2026 19:39:09 +0100 Subject: [PATCH] MT#55283 GH: automate GitHub releases for mr* tags, build Debian packages for PRs + update to trixie 1) Add a release job Automatically create a GitHub release with attached Debian packages, whenever a tag starting with 'mr' is pushed. Generate release notes grouped by author from git commits between the previous mr* tag and the current tag, similar to the format used in debian/changelog. 2) Automatically generate Debian packages for PRs This is useful for contributors as well as developers, to test and verify proposed changes. 3) Consolidate Debian package workflows Merge debpkg.yml into package-build.yml using a matrix strategy for building on multiple Debian distributions (trixie, sid), using jtdor/build-deb-action instead of custom Docker actions. Now our release job merges artifacts from all distros. 4) Update from bookworm to trixie Bump Debian package builds from bookworm to trixie, while at it, given that Debian trixie/v13 is the current stable Debian release. 5) Bump workflow actions from in package build workflow Update from v4 to current version v6, see https://github.com/actions/checkout Closes #2063 Change-Id: Ic1bfb3a7f9fa7e263f8e8d3b115baa01633db1a1 (cherry picked from commit e9fc1b10572fd806666927075d2ba1e1d9f25fcd) (cherry picked from commit ac1864f8650ba94217e44441c090f7e5184cc43f) --- .github/actions/debpkg-bullseye/Dockerfile | 13 --- .github/actions/debpkg-bullseye/entrypoint.sh | 16 ---- .github/actions/debpkg-sid/Dockerfile | 13 --- .github/actions/debpkg-sid/action.yml | 6 -- .github/actions/debpkg-sid/entrypoint.sh | 16 ---- .github/workflows/debian-package-build.yml | 90 +++++++++++++++++++ .github/workflows/debpkg.yml | 54 ----------- .github/workflows/release.yml | 69 ++++++++++++++ 8 files changed, 159 insertions(+), 118 deletions(-) delete mode 100644 .github/actions/debpkg-bullseye/Dockerfile delete mode 100755 .github/actions/debpkg-bullseye/entrypoint.sh delete mode 100644 .github/actions/debpkg-sid/Dockerfile delete mode 100644 .github/actions/debpkg-sid/action.yml delete mode 100755 .github/actions/debpkg-sid/entrypoint.sh create mode 100644 .github/workflows/debian-package-build.yml delete mode 100644 .github/workflows/debpkg.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/actions/debpkg-bullseye/Dockerfile b/.github/actions/debpkg-bullseye/Dockerfile deleted file mode 100644 index 6915587e5..000000000 --- a/.github/actions/debpkg-bullseye/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM debian:bullseye - -COPY entrypoint.sh /entrypoint.sh - -# avoid "debconf: (TERM is not set, so the dialog frontend is not usable.)" -ENV DEBIAN_FRONTEND noninteractive - -# disable man-db to speed up builds -RUN echo 'man-db man-db/auto-update boolean false' | debconf-set-selections - -RUN apt-get update && apt-get -y install build-essential - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/debpkg-bullseye/entrypoint.sh b/.github/actions/debpkg-bullseye/entrypoint.sh deleted file mode 100755 index 8f086e19f..000000000 --- a/.github/actions/debpkg-bullseye/entrypoint.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -eu -o pipefail - -echo "*** Starting execution of '$0' ***" - -echo "** Installing build dependencies **" -apt-get -y build-dep -Ppkg.ngcp-rtpengine.nobcg729 . - -echo "** Building Debian package **" -dpkg-buildpackage -Ppkg.ngcp-rtpengine.nobcg729 - -# We're inside /github/workspace/ -echo "** Copying Debian package files to workspace **" -cp ../*.deb ../*.buildinfo ../workspace/ - -echo "*** Finished execution of '$0' ***" diff --git a/.github/actions/debpkg-sid/Dockerfile b/.github/actions/debpkg-sid/Dockerfile deleted file mode 100644 index 375b766c3..000000000 --- a/.github/actions/debpkg-sid/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM debian:sid - -COPY entrypoint.sh /entrypoint.sh - -# avoid "debconf: (TERM is not set, so the dialog frontend is not usable.)" -ENV DEBIAN_FRONTEND noninteractive - -# disable man-db to speed up builds -RUN echo 'man-db man-db/auto-update boolean false' | debconf-set-selections - -RUN apt-get update && apt-get -y install build-essential - -ENTRYPOINT ["/entrypoint.sh"] diff --git a/.github/actions/debpkg-sid/action.yml b/.github/actions/debpkg-sid/action.yml deleted file mode 100644 index 1ec396a30..000000000 --- a/.github/actions/debpkg-sid/action.yml +++ /dev/null @@ -1,6 +0,0 @@ -name: "Build Docker image based on Debian/sid" -description: "Build Docker image based on Debian/sid" - -runs: - using: 'docker' - image: 'Dockerfile' diff --git a/.github/actions/debpkg-sid/entrypoint.sh b/.github/actions/debpkg-sid/entrypoint.sh deleted file mode 100755 index 8f086e19f..000000000 --- a/.github/actions/debpkg-sid/entrypoint.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -set -eu -o pipefail - -echo "*** Starting execution of '$0' ***" - -echo "** Installing build dependencies **" -apt-get -y build-dep -Ppkg.ngcp-rtpengine.nobcg729 . - -echo "** Building Debian package **" -dpkg-buildpackage -Ppkg.ngcp-rtpengine.nobcg729 - -# We're inside /github/workspace/ -echo "** Copying Debian package files to workspace **" -cp ../*.deb ../*.buildinfo ../workspace/ - -echo "*** Finished execution of '$0' ***" diff --git a/.github/workflows/debian-package-build.yml b/.github/workflows/debian-package-build.yml new file mode 100644 index 000000000..6a4542c3f --- /dev/null +++ b/.github/workflows/debian-package-build.yml @@ -0,0 +1,90 @@ +name: Debian package build +on: + pull_request: + push: + tags: + - 'mr*' + schedule: + - cron: '0 8 * * *' +permissions: + actions: read + contents: read + pull-requests: write +concurrency: + group: "${{ github.ref }}" + cancel-in-progress: true +jobs: + build-debian: + if: github.event_name != 'schedule' || github.repository == 'sipwise/rtpengine' + runs-on: ubuntu-latest + strategy: + matrix: + dist: [trixie, sid] + steps: + - uses: actions/checkout@v6 + - name: Update changelog + run: | + set -ex + OLD_VERSION=$(dpkg-parsechangelog -SVersion) + SOURCE=$(dpkg-parsechangelog -SSource) + if [[ "${{ github.ref_type }}" == "tag" ]]; then + VERSION_SUFFIX="+gh" + else + VERSION_SUFFIX="+autobuild${GITHUB_RUN_NUMBER}" + fi + cat > debian/changelog < $(date -R) + EOT + - uses: jtdor/build-deb-action@v1 + with: + docker-image: debian:${{ matrix.dist }} + buildpackage-opts: -Ppkg.ngcp-rtpengine.nobcg729 + - name: Archive build result + uses: actions/upload-artifact@v6 + with: + name: packages-${{ matrix.dist }} + if-no-files-found: error + retention-days: 14 + path: | + debian/artifacts/*.deb + debian/artifacts/*.tar.* + debian/artifacts/*.changes + debian/artifacts/*.buildinfo + + comment-pr: + if: github.event_name == 'pull_request' + needs: build-debian + runs-on: ubuntu-latest + steps: + - name: Comment PR with artifact links + continue-on-error: true + uses: actions/github-script@v8 + with: + script: | + const runId = context.runId; + const repoOwner = context.repo.owner; + const repoName = context.repo.repo; + + const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: repoOwner, + repo: repoName, + run_id: runId + }); + + const links = artifacts.data.artifacts + .filter(a => a.name.startsWith('packages-')) + .map(a => `- [${a.name}](https://github.com/${repoOwner}/${repoName}/actions/runs/${runId}/artifacts/${a.id})`) + .join('\n'); + + if (links) { + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: repoOwner, + repo: repoName, + body: `📦 Built Debian packages are ready!\n\n${links}` + }); + } diff --git a/.github/workflows/debpkg.yml b/.github/workflows/debpkg.yml deleted file mode 100644 index d10cf1812..000000000 --- a/.github/workflows/debpkg.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Debian Packaging - -on: - push: - pull_request: - schedule: - - cron: '0 8 * * *' - -jobs: - build-deb-bullseye: - runs-on: ubuntu-latest - name: Debian pipeline for bullseye - - steps: - - name: Checkout source - uses: actions/checkout@v3 - - - name: Execute Docker debpkg action - uses: ./.github/actions/debpkg-bullseye - - - name: Store Debian package artifacts - uses: actions/upload-artifact@v3 - with: - name: Debian binary package files - path: '*.deb' - - - name: Store Debian package build info - uses: actions/upload-artifact@v3 - with: - name: Debian buildinfo file - path: '*.buildinfo' - - build-deb-sid: - runs-on: ubuntu-latest - name: Debian pipeline for sid - - steps: - - name: Checkout source - uses: actions/checkout@v3 - - - name: Execute Docker debpkg action - uses: ./.github/actions/debpkg-sid - - - name: Store Debian package artifacts - uses: actions/upload-artifact@v3 - with: - name: Debian binary package files - path: '*.deb' - - - name: Store Debian package build info - uses: actions/upload-artifact@v3 - with: - name: Debian buildinfo file - path: '*.buildinfo' diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..18014bf8e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,69 @@ +name: Release +on: + workflow_run: + workflows: [Debian package build] + types: [completed] +permissions: + contents: write +jobs: + release: + # Only run for successful tag pushes starting with 'mr' + # (package-build.yml only triggers 'push' events for tags, not branches) + if: >- + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'push' && + startsWith(github.event.workflow_run.head_branch, 'mr') + runs-on: ubuntu-latest + steps: + - name: Checkout source + uses: actions/checkout@v6 + with: + fetch-depth: 0 + + - name: Download all build artifacts + uses: actions/download-artifact@v6 + with: + path: packages + pattern: packages-* + merge-multiple: true + run-id: ${{ github.event.workflow_run.id }} + github-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate changelog + run: | + CURRENT_TAG="${{ github.event.workflow_run.head_branch }}" + PREVIOUS_TAG=$(git tag --list 'mr*' --sort=-version:refname | grep -A1 "^${CURRENT_TAG}$" | tail -1) + + if [ "$PREVIOUS_TAG" = "$CURRENT_TAG" ] || [ -z "$PREVIOUS_TAG" ]; then + RANGE="$CURRENT_TAG" + else + RANGE="${PREVIOUS_TAG}..${CURRENT_TAG}" + fi + + echo "Generating changelog for range: $RANGE" + + echo "## Changes in ${CURRENT_TAG}" > release_notes.md + echo "" >> release_notes.md + if [ "$RANGE" != "$CURRENT_TAG" ]; then + echo "Changes since ${PREVIOUS_TAG}:" >> release_notes.md + echo "" >> release_notes.md + fi + + git log --format='%aN' "$RANGE" | sort -u | while IFS= read -r author; do + echo "### $author" >> release_notes.md + echo "" >> release_notes.md + git log --format='* [%h] %s' --author="$author" "$RANGE" >> release_notes.md + echo "" >> release_notes.md + done + + cat release_notes.md + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ github.event.workflow_run.head_branch }} + name: Release ${{ github.event.workflow_run.head_branch }} + body_path: release_notes.md + files: | + packages/*.deb + packages/*.tar.*