61 lines
2.0 KiB
YAML
61 lines
2.0 KiB
YAML
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 control file
|
|
sed -i "s/^Version:.*/Version: ${VERSION}/" debian/control
|
|
|
|
# dpkg-deb requires uppercase DEBIAN directory
|
|
mv debian DEBIAN
|
|
|
|
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"
|