File: package-build.yml

package info (click to toggle)
grml-debootstrap 0.123
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 464 kB
  • sloc: sh: 2,562; python: 165; makefile: 72; ansic: 49
file content (75 lines) | stat: -rw-r--r-- 2,385 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: package-build
on:
  pull_request:
  push:
    tags:
      - 'v*'
permissions:
  actions: read
  contents: read
  pull-requests: write
concurrency:
  group: "${{ github.ref }}"
  cancel-in-progress: true
jobs:
  build-debian:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - 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 <<EOT
          ${SOURCE} (${OLD_VERSION}${VERSION_SUFFIX}) UNRELEASED; urgency=medium

            * Automated Build

           -- Automated Build <builder@localhost>  $(date -R)
          EOT
      - uses: jtdor/build-deb-action@v1
      - name: Archive build result
        uses: actions/upload-artifact@v4
        with:
          name: packages
          if-no-files-found: error
          retention-days: 14
          path: |
            debian/artifacts/*.deb
            debian/artifacts/*.tar.*
      - name: Comment PR with artifact link
        if: github.event_name == 'pull_request'
        uses: actions/github-script@v8
        with:
          script: |
            const runId = context.runId;
            const repoOwner = context.repo.owner;
            const repoName = context.repo.repo;

            // Get the artifact download URL
            const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
              owner: repoOwner,
              repo: repoName,
              run_id: runId
            });

            const packagesArtifact = artifacts.data.artifacts.find(artifact => artifact.name === 'packages');
            if (!packagesArtifact) {
              console.log('No packages artifact found');
              return;
            }

            const artifactUrl = `https://github.com/${repoOwner}/${repoName}/actions/runs/${runId}/artifacts/${packagesArtifact.id}`;

            github.rest.issues.createComment({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              body: `📦 Built packages are ready! [Download here](${artifactUrl}).`
            });