| 1 |
name: package-build |
| 2 |
on: |
| 3 |
pull_request: |
| 4 |
push: |
| 5 |
tags: |
| 6 |
- 'v*' |
| 7 |
|
| 8 |
concurrency: |
| 9 |
group: "${{ github.ref }}" |
| 10 |
cancel-in-progress: true |
| 11 |
jobs: |
| 12 |
build-debian: |
| 13 |
runs-on: ubuntu-latest |
| 14 |
steps: |
| 15 |
- uses: actions/checkout@v4 |
| 16 |
- name: "Update changelog" |
| 17 |
run: | |
| 18 |
set -ex |
| 19 |
OLD_VERSION=$(dpkg-parsechangelog -SVersion) |
| 20 |
SOURCE=$(dpkg-parsechangelog -SSource) |
| 21 |
if [[ "${{ github.ref_type }}" == "tag" ]]; then |
| 22 |
VERSION_SUFFIX="+gh" |
| 23 |
else |
| 24 |
VERSION_SUFFIX="+autobuild${GITHUB_RUN_NUMBER}" |
| 25 |
fi |
| 26 |
cat > debian/changelog <<EOT |
| 27 |
${SOURCE} (${OLD_VERSION}${VERSION_SUFFIX}) UNRELEASED; urgency=medium |
| 28 |
|
| 29 |
* Automated Build |
| 30 |
|
| 31 |
-- Automated Build <builder@localhost> $(date -R) |
| 32 |
EOT |
| 33 |
- uses: jtdor/build-deb-action@v1 |
| 34 |
- name: Archive build result |
| 35 |
uses: actions/upload-artifact@v4 |
| 36 |
with: |
| 37 |
name: packages |
| 38 |
if-no-files-found: error |
| 39 |
retention-days: 14 |
| 40 |
path: | |
| 41 |
debian/artifacts/*.deb |
| 42 |
debian/artifacts/*.tar.* |
| 43 |
- name: Comment PR with artifact link |
| 44 |
if: github.event_name == 'pull_request' |
| 45 |
uses: actions/github-script@v7 |
| 46 |
with: |
| 47 |
script: | |
| 48 |
const runId = context.runId; |
| 49 |
const repoOwner = context.repo.owner; |
| 50 |
const repoName = context.repo.repo; |
| 51 |
|
| 52 |
// Get the artifact download URL |
| 53 |
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({ |
| 54 |
owner: repoOwner, |
| 55 |
repo: repoName, |
| 56 |
run_id: runId |
| 57 |
}); |
| 58 |
|
| 59 |
const packagesArtifact = artifacts.data.artifacts.find(artifact => artifact.name === 'packages'); |
| 60 |
if (!packagesArtifact) { |
| 61 |
console.log('No packages artifact found'); |
| 62 |
return; |
| 63 |
} |
| 64 |
|
| 65 |
const artifactUrl = `https://github.com/${repoOwner}/${repoName}/actions/runs/${runId}/artifacts/${packagesArtifact.id}`; |
| 66 |
|
| 67 |
github.rest.issues.createComment({ |
| 68 |
issue_number: context.issue.number, |
| 69 |
owner: context.repo.owner, |
| 70 |
repo: context.repo.repo, |
| 71 |
body: `📦 Built packages are ready! [Download here](${artifactUrl}).` |
| 72 |
}); |