build(ci): unify FreeBSD packaging across native/chroot/ports/CI with… #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # .github/workflows/freebsd-pkg.yml | |
| name: FreeBSD 14 .pkg | |
| on: | |
| workflow_dispatch: | |
| push: | |
| branches: [ "main" ] | |
| paths: | |
| - "src/**" | |
| - "packaging/**" | |
| - "scripts/build-and-package-freebsd.sh" | |
| - "ecli.spec" | |
| - "pyproject.toml" | |
| permissions: | |
| contents: write | |
| jobs: | |
| build-freebsd-pkg: | |
| runs-on: ubuntu-latest | |
| name: "Build FreeBSD 14.3 .pkg" | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Build in FreeBSD 14.3 VM | |
| uses: vmactions/freebsd-vm@v1 | |
| with: | |
| release: "14.3" | |
| usesh: true | |
| mem: 4096 | |
| cpu: 2 | |
| sync: rsync | |
| copyback: true | |
| prepare: | | |
| set -eux | |
| env ASSUME_ALWAYS_YES=yes pkg update -f | |
| run: | | |
| set -eux | |
| sh ./scripts/build-and-package-freebsd.sh | |
| - name: Find built .pkg and checksum | |
| id: find_pkg | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| shopt -s nullglob | |
| mapfile -t PKGS < <(ls -1 releases/*/ecli-*.pkg 2>/dev/null || true) | |
| mapfile -t SHAS < <(ls -1 releases/*/ecli-*.pkg.sha256 2>/dev/null || true) | |
| if (( ${#PKGS[@]} == 0 )); then | |
| echo "No .pkg files found under releases/**/ — build failed or copyback disabled" >&2 | |
| exit 2 | |
| fi | |
| echo "pkg_path=${PKGS[-1]}" >> "$GITHUB_OUTPUT" | |
| if (( ${#SHAS[@]} )); then | |
| echo "checksum_path=${SHAS[-1]}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "checksum_path=" >> "$GITHUB_OUTPUT" | |
| fi | |
| echo "Found: ${PKGS[-1]}" | |
| [[ -n "${SHAS[-1]:-}" ]] && echo "Found checksum: ${SHAS[-1]}" | |
| - name: Upload artifact (.pkg and checksum) | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: freebsd-pkg | |
| path: | | |
| ${{ steps.find_pkg.outputs.pkg_path }} | |
| ${{ steps.find_pkg.outputs.checksum_path }} | |
| if-no-files-found: error | |
| - name: Commit .pkg and checksum into repository | |
| if: ${{ github.ref == 'refs/heads/main' }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| PKG="${{ steps.find_pkg.outputs.pkg_path }}" | |
| CHECKSUM="${{ steps.find_pkg.outputs.checksum_path }}" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add "$PKG" | |
| if [[ -n "$CHECKSUM" ]]; then git add "$CHECKSUM"; fi | |
| git commit -m "ci(freebsd): add built pkg artifact $PKG and checksum [skip ci]" || echo "No changes to commit" | |
| git push |