From 16f1b83d985ad610a91ed2d2cd9fcd9485b2b241 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 11 May 2026 13:17:32 -0400 Subject: [PATCH] MT#65080 add GH actions to automate release builds Adapted from: https://github.com/sipwise/rtpengine/tree/master/.github/workflows https://github.com/sipwise/rtpengine/commit/e9fc1b10572fd806666927075d2ba1e1d9f25fcd https://github.com/sipwise/rtpengine/commit/68c6bf60a8e239bd8e39b6e79a4cd641c2a52a06 https://github.com/sipwise/rtpengine/commit/071f3187076ecfbcacbf0a63ad3c6166a17d529b Change-Id: I75d3fbf8d8087a4583336f454f4e9fd30aae12c0 (cherry picked from commit 8397b9c242a2087a806e878ccaa4de28d9896ccd) --- .github/workflows/debian-package-build.yml | 90 ++++++++++++++++++++++ .github/workflows/release.yml | 69 +++++++++++++++++ 2 files changed, 159 insertions(+) create mode 100644 .github/workflows/debian-package-build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/debian-package-build.yml b/.github/workflows/debian-package-build.yml new file mode 100644 index 00000000..13dfaf3d --- /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/sems' + runs-on: ${{ matrix.os }} + strategy: + matrix: + dist: [trixie, sid] + os: [ubuntu-latest] + 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+${{ matrix.dist }}" + else + VERSION_SUFFIX="+autobuild${GITHUB_RUN_NUMBER}+${{ matrix.dist }}" + fi + cat > debian/changelog < $(date -R) + EOT + - uses: jtdor/build-deb-action@v1 + with: + docker-image: debian:${{ matrix.dist }} + - 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/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..18014bf8 --- /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.*