commit de79f0bc12f8dda037530d2ac3f80c7170846d9d Author: N0Ball Date: Tue Mar 10 22:47:18 2026 +0800 Initial debrepo template: CI workflow + package structure diff --git a/.gitea/workflows/build-deb.yaml b/.gitea/workflows/build-deb.yaml new file mode 100644 index 0000000..c2fecb4 --- /dev/null +++ b/.gitea/workflows/build-deb.yaml @@ -0,0 +1,59 @@ +name: Build and Publish Deb Package +on: + push: + tags: ["v*"] + +jobs: + build: + runs-on: self-hosted + steps: + - name: Checkout + run: | + rm -rf src + git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git src + cd src && git checkout ${{ github.sha }} + + - name: Build .deb package + run: | + cd src + VERSION="${GITHUB_REF_NAME#v}" + PKG_NAME="${GITHUB_REPOSITORY##*/}" + echo "Building ${PKG_NAME} version ${VERSION}" + + # Update version in debian/changelog if it exists + if [ -f debian/changelog ]; then + sed -i "1s/([^)]*)/($VERSION)/" debian/changelog + fi + + dpkg-deb --build --root-owner-group . "../${PKG_NAME}_${VERSION}_amd64.deb" + echo "DEB_FILE=$(ls ../*.deb)" >> "$GITHUB_ENV" + + - name: Setup kubeconfig + run: | + mkdir -p ~/.kube + echo "${{ secrets.KUBECONFIG }}" | base64 -d > ~/.kube/config + chmod 600 ~/.kube/config + + - name: Install kubectl + run: | + if ! command -v kubectl &>/dev/null; then + curl -sLO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" + sudo install kubectl /usr/local/bin/kubectl + fi + + - name: Publish to repo + run: | + POD=$(kubectl get pod -n pkg-repo -l app=pkg-repo -o jsonpath='{.items[0].metadata.name}') + + # Copy .deb into the reprepro sidecar + kubectl cp "$DEB_FILE" "pkg-repo/${POD}:/incoming/" -c reprepro + + # Run reprepro to include the package + kubectl exec -n pkg-repo "${POD}" -c reprepro -- \ + reprepro -b /repo/debian includedeb trixie "/incoming/$(basename $DEB_FILE)" + + # Cleanup + kubectl exec -n pkg-repo "${POD}" -c reprepro -- \ + rm -f "/incoming/$(basename $DEB_FILE)" + + echo "Published $(basename $DEB_FILE) to repo.n0ball.tw" diff --git a/README.md b/README.md new file mode 100644 index 0000000..2e577fe --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# Deb Package Template + +## Quick Start + +1. Fork/copy this template +2. Edit `debian/control` — set Package, Version, Description +3. Add your files (scripts in `usr/local/bin/`, systemd units in `etc/systemd/system/`, etc.) +4. Add Gitea secrets: + - `KUBECONFIG`: base64-encoded kubeconfig for pkg-repo-ci SA +5. Tag a release: `git tag v1.0.0 && git push --tags` +6. CI builds .deb and publishes to repo.n0ball.tw + +## Package Structure + +``` +your-package/ +├── .gitea/workflows/build-deb.yaml # CI pipeline (do not modify) +├── debian/ +│ ├── control # Package metadata +│ ├── install # (optional) file install mapping +│ ├── postinst # (optional) post-install script +│ └── changelog # (optional) changelog +├── usr/local/bin/ # Scripts +├── etc/systemd/system/ # Systemd units +└── etc/ # Config files +``` + +## Client Setup + +```bash +curl https://repo.n0ball.tw/pubkey.gpg | gpg --dearmor | sudo tee /etc/apt/keyrings/n0ball.gpg > /dev/null +echo "deb [signed-by=/etc/apt/keyrings/n0ball.gpg] https://repo.n0ball.tw/debian trixie main" | sudo tee /etc/apt/sources.list.d/n0ball.list +sudo apt update +sudo apt install your-package +``` diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..060ac18 --- /dev/null +++ b/debian/control @@ -0,0 +1,7 @@ +Package: PACKAGE_NAME +Version: 0.0.1 +Section: misc +Priority: optional +Architecture: amd64 +Maintainer: n0ball +Description: PACKAGE_DESCRIPTION