Debian Codegraph @

.github/workflows/release.yml

raw
1 name: release
2 on:
3 push:
4 tags:
5 - 'v*'
6
7 jobs:
8 create-release:
9 runs-on: ubuntu-latest
10 steps:
11 - uses: actions/checkout@v4
12
13 - name: Extract version from tag
14 id: version
15 run: |
16 TAG_NAME="${GITHUB_REF#refs/tags/}"
17 VERSION="${TAG_NAME#v}"
18 echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
19 echo "tag=${TAG_NAME}" >> "$GITHUB_OUTPUT"
20
21 - name: Extract changelog entry
22 id: changelog
23 run: |
24 VERSION="${{ steps.version.outputs.version }}"
25
26 # Extract and clean changelog for this specific version
27 CHANGES=$(dpkg-parsechangelog -l debian/changelog --since "${VERSION}" --until "${VERSION}" --show-field Changes | \
28 sed '/^[a-zA-Z0-9-].*([^)]*)[[:space:]]*.*$/d' | \
29 sed 's/^[[:space:]]*\.[[:space:]]*$//' | \
30 sed '/^[[:space:]]*$/d' | \
31 sed 's/^[[:space:]]*\*[[:space:]]*/- /' | \
32 sed 's/^[[:space:]]*\\+[[:space:]]*/ - /')
33
34 # Set as output for use in release
35 {
36 echo 'description<<EOF'
37 echo "$CHANGES"
38 echo 'EOF'
39 } >> "$GITHUB_OUTPUT"
40
41 - name: Wait for and get package build run ID
42 id: build-run
43 uses: actions/github-script@v7
44 with:
45 script: |
46 const maxWaitTime = 10 * 60 * 1000; // 10 minutes
47 const pollInterval = 30 * 1000; // 30 seconds
48 const startTime = Date.now();
49
50 while (Date.now() - startTime < maxWaitTime) {
51 const runs = await github.rest.actions.listWorkflowRuns({
52 owner: context.repo.owner,
53 repo: context.repo.repo,
54 workflow_id: 'package-build.yml',
55 head_sha: context.sha,
56 status: 'completed',
57 conclusion: 'success'
58 });
59
60 if (runs.data.workflow_runs.length > 0) {
61 const runId = runs.data.workflow_runs[0].id;
62 console.log(`Found successful package-build run: ${runId}`);
63 return runId;
64 }
65
66 console.log('Package-build workflow not completed yet, waiting...');
67 await new Promise(resolve => setTimeout(resolve, pollInterval));
68 }
69
70 throw new Error('Package-build workflow did not complete successfully within 10 minutes');
71
72 - name: Download build artifacts
73 uses: actions/download-artifact@v4
74 with:
75 name: packages
76 path: artifacts/
77 run-id: ${{ steps.build-run.outputs.result }}
78 github-token: ${{ secrets.GITHUB_TOKEN }}
79
80 - name: Create GitHub Release
81 run: |
82 DEB_FILE=$(find artifacts -name "*.deb" -printf "%f\n" | head -1)
83 gh release create "${{ steps.version.outputs.tag }}" \
84 --title "Release ${{ steps.version.outputs.tag }}" \
85 --notes "## Changes in ${{ steps.version.outputs.version }}
86
87 ${{ steps.changelog.outputs.description }}
88
89 ---
90
91 📦 **Installation:**
92 Download the package and install with:
93 \`\`\`bash
94 sudo apt install ./${DEB_FILE}
95 \`\`\`" \
96 artifacts/*
97 env:
98 GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}