From 2c6ad3e0bd9fec251c9572fae37a53534c995956 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 22:55:11 -0700 Subject: [PATCH 01/33] TEST --- .gitea/workflows/build-release.yml | 12 +++ ci/build.sh | 113 +++++++++++++++++++++++++++++ 2 files changed, 125 insertions(+) create mode 100644 .gitea/workflows/build-release.yml create mode 100755 ci/build.sh diff --git a/.gitea/workflows/build-release.yml b/.gitea/workflows/build-release.yml new file mode 100644 index 0000000..5288269 --- /dev/null +++ b/.gitea/workflows/build-release.yml @@ -0,0 +1,12 @@ +name: Build Coredns with netboxdns plugin +on: [workflow_dispatch] + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v5 + + - name: Build + run: ./ci/build.sh diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 0000000..74772b6 --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,113 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Inputs expected from the workflow: +# GITHUB_REPOSITORY - owner/repo of the current action repo (provided by Actions) +# GITHUB_SHA - commit to clone/check out (provided by Actions, optional) +# GO_VERSION - optional, e.g. "1.23.3"; if unset, script will query latest. + +main() { + # 1. Create temp directory + TMPDIR="$(mktemp -d)" + echo "Using temp dir: ${TMPDIR}" + + # 2. Clone latest CoreDNS release + cd "${TMPDIR}" + COREDNS_REPO_URL="https://github.com/coredns/coredns.git" + COREDNS_DIR="${TMPDIR}/coredns" + + # get latest tag (annotated or lightweight) + git clone --depth=1 --filter=blob:none --tags "${COREDNS_REPO_URL}" "${COREDNS_DIR}" + cd "${COREDNS_DIR}" + LATEST_TAG="$(git describe --tags "$(git rev-list --tags --max-count=1)")" + git fetch --tags --depth=1 origin "${LATEST_TAG}" + git checkout "${LATEST_TAG}" + + # 3. Clone the GitHub Action's repo (this repo) + ACTION_REPO_DIR="${TMPDIR}/action-repo" + git clone "https://github.com/${GITHUB_REPOSITORY}.git" "${ACTION_REPO_DIR}" + if [ -n "${GITHUB_SHA:-}" ]; then + cd "${ACTION_REPO_DIR}" + git checkout "${GITHUB_SHA}" + fi + + # 4. cd into the CoreDNS repo + cd "${COREDNS_DIR}" + + # 5. Update plugin.cfg to include netboxdns plugin + # Insert netboxdns after the 'cache' plugin entry as recommended. [web:16][web:29] + if ! grep -q '^netboxdns:' plugin.cfg; then + awk ' + /^cache:/ { + print + print "netboxdns:github.com/doubleu-labs/coredns-netbox-plugin-dns" + next + } + { print } + ' plugin.cfg >plugin.cfg.new + mv plugin.cfg.new plugin.cfg + fi + + # 6. Regenerate plugin source files + # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] + make gen || go generate ./... + + # 7. go mod replace plugin path to the cloned action repo + # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] + # Adjust relative path if your repo layout differs. + go mod edit -replace=github.com/doubleu-labs/coredns-netbox-plugin-dns="${ACTION_REPO_DIR}" + + # 8. Update Go version to the latest + # Install or pick latest Go and set GOTOOLCHAIN, or rely on pre-installed toolchain in the runner. [web:17] + # Here we query the latest stable from golang.org and export it for this build. + if [ -z "${GO_VERSION:-}" ]; then + GO_VERSION="$(curl -s https://go.dev/VERSION?m=text | head -n1 | sed 's/^go//')" # e.g. "1.23.3" + fi + + echo "Using Go version: ${GO_VERSION}" + + # If you use setup-go in the workflow, this is optional; otherwise install here. + # Example (Debian-based runner): + # sudo rm -rf /usr/local/go + # curl -sL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" | sudo tar -C /usr/local -xz + # export PATH="/usr/local/go/bin:${PATH}" + + export GOTOOLCHAIN="go${GO_VERSION}" + + # 9. Compile CoreDNS + make coredns || make + + # 10. Strip the binary + STRIP_BIN="${STRIP_BIN:-strip}" + "${STRIP_BIN}" ./coredns + + # 11. Create a .deb installing /usr/local/bin/coredns + # Minimal Debian package using dpkg-deb. [web:17] + PKG_ROOT="${TMPDIR}/pkg-root" + mkdir -p "${PKG_ROOT}/DEBIAN" "${PKG_ROOT}/usr/local/bin" + + # Basic metadata; tweak as needed + PKG_NAME="coredns-netboxdns" + PKG_VERSION="$(echo "${LATEST_TAG}" | sed 's/^v//')" + PKG_ARCH="$(dpkg --print-architecture 2>/dev/null || echo amd64)" + + cat >"${PKG_ROOT}/DEBIAN/control" < +Description: CoreDNS with netboxdns plugin + Custom CoreDNS build with netboxdns plugin compiled in. +EOF + + install -m 0755 ./coredns "${PKG_ROOT}/usr/local/bin/coredns" + + DEB_OUT="${TMPDIR}/${PKG_NAME}_${PKG_VERSION}_${PKG_ARCH}.deb" + dpkg-deb --build "${PKG_ROOT}" "${DEB_OUT}" + + echo "Built Debian package at: ${DEB_OUT}" +} + +main "$@" -- 2.52.0 From 30623a158d72308b74ce77a74fd943c8191325f2 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 22:55:42 -0700 Subject: [PATCH 02/33] TEST --- .gitea/workflows/build-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-release.yml b/.gitea/workflows/build-release.yml index 5288269..b926157 100644 --- a/.gitea/workflows/build-release.yml +++ b/.gitea/workflows/build-release.yml @@ -1,5 +1,5 @@ name: Build Coredns with netboxdns plugin -on: [workflow_dispatch] +on: [push] jobs: build: -- 2.52.0 From e81ce40e61a3e15c9ff25bbda974bbe9ce81f834 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 22:56:37 -0700 Subject: [PATCH 03/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 74772b6..940ba68 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -euo pipefail +set -xeuo pipefail # Inputs expected from the workflow: # GITHUB_REPOSITORY - owner/repo of the current action repo (provided by Actions) -- 2.52.0 From efba990b600f7a8a83e74fba1e53814e3074a7e2 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 22:58:47 -0700 Subject: [PATCH 04/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 940ba68..e82896c 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -19,7 +19,7 @@ main() { # get latest tag (annotated or lightweight) git clone --depth=1 --filter=blob:none --tags "${COREDNS_REPO_URL}" "${COREDNS_DIR}" cd "${COREDNS_DIR}" - LATEST_TAG="$(git describe --tags "$(git rev-list --tags --max-count=1)")" + LATEST_TAG="$(git tag --list --sort=-version:refname | head -n 1)" git fetch --tags --depth=1 origin "${LATEST_TAG}" git checkout "${LATEST_TAG}" -- 2.52.0 From ec7628c1ecbd3764ab38fbdc9c4f43a6cac4c071 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:00:26 -0700 Subject: [PATCH 05/33] TEST --- ci/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/build.sh b/ci/build.sh index e82896c..8802139 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -19,6 +19,7 @@ main() { # get latest tag (annotated or lightweight) git clone --depth=1 --filter=blob:none --tags "${COREDNS_REPO_URL}" "${COREDNS_DIR}" cd "${COREDNS_DIR}" + git fetch --tags LATEST_TAG="$(git tag --list --sort=-version:refname | head -n 1)" git fetch --tags --depth=1 origin "${LATEST_TAG}" git checkout "${LATEST_TAG}" -- 2.52.0 From fc9e9ee627756da439686b525b32d3e6771f178d Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:13:21 -0700 Subject: [PATCH 06/33] TEST --- ci/build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ci/build.sh b/ci/build.sh index 8802139..5e5fb11 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -24,8 +24,12 @@ main() { git fetch --tags --depth=1 origin "${LATEST_TAG}" git checkout "${LATEST_TAG}" + # 3. Clone the GitHub Action's repo (this repo) ACTION_REPO_DIR="${TMPDIR}/action-repo" + #CLONE_URL="${{ gitea.server_url }}/${{ gitea.repository }}.git" + CLONE_URL="${{ gitea.server_url }}/${{ gitea.repository }}.git" + git clone "$CLONE_URL" "${ACTION_REPO_DIR}" git clone "https://github.com/${GITHUB_REPOSITORY}.git" "${ACTION_REPO_DIR}" if [ -n "${GITHUB_SHA:-}" ]; then cd "${ACTION_REPO_DIR}" -- 2.52.0 From 01476201d74f9963e9c0acc462300a8cf1090d19 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:15:30 -0700 Subject: [PATCH 07/33] TEST --- ci/build.sh | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 5e5fb11..4957362 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -24,17 +24,10 @@ main() { git fetch --tags --depth=1 origin "${LATEST_TAG}" git checkout "${LATEST_TAG}" - # 3. Clone the GitHub Action's repo (this repo) ACTION_REPO_DIR="${TMPDIR}/action-repo" - #CLONE_URL="${{ gitea.server_url }}/${{ gitea.repository }}.git" - CLONE_URL="${{ gitea.server_url }}/${{ gitea.repository }}.git" - git clone "$CLONE_URL" "${ACTION_REPO_DIR}" - git clone "https://github.com/${GITHUB_REPOSITORY}.git" "${ACTION_REPO_DIR}" - if [ -n "${GITHUB_SHA:-}" ]; then - cd "${ACTION_REPO_DIR}" - git checkout "${GITHUB_SHA}" - fi + mkdir "${ACTION_REPO_DIR}" + cp -a . "${ACTION_REPO_DIR}/" # 4. cd into the CoreDNS repo cd "${COREDNS_DIR}" -- 2.52.0 From 71c92088ba566bd0133643035fe0b60bc57041ad Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:17:41 -0700 Subject: [PATCH 08/33] TEST --- ci/build.sh | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 4957362..2d18644 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -48,12 +48,20 @@ main() { # 6. Regenerate plugin source files # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] - make gen || go generate ./... + docker run --rm -it \ + --user "$(id -u):$(id -g)" \ + -v "$PWD":"$PWD" \ + -w "$PWD" \ + golang:latest make gen || go generate ./... # 7. go mod replace plugin path to the cloned action repo # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] # Adjust relative path if your repo layout differs. - go mod edit -replace=github.com/doubleu-labs/coredns-netbox-plugin-dns="${ACTION_REPO_DIR}" + docker run --rm -it \ + --user "$(id -u):$(id -g)" \ + -v "$PWD":"$PWD" \ + -w "$PWD" \ + golang:latest go mod edit -replace=github.com/doubleu-labs/coredns-netbox-plugin-dns="${ACTION_REPO_DIR}" # 8. Update Go version to the latest # Install or pick latest Go and set GOTOOLCHAIN, or rely on pre-installed toolchain in the runner. [web:17] -- 2.52.0 From dd0233a1b87dd3e6417c7d510f64cffc5d0c1eee Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:19:21 -0700 Subject: [PATCH 09/33] TEST --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 2d18644..bb13ee2 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -48,11 +48,11 @@ main() { # 6. Regenerate plugin source files # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] - docker run --rm -it \ + docker run --rm \ --user "$(id -u):$(id -g)" \ -v "$PWD":"$PWD" \ -w "$PWD" \ - golang:latest make gen || go generate ./... + golang:latest bash -c "make gen || go generate ./..." # 7. go mod replace plugin path to the cloned action repo # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] -- 2.52.0 From 700a67bd27d1f19f0fc04b1b1f7708d8e571f750 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:22:35 -0700 Subject: [PATCH 10/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index bb13ee2..d84e8f6 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -52,7 +52,7 @@ main() { --user "$(id -u):$(id -g)" \ -v "$PWD":"$PWD" \ -w "$PWD" \ - golang:latest bash -c "make gen || go generate ./..." + golang:latest bash -c make core/plugin/zplugin.go core/dnsserver/zdirectives.go # 7. go mod replace plugin path to the cloned action repo # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] -- 2.52.0 From fea078e065f83ae6b5a00827bc46c82d27685297 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:24:03 -0700 Subject: [PATCH 11/33] TEST --- ci/build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index d84e8f6..9498da5 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -50,8 +50,8 @@ main() { # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] docker run --rm \ --user "$(id -u):$(id -g)" \ - -v "$PWD":"$PWD" \ - -w "$PWD" \ + -v "$PWD":"/work" \ + -w "/work" \ golang:latest bash -c make core/plugin/zplugin.go core/dnsserver/zdirectives.go # 7. go mod replace plugin path to the cloned action repo @@ -59,8 +59,8 @@ main() { # Adjust relative path if your repo layout differs. docker run --rm -it \ --user "$(id -u):$(id -g)" \ - -v "$PWD":"$PWD" \ - -w "$PWD" \ + -v "$PWD":"/work" \ + -w "/work" \ golang:latest go mod edit -replace=github.com/doubleu-labs/coredns-netbox-plugin-dns="${ACTION_REPO_DIR}" # 8. Update Go version to the latest -- 2.52.0 From c18115b2b8d2902f7b07937c4a509103bd763056 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:24:51 -0700 Subject: [PATCH 12/33] TEST --- ci/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/build.sh b/ci/build.sh index 9498da5..23bdbd2 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -46,6 +46,8 @@ main() { mv plugin.cfg.new plugin.cfg fi + ls -lah + # 6. Regenerate plugin source files # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] docker run --rm \ -- 2.52.0 From f1b37e787c43ee7aa769995f7476829dc385d9a0 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:25:32 -0700 Subject: [PATCH 13/33] TEST --- ci/build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ci/build.sh b/ci/build.sh index 23bdbd2..78de6e4 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -48,6 +48,12 @@ main() { ls -lah + docker run --rm \ + --user "$(id -u):$(id -g)" \ + -v "$PWD":"/work" \ + -w "/work" \ + golang:latest ls -lah + # 6. Regenerate plugin source files # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] docker run --rm \ -- 2.52.0 From 0da9b977959fb75560323e7e41570811906bf3f7 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:32:28 -0700 Subject: [PATCH 14/33] TEST --- ci/build.sh | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/ci/build.sh b/ci/build.sh index 78de6e4..b7d11fd 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -11,6 +11,15 @@ main() { TMPDIR="$(mktemp -d)" echo "Using temp dir: ${TMPDIR}" + cd "${TMPDIR}" + mkdir golang + cd golang + GO_VERSION=$(curl -s 'https://go.dev/VERSION?m=text' | head -n1) + GOLANG_URL="https://go.dev/dl/$(GO_VERSION).linux-amd64.tar.gz" + wget "${GOLANG_URL}" + tar xzf "${GO_VERSION}.linux-amd64.tar.gz" + ls -lah + # 2. Clone latest CoreDNS release cd "${TMPDIR}" COREDNS_REPO_URL="https://github.com/coredns/coredns.git" -- 2.52.0 From 76cd206046d856fba788e5f37c2e7727dab00002 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:33:10 -0700 Subject: [PATCH 15/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index b7d11fd..21e103f 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -15,7 +15,7 @@ main() { mkdir golang cd golang GO_VERSION=$(curl -s 'https://go.dev/VERSION?m=text' | head -n1) - GOLANG_URL="https://go.dev/dl/$(GO_VERSION).linux-amd64.tar.gz" + GOLANG_URL="https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" wget "${GOLANG_URL}" tar xzf "${GO_VERSION}.linux-amd64.tar.gz" ls -lah -- 2.52.0 From 299eea08084500e163a617156e22af84cd06167e Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:34:00 -0700 Subject: [PATCH 16/33] TEST --- ci/build.sh | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 21e103f..a642430 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -18,7 +18,7 @@ main() { GOLANG_URL="https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" wget "${GOLANG_URL}" tar xzf "${GO_VERSION}.linux-amd64.tar.gz" - ls -lah + ls -lah go # 2. Clone latest CoreDNS release cd "${TMPDIR}" @@ -55,21 +55,10 @@ main() { mv plugin.cfg.new plugin.cfg fi - ls -lah - - docker run --rm \ - --user "$(id -u):$(id -g)" \ - -v "$PWD":"/work" \ - -w "/work" \ - golang:latest ls -lah - # 6. Regenerate plugin source files # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] - docker run --rm \ - --user "$(id -u):$(id -g)" \ - -v "$PWD":"/work" \ - -w "/work" \ - golang:latest bash -c make core/plugin/zplugin.go core/dnsserver/zdirectives.go + + make core/plugin/zplugin.go core/dnsserver/zdirectives.go # 7. go mod replace plugin path to the cloned action repo # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] -- 2.52.0 From 65da0e65dc870bce3d3430816949aa3fc1fb097a Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:34:37 -0700 Subject: [PATCH 17/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index a642430..2e9b497 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -18,7 +18,7 @@ main() { GOLANG_URL="https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" wget "${GOLANG_URL}" tar xzf "${GO_VERSION}.linux-amd64.tar.gz" - ls -lah go + PATH="${PATH}:$PWD/go/bin" # 2. Clone latest CoreDNS release cd "${TMPDIR}" -- 2.52.0 From 6289427eaebe5d0d961635731c7e055d0cde5e44 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:36:49 -0700 Subject: [PATCH 18/33] TEST --- ci/build.sh | 33 ++++++++------------------------- 1 file changed, 8 insertions(+), 25 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 2e9b497..96525e1 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -1,11 +1,6 @@ #!/usr/bin/env bash set -xeuo pipefail -# Inputs expected from the workflow: -# GITHUB_REPOSITORY - owner/repo of the current action repo (provided by Actions) -# GITHUB_SHA - commit to clone/check out (provided by Actions, optional) -# GO_VERSION - optional, e.g. "1.23.3"; if unset, script will query latest. - main() { # 1. Create temp directory TMPDIR="$(mktemp -d)" @@ -55,36 +50,24 @@ main() { mv plugin.cfg.new plugin.cfg fi - # 6. Regenerate plugin source files + # 6. go mod replace plugin path to the cloned action repo + # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] + # Adjust relative path if your repo layout differs. + + go mod edit -replace=github.com/doubleu-labs/coredns-netbox-plugin-dns="${ACTION_REPO_DIR}" + + # 7. Regenerate plugin source files # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] make core/plugin/zplugin.go core/dnsserver/zdirectives.go - # 7. go mod replace plugin path to the cloned action repo - # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] - # Adjust relative path if your repo layout differs. - docker run --rm -it \ - --user "$(id -u):$(id -g)" \ - -v "$PWD":"/work" \ - -w "/work" \ - golang:latest go mod edit -replace=github.com/doubleu-labs/coredns-netbox-plugin-dns="${ACTION_REPO_DIR}" - # 8. Update Go version to the latest # Install or pick latest Go and set GOTOOLCHAIN, or rely on pre-installed toolchain in the runner. [web:17] # Here we query the latest stable from golang.org and export it for this build. - if [ -z "${GO_VERSION:-}" ]; then - GO_VERSION="$(curl -s https://go.dev/VERSION?m=text | head -n1 | sed 's/^go//')" # e.g. "1.23.3" - fi echo "Using Go version: ${GO_VERSION}" - # If you use setup-go in the workflow, this is optional; otherwise install here. - # Example (Debian-based runner): - # sudo rm -rf /usr/local/go - # curl -sL "https://go.dev/dl/go${GO_VERSION}.linux-amd64.tar.gz" | sudo tar -C /usr/local -xz - # export PATH="/usr/local/go/bin:${PATH}" - - export GOTOOLCHAIN="go${GO_VERSION}" + export GOTOOLCHAIN="${GO_VERSION}" # 9. Compile CoreDNS make coredns || make -- 2.52.0 From f3327831ea653ca49d72d84ded9ce4b19c5bc58c Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:39:46 -0700 Subject: [PATCH 19/33] TEST --- ci/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/build.sh b/ci/build.sh index 96525e1..4fb1951 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -65,6 +65,8 @@ main() { # Install or pick latest Go and set GOTOOLCHAIN, or rely on pre-installed toolchain in the runner. [web:17] # Here we query the latest stable from golang.org and export it for this build. + git diff + echo "Using Go version: ${GO_VERSION}" export GOTOOLCHAIN="${GO_VERSION}" -- 2.52.0 From 1e394962e8ff072452834f6ce65df4f64b883619 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:41:41 -0700 Subject: [PATCH 20/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 4fb1951..937503e 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -69,7 +69,7 @@ main() { echo "Using Go version: ${GO_VERSION}" - export GOTOOLCHAIN="${GO_VERSION}" + #export GOTOOLCHAIN="${GO_VERSION}" # 9. Compile CoreDNS make coredns || make -- 2.52.0 From 999d97d79afe0ad6ce342330cc42676aad6b9d0d Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:48:20 -0700 Subject: [PATCH 21/33] TEST --- ci/build.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 937503e..54d97a9 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -2,20 +2,27 @@ set -xeuo pipefail main() { - # 1. Create temp directory + GO_VERSION=$(curl -s 'https://go.dev/VERSION?m=text' | head -n1) + + # 1. + ACTION_REPO_DIR="${PWD}" + go mod edit -go=$(echo GO_VERSION | sed 's/^go//') + #mkdir "${ACTION_REPO_DIR}" + #cp -a . "${ACTION_REPO_DIR}/" + + # 2. Create temp directory TMPDIR="$(mktemp -d)" echo "Using temp dir: ${TMPDIR}" cd "${TMPDIR}" mkdir golang cd golang - GO_VERSION=$(curl -s 'https://go.dev/VERSION?m=text' | head -n1) GOLANG_URL="https://go.dev/dl/${GO_VERSION}.linux-amd64.tar.gz" wget "${GOLANG_URL}" tar xzf "${GO_VERSION}.linux-amd64.tar.gz" PATH="${PATH}:$PWD/go/bin" - # 2. Clone latest CoreDNS release + # 3. Clone latest CoreDNS release cd "${TMPDIR}" COREDNS_REPO_URL="https://github.com/coredns/coredns.git" COREDNS_DIR="${TMPDIR}/coredns" @@ -28,11 +35,6 @@ main() { git fetch --tags --depth=1 origin "${LATEST_TAG}" git checkout "${LATEST_TAG}" - # 3. Clone the GitHub Action's repo (this repo) - ACTION_REPO_DIR="${TMPDIR}/action-repo" - mkdir "${ACTION_REPO_DIR}" - cp -a . "${ACTION_REPO_DIR}/" - # 4. cd into the CoreDNS repo cd "${COREDNS_DIR}" @@ -50,6 +52,7 @@ main() { mv plugin.cfg.new plugin.cfg fi + go mod edit -go=$(echo GO_VERSION | sed 's/^go//') # 6. go mod replace plugin path to the cloned action repo # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] # Adjust relative path if your repo layout differs. -- 2.52.0 From 7d97d270d5bae0fae352fd671296d855a3cb051b Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:49:01 -0700 Subject: [PATCH 22/33] TEST --- ci/build.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 54d97a9..dfbc452 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -3,12 +3,7 @@ set -xeuo pipefail main() { GO_VERSION=$(curl -s 'https://go.dev/VERSION?m=text' | head -n1) - - # 1. ACTION_REPO_DIR="${PWD}" - go mod edit -go=$(echo GO_VERSION | sed 's/^go//') - #mkdir "${ACTION_REPO_DIR}" - #cp -a . "${ACTION_REPO_DIR}/" # 2. Create temp directory TMPDIR="$(mktemp -d)" @@ -22,6 +17,9 @@ main() { tar xzf "${GO_VERSION}.linux-amd64.tar.gz" PATH="${PATH}:$PWD/go/bin" + cd "${ACTION_REPO_DIR}" + go mod edit -go=$(echo GO_VERSION | sed 's/^go//') + # 3. Clone latest CoreDNS release cd "${TMPDIR}" COREDNS_REPO_URL="https://github.com/coredns/coredns.git" -- 2.52.0 From b87f79d4b72772644c3afc951389b66df8a7bb5f Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:49:31 -0700 Subject: [PATCH 23/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index dfbc452..8e3eed6 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -18,7 +18,7 @@ main() { PATH="${PATH}:$PWD/go/bin" cd "${ACTION_REPO_DIR}" - go mod edit -go=$(echo GO_VERSION | sed 's/^go//') + go mod edit -go "$(echo GO_VERSION | sed 's/^go//')" # 3. Clone latest CoreDNS release cd "${TMPDIR}" -- 2.52.0 From 1a899f68136acfd6c01359e14ef0a1eddc333388 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:50:05 -0700 Subject: [PATCH 24/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 8e3eed6..dd9819f 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -18,7 +18,7 @@ main() { PATH="${PATH}:$PWD/go/bin" cd "${ACTION_REPO_DIR}" - go mod edit -go "$(echo GO_VERSION | sed 's/^go//')" + go mod edit -go "$(echo "${GO_VERSION}" | sed 's/^go//')" # 3. Clone latest CoreDNS release cd "${TMPDIR}" -- 2.52.0 From 487ee9f1e251f5c3aad2d711dd100f6cd85c92b1 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:50:32 -0700 Subject: [PATCH 25/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index dd9819f..b759bca 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -50,7 +50,7 @@ main() { mv plugin.cfg.new plugin.cfg fi - go mod edit -go=$(echo GO_VERSION | sed 's/^go//') + go mod edit -go "$(echo "${GO_VERSION}" | sed 's/^go//')" # 6. go mod replace plugin path to the cloned action repo # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] # Adjust relative path if your repo layout differs. -- 2.52.0 From ce0950eeb6f6c812e84dae8551fa28b07898f3c2 Mon Sep 17 00:00:00 2001 From: restitux Date: Tue, 23 Dec 2025 23:52:41 -0700 Subject: [PATCH 26/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index b759bca..de9443a 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -60,7 +60,7 @@ main() { # 7. Regenerate plugin source files # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] - make core/plugin/zplugin.go core/dnsserver/zdirectives.go + make gen # 8. Update Go version to the latest # Install or pick latest Go and set GOTOOLCHAIN, or rely on pre-installed toolchain in the runner. [web:17] -- 2.52.0 From ab1f649d79fc3ec72549faeab9a66b2dfdadbbb5 Mon Sep 17 00:00:00 2001 From: restitux Date: Wed, 24 Dec 2025 00:08:16 -0700 Subject: [PATCH 27/33] TEST --- ci/build.sh | 42 +++++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index de9443a..17f643b 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -20,12 +20,12 @@ main() { cd "${ACTION_REPO_DIR}" go mod edit -go "$(echo "${GO_VERSION}" | sed 's/^go//')" - # 3. Clone latest CoreDNS release + # 3. Clone CoreDNS cd "${TMPDIR}" COREDNS_REPO_URL="https://github.com/coredns/coredns.git" COREDNS_DIR="${TMPDIR}/coredns" - # get latest tag (annotated or lightweight) + # 4. Checkout coredns to latest release git clone --depth=1 --filter=blob:none --tags "${COREDNS_REPO_URL}" "${COREDNS_DIR}" cd "${COREDNS_DIR}" git fetch --tags @@ -33,9 +33,6 @@ main() { git fetch --tags --depth=1 origin "${LATEST_TAG}" git checkout "${LATEST_TAG}" - # 4. cd into the CoreDNS repo - cd "${COREDNS_DIR}" - # 5. Update plugin.cfg to include netboxdns plugin # Insert netboxdns after the 'cache' plugin entry as recommended. [web:16][web:29] if ! grep -q '^netboxdns:' plugin.cfg; then @@ -50,28 +47,21 @@ main() { mv plugin.cfg.new plugin.cfg fi + # 6. Update coredns repo to latest golang version + # TODO: do we need this? I think we should actually force the plugin to use the coredns configured golang version + # this possibly only works because coredns is using the latest golang version go mod edit -go "$(echo "${GO_VERSION}" | sed 's/^go//')" - # 6. go mod replace plugin path to the cloned action repo - # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. [web:16][web:23] - # Adjust relative path if your repo layout differs. + + # 7. go mod replace plugin path to the cloned action repo + # This assumes the plugin lives at github.com/doubleu-labs/coredns-netbox-plugin-dns in your repo. go mod edit -replace=github.com/doubleu-labs/coredns-netbox-plugin-dns="${ACTION_REPO_DIR}" # 7. Regenerate plugin source files - # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. [web:20][web:26] + # CoreDNS uses go generate (via Makefile) to rebuild plugin glue code. make gen - # 8. Update Go version to the latest - # Install or pick latest Go and set GOTOOLCHAIN, or rely on pre-installed toolchain in the runner. [web:17] - # Here we query the latest stable from golang.org and export it for this build. - - git diff - - echo "Using Go version: ${GO_VERSION}" - - #export GOTOOLCHAIN="${GO_VERSION}" - # 9. Compile CoreDNS make coredns || make @@ -106,6 +96,20 @@ EOF dpkg-deb --build "${PKG_ROOT}" "${DEB_OUT}" echo "Built Debian package at: ${DEB_OUT}" + + # 12. Upload the package to Gitea Debian registry + # Gitea uses HTTP PUT with the .deb in the request body. [web:31][web:39] + DEB_REGISTRY_URL="https://git.ohea.xyz/api/packages/dns/debian/pool/trixie/main/upload" + echo "Uploading ${DEB_OUT} to ${DEB_REGISTRY_URL}" + curl \ + --fail \ + --show-error \ + --silent \ + --request PUT \ + --user "${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}" \ + --upload-file "${DEB_OUT}" \ + "${DEB_REGISTRY_URL}" + } main "$@" -- 2.52.0 From 101987240b139dd39c72fc8016e26ce61da38de8 Mon Sep 17 00:00:00 2001 From: restitux Date: Wed, 24 Dec 2025 00:13:09 -0700 Subject: [PATCH 28/33] TEST --- .gitea/workflows/build-release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitea/workflows/build-release.yml b/.gitea/workflows/build-release.yml index b926157..e69f355 100644 --- a/.gitea/workflows/build-release.yml +++ b/.gitea/workflows/build-release.yml @@ -9,4 +9,7 @@ jobs: uses: actions/checkout@v5 - name: Build + env: + CI_REGISTRY_USER: ${{ secrets.CI_REGISTRY_USER }} + CI_REGISTRY_PASSWORD: ${{ secrets.CI_REGISTRY_PASSWORD }} run: ./ci/build.sh -- 2.52.0 From 69ab6265a934f7d6c9abf36aec860076d2863ff2 Mon Sep 17 00:00:00 2001 From: restitux Date: Wed, 24 Dec 2025 00:19:12 -0700 Subject: [PATCH 29/33] TEST --- ci/build.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 17f643b..0851908 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -29,12 +29,12 @@ main() { git clone --depth=1 --filter=blob:none --tags "${COREDNS_REPO_URL}" "${COREDNS_DIR}" cd "${COREDNS_DIR}" git fetch --tags - LATEST_TAG="$(git tag --list --sort=-version:refname | head -n 1)" - git fetch --tags --depth=1 origin "${LATEST_TAG}" - git checkout "${LATEST_TAG}" + COREDNS_LATEST_VERSION="$(git tag --list --sort=-version:refname | head -n 1)" + git fetch --tags --depth=1 origin "${COREDNS_LATEST_VERSION}" + git checkout "${COREDNS_LATEST_VERSION}" # 5. Update plugin.cfg to include netboxdns plugin - # Insert netboxdns after the 'cache' plugin entry as recommended. [web:16][web:29] + # Insert netboxdns after the 'cache' plugin entry as recommended. if ! grep -q '^netboxdns:' plugin.cfg; then awk ' /^cache:/ { @@ -70,22 +70,22 @@ main() { "${STRIP_BIN}" ./coredns # 11. Create a .deb installing /usr/local/bin/coredns - # Minimal Debian package using dpkg-deb. [web:17] + # Minimal Debian package using dpkg-deb. PKG_ROOT="${TMPDIR}/pkg-root" mkdir -p "${PKG_ROOT}/DEBIAN" "${PKG_ROOT}/usr/local/bin" # Basic metadata; tweak as needed PKG_NAME="coredns-netboxdns" - PKG_VERSION="$(echo "${LATEST_TAG}" | sed 's/^v//')" + PKG_VERSION="$(echo "${COREDNS_LATEST_VERSION}" | sed 's/^v//')" PKG_ARCH="$(dpkg --print-architecture 2>/dev/null || echo amd64)" cat >"${PKG_ROOT}/DEBIAN/control" < +Maintainer: CI Description: CoreDNS with netboxdns plugin Custom CoreDNS build with netboxdns plugin compiled in. EOF @@ -98,7 +98,7 @@ EOF echo "Built Debian package at: ${DEB_OUT}" # 12. Upload the package to Gitea Debian registry - # Gitea uses HTTP PUT with the .deb in the request body. [web:31][web:39] + # Gitea uses HTTP PUT with the .deb in the request body. DEB_REGISTRY_URL="https://git.ohea.xyz/api/packages/dns/debian/pool/trixie/main/upload" echo "Uploading ${DEB_OUT} to ${DEB_REGISTRY_URL}" curl \ -- 2.52.0 From e6fb87c57417e956f7fc4779f0f909418b462b60 Mon Sep 17 00:00:00 2001 From: restitux Date: Wed, 24 Dec 2025 00:26:56 -0700 Subject: [PATCH 30/33] TEST --- .gitea/workflows/build-release.yml | 2 +- ci/build.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/build-release.yml b/.gitea/workflows/build-release.yml index e69f355..1ec07a8 100644 --- a/.gitea/workflows/build-release.yml +++ b/.gitea/workflows/build-release.yml @@ -1,5 +1,5 @@ name: Build Coredns with netboxdns plugin -on: [push] +on: [workflow_dispatch] jobs: build: diff --git a/ci/build.sh b/ci/build.sh index 0851908..b7853a5 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -2,8 +2,14 @@ set -xeuo pipefail main() { + # Location to persist build metadata between runs (use Actions cache on this). [web:51][web:52] + BUILD_STATE_DIR="${BUILD_STATE_DIR:-${GITHUB_WORKSPACE:-.}/.build-state}" + mkdir -p "${BUILD_STATE_DIR}" + META_FILE="${BUILD_STATE_DIR}/coredns-netboxdns.meta" + GO_VERSION=$(curl -s 'https://go.dev/VERSION?m=text' | head -n1) ACTION_REPO_DIR="${PWD}" + ACTION_COMMIT="$(git rev-parse HEAD)" # 2. Create temp directory TMPDIR="$(mktemp -d)" @@ -33,6 +39,22 @@ main() { git fetch --tags --depth=1 origin "${COREDNS_LATEST_VERSION}" git checkout "${COREDNS_LATEST_VERSION}" + echo "CoreDNS version (tag): ${LATEST_TAG}" + echo "Action repo commit : ${ACTION_COMMIT}" + + # 4b. Skip build if same CoreDNS version and same action repo commit as last time. # NEW + if [ -f "${META_FILE}" ]; then + LAST_COREDNS_TAG="$(sed -n 's/^COREDNS_TAG=//p' "${META_FILE}")" + LAST_ACTION_COMMIT="$(sed -n 's/^ACTION_COMMIT=//p' "${META_FILE}")" + + if [ "${LAST_COREDNS_TAG}" = "${COREDNS_LATEST_VERSION}" ] && + [ "${LAST_ACTION_COMMIT}" = "${ACTION_COMMIT}" ]; then + echo "No changes in CoreDNS version or action repo commit since last build." + echo "Skipping build and upload." + exit 0 + fi + fi + # 5. Update plugin.cfg to include netboxdns plugin # Insert netboxdns after the 'cache' plugin entry as recommended. if ! grep -q '^netboxdns:' plugin.cfg; then @@ -110,6 +132,14 @@ EOF --upload-file "${DEB_OUT}" \ "${DEB_REGISTRY_URL}" + # 13. Store metadata for next run (so it can be used with actions/cache). # NEW + cat >"${META_FILE}" < Date: Wed, 24 Dec 2025 00:29:52 -0700 Subject: [PATCH 31/33] TEST --- .gitea/workflows/build-release.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.gitea/workflows/build-release.yml b/.gitea/workflows/build-release.yml index 1ec07a8..46f64b6 100644 --- a/.gitea/workflows/build-release.yml +++ b/.gitea/workflows/build-release.yml @@ -8,8 +8,22 @@ jobs: - name: Checkout uses: actions/checkout@v5 + - name: Restore build state + uses: actions/cache/restore@v4 + with: + path: .build-state + key: coredns-netboxdns-${{ runner.os }} + - name: Build env: CI_REGISTRY_USER: ${{ secrets.CI_REGISTRY_USER }} CI_REGISTRY_PASSWORD: ${{ secrets.CI_REGISTRY_PASSWORD }} run: ./ci/build.sh + + - name: Save build metadata + uses: actions/cache/save@v4 + with: + path: .build-state + key: coredns-netboxdns-${{ runner.os }} + + -- 2.52.0 From 4bd2de747db21622488442025b32490b8ffd3111 Mon Sep 17 00:00:00 2001 From: restitux Date: Wed, 24 Dec 2025 00:30:48 -0700 Subject: [PATCH 32/33] TEST --- .gitea/workflows/build-release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitea/workflows/build-release.yml b/.gitea/workflows/build-release.yml index 46f64b6..5e933be 100644 --- a/.gitea/workflows/build-release.yml +++ b/.gitea/workflows/build-release.yml @@ -1,5 +1,5 @@ name: Build Coredns with netboxdns plugin -on: [workflow_dispatch] +on: [push] jobs: build: -- 2.52.0 From 4d22c55983b43f74d359e859d210039e890a73a9 Mon Sep 17 00:00:00 2001 From: restitux Date: Wed, 24 Dec 2025 00:32:40 -0700 Subject: [PATCH 33/33] TEST --- ci/build.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index b7853a5..2fba7b3 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -39,7 +39,7 @@ main() { git fetch --tags --depth=1 origin "${COREDNS_LATEST_VERSION}" git checkout "${COREDNS_LATEST_VERSION}" - echo "CoreDNS version (tag): ${LATEST_TAG}" + echo "CoreDNS version (tag): ${COREDNS_LATEST_VERSION}" echo "Action repo commit : ${ACTION_COMMIT}" # 4b. Skip build if same CoreDNS version and same action repo commit as last time. # NEW -- 2.52.0