|
4 | 4 | push: |
5 | 5 | paths: |
6 | 6 | - "safexec/safexec.c" |
7 | | - - "safexec/libnpp_norm.c" |
| 7 | + - "safexec/libnpp_norm.c" |
| 8 | + - "safexec/helpers/deb.sh" |
8 | 9 | - ".github/workflows/build-and-commit-safexec.yml" |
9 | 10 | workflow_dispatch: {} |
10 | 11 |
|
@@ -461,3 +462,97 @@ jobs: |
461 | 462 |
|
462 | 463 | git commit -m "ci: build safexec + libnpp_norm (glibc/musl)" |
463 | 464 | git push origin HEAD:${GITHUB_REF#refs/heads/} |
| 465 | +
|
| 466 | + deb-packages: |
| 467 | + name: Build .deb packages |
| 468 | + needs: build-commit |
| 469 | + runs-on: ubuntu-latest |
| 470 | + permissions: |
| 471 | + contents: write |
| 472 | + id-token: write |
| 473 | + attestations: write |
| 474 | + actions: read |
| 475 | + env: |
| 476 | + DEB_REV: "1" |
| 477 | + steps: |
| 478 | + - name: Checkout |
| 479 | + uses: actions/checkout@v5 |
| 480 | + with: |
| 481 | + fetch-depth: 0 |
| 482 | + |
| 483 | + - name: Ensure Debian tooling |
| 484 | + run: | |
| 485 | + set -euo pipefail |
| 486 | + sudo apt-get update |
| 487 | + sudo apt-get install -y --no-install-recommends \ |
| 488 | + devscripts debhelper dpkg-dev lintian |
| 489 | +
|
| 490 | + - name: Detect version from safexec -v |
| 491 | + id: ver |
| 492 | + run: | |
| 493 | + set -euo pipefail |
| 494 | + BIN="safexec/bin/safexec-x86_64-linux-musl" |
| 495 | + if [[ ! -x "$BIN" ]]; then |
| 496 | + # fallback if only arm64 was rebuilt for some reason |
| 497 | + BIN="safexec/bin/safexec-aarch64-linux-musl" |
| 498 | + fi |
| 499 | + [[ -x "$BIN" ]] || { echo "safexec binary not found in safexec/bin"; exit 1; } |
| 500 | + BASE_VER="$("$BIN" -v | awk '{print $2}')" |
| 501 | + echo "base=$BASE_VER" >> "$GITHUB_OUTPUT" |
| 502 | + echo "deb=${BASE_VER}-${DEB_REV}" >> "$GITHUB_OUTPUT" |
| 503 | + echo "Detected: ${BASE_VER}-${DEB_REV}" |
| 504 | +
|
| 505 | + - name: Make deb.sh executable |
| 506 | + run: chmod +x safexec/helpers/deb.sh |
| 507 | + |
| 508 | + - name: Build .deb (amd64) |
| 509 | + run: | |
| 510 | + set -euo pipefail |
| 511 | + bash safexec/helpers/deb.sh --arch amd64 --version "${{ steps.ver.outputs.deb }}" |
| 512 | +
|
| 513 | + - name: Build .deb (arm64) |
| 514 | + run: | |
| 515 | + set -euo pipefail |
| 516 | + bash safexec/helpers/deb.sh --arch arm64 --version "${{ steps.ver.outputs.deb }}" |
| 517 | +
|
| 518 | + - name: Collect .debs into safexec/deb/ |
| 519 | + run: | |
| 520 | + set -euo pipefail |
| 521 | + mkdir -p safexec/deb |
| 522 | + mv safexec_*_${{ steps.ver.outputs.deb }}_amd64.deb safexec/deb/ 2>/dev/null || true |
| 523 | + mv safexec_*_${{ steps.ver.outputs.deb }}_arm64.deb safexec/deb/ 2>/dev/null || true |
| 524 | + cd safexec/deb |
| 525 | + ls -1 *.deb |
| 526 | + sha256sum *.deb | sort > SHA256SUMS |
| 527 | +
|
| 528 | + - name: Generate SLSA provenance (deb packages) |
| 529 | + uses: actions/attest-build-provenance@v3 |
| 530 | + with: |
| 531 | + subject-path: | |
| 532 | + safexec/deb/*.deb |
| 533 | + safexec/deb/SHA256SUMS |
| 534 | +
|
| 535 | + - name: Upload debs as artifacts |
| 536 | + uses: actions/upload-artifact@v4 |
| 537 | + with: |
| 538 | + name: safexec-debs-${{ steps.ver.outputs.deb }} |
| 539 | + path: | |
| 540 | + safexec/deb/*.deb |
| 541 | + safexec/deb/SHA256SUMS |
| 542 | + if-no-files-found: error |
| 543 | + |
| 544 | + - name: Commit .deb packages back to repo |
| 545 | + if: github.ref_type == 'branch' |
| 546 | + env: |
| 547 | + GITHUB_REF: ${{ github.ref }} |
| 548 | + run: | |
| 549 | + set -euo pipefail |
| 550 | + git config user.name "github-actions[bot]" |
| 551 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 552 | + git add safexec/deb/*.deb safexec/deb/SHA256SUMS || true |
| 553 | + if git diff --cached --quiet; then |
| 554 | + echo "No .deb changes to commit." |
| 555 | + exit 0 |
| 556 | + fi |
| 557 | + git commit -m "ci: add Debian packages for ${{ steps.ver.outputs.deb }}" |
| 558 | + git push origin HEAD:${GITHUB_REF#refs/heads/} |
0 commit comments