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