Initial debrepo template: CI workflow + package structure
This commit is contained in:
commit
de79f0bc12
59
.gitea/workflows/build-deb.yaml
Normal file
59
.gitea/workflows/build-deb.yaml
Normal file
@ -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"
|
||||||
35
README.md
Normal file
35
README.md
Normal file
@ -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
|
||||||
|
```
|
||||||
7
debian/control
vendored
Normal file
7
debian/control
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
Package: PACKAGE_NAME
|
||||||
|
Version: 0.0.1
|
||||||
|
Section: misc
|
||||||
|
Priority: optional
|
||||||
|
Architecture: amd64
|
||||||
|
Maintainer: n0ball <repo@n0ball.tw>
|
||||||
|
Description: PACKAGE_DESCRIPTION
|
||||||
Loading…
x
Reference in New Issue
Block a user