Skip to content

Commit 601d2fb

Browse files
mikarfuchs
authored andcommitted
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 e9fc1b1)
1 parent efade36 commit 601d2fb

9 files changed

Lines changed: 159 additions & 126 deletions

File tree

.github/actions/debpkg-bookworm/Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/actions/debpkg-bookworm/action.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/actions/debpkg-bookworm/entrypoint.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.

.github/actions/debpkg-sid/Dockerfile

Lines changed: 0 additions & 13 deletions
This file was deleted.

.github/actions/debpkg-sid/action.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/actions/debpkg-sid/entrypoint.sh

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: Debian package build
2+
on:
3+
pull_request:
4+
push:
5+
tags:
6+
- 'mr*'
7+
schedule:
8+
- cron: '0 8 * * *'
9+
permissions:
10+
actions: read
11+
contents: read
12+
pull-requests: write
13+
concurrency:
14+
group: "${{ github.ref }}"
15+
cancel-in-progress: true
16+
jobs:
17+
build-debian:
18+
if: github.event_name != 'schedule' || github.repository == 'sipwise/rtpengine'
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
dist: [trixie, sid]
23+
steps:
24+
- uses: actions/checkout@v6
25+
- name: Update changelog
26+
run: |
27+
set -ex
28+
OLD_VERSION=$(dpkg-parsechangelog -SVersion)
29+
SOURCE=$(dpkg-parsechangelog -SSource)
30+
if [[ "${{ github.ref_type }}" == "tag" ]]; then
31+
VERSION_SUFFIX="+gh"
32+
else
33+
VERSION_SUFFIX="+autobuild${GITHUB_RUN_NUMBER}"
34+
fi
35+
cat > debian/changelog <<EOT
36+
${SOURCE} (${OLD_VERSION}${VERSION_SUFFIX}) UNRELEASED; urgency=medium
37+
38+
* Automated Build
39+
40+
-- Automated Build <builder@localhost> $(date -R)
41+
EOT
42+
- uses: jtdor/build-deb-action@v1
43+
with:
44+
docker-image: debian:${{ matrix.dist }}
45+
buildpackage-opts: -Ppkg.ngcp-rtpengine.nobcg729
46+
- name: Archive build result
47+
uses: actions/upload-artifact@v6
48+
with:
49+
name: packages-${{ matrix.dist }}
50+
if-no-files-found: error
51+
retention-days: 14
52+
path: |
53+
debian/artifacts/*.deb
54+
debian/artifacts/*.tar.*
55+
debian/artifacts/*.changes
56+
debian/artifacts/*.buildinfo
57+
58+
comment-pr:
59+
if: github.event_name == 'pull_request'
60+
needs: build-debian
61+
runs-on: ubuntu-latest
62+
steps:
63+
- name: Comment PR with artifact links
64+
continue-on-error: true
65+
uses: actions/github-script@v8
66+
with:
67+
script: |
68+
const runId = context.runId;
69+
const repoOwner = context.repo.owner;
70+
const repoName = context.repo.repo;
71+
72+
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
73+
owner: repoOwner,
74+
repo: repoName,
75+
run_id: runId
76+
});
77+
78+
const links = artifacts.data.artifacts
79+
.filter(a => a.name.startsWith('packages-'))
80+
.map(a => `- [${a.name}](https://github.com/${repoOwner}/${repoName}/actions/runs/${runId}/artifacts/${a.id})`)
81+
.join('\n');
82+
83+
if (links) {
84+
github.rest.issues.createComment({
85+
issue_number: context.issue.number,
86+
owner: repoOwner,
87+
repo: repoName,
88+
body: `📦 Built Debian packages are ready!\n\n${links}`
89+
});
90+
}

.github/workflows/debpkg.yml

Lines changed: 0 additions & 56 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: Release
2+
on:
3+
workflow_run:
4+
workflows: [Debian package build]
5+
types: [completed]
6+
permissions:
7+
contents: write
8+
jobs:
9+
release:
10+
# Only run for successful tag pushes starting with 'mr'
11+
# (package-build.yml only triggers 'push' events for tags, not branches)
12+
if: >-
13+
github.event.workflow_run.conclusion == 'success' &&
14+
github.event.workflow_run.event == 'push' &&
15+
startsWith(github.event.workflow_run.head_branch, 'mr')
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: Checkout source
19+
uses: actions/checkout@v6
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Download all build artifacts
24+
uses: actions/download-artifact@v6
25+
with:
26+
path: packages
27+
pattern: packages-*
28+
merge-multiple: true
29+
run-id: ${{ github.event.workflow_run.id }}
30+
github-token: ${{ secrets.GITHUB_TOKEN }}
31+
32+
- name: Generate changelog
33+
run: |
34+
CURRENT_TAG="${{ github.event.workflow_run.head_branch }}"
35+
PREVIOUS_TAG=$(git tag --list 'mr*' --sort=-version:refname | grep -A1 "^${CURRENT_TAG}$" | tail -1)
36+
37+
if [ "$PREVIOUS_TAG" = "$CURRENT_TAG" ] || [ -z "$PREVIOUS_TAG" ]; then
38+
RANGE="$CURRENT_TAG"
39+
else
40+
RANGE="${PREVIOUS_TAG}..${CURRENT_TAG}"
41+
fi
42+
43+
echo "Generating changelog for range: $RANGE"
44+
45+
echo "## Changes in ${CURRENT_TAG}" > release_notes.md
46+
echo "" >> release_notes.md
47+
if [ "$RANGE" != "$CURRENT_TAG" ]; then
48+
echo "Changes since ${PREVIOUS_TAG}:" >> release_notes.md
49+
echo "" >> release_notes.md
50+
fi
51+
52+
git log --format='%aN' "$RANGE" | sort -u | while IFS= read -r author; do
53+
echo "### $author" >> release_notes.md
54+
echo "" >> release_notes.md
55+
git log --format='* [%h] %s' --author="$author" "$RANGE" >> release_notes.md
56+
echo "" >> release_notes.md
57+
done
58+
59+
cat release_notes.md
60+
61+
- name: Create GitHub Release
62+
uses: softprops/action-gh-release@v2
63+
with:
64+
tag_name: ${{ github.event.workflow_run.head_branch }}
65+
name: Release ${{ github.event.workflow_run.head_branch }}
66+
body_path: release_notes.md
67+
files: |
68+
packages/*.deb
69+
packages/*.tar.*

0 commit comments

Comments
 (0)