This commit is contained in:
+23
-19
@@ -20,12 +20,12 @@ main() {
|
|||||||
cd "${ACTION_REPO_DIR}"
|
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
|
# 3. Clone CoreDNS
|
||||||
cd "${TMPDIR}"
|
cd "${TMPDIR}"
|
||||||
COREDNS_REPO_URL="https://github.com/coredns/coredns.git"
|
COREDNS_REPO_URL="https://github.com/coredns/coredns.git"
|
||||||
COREDNS_DIR="${TMPDIR}/coredns"
|
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}"
|
git clone --depth=1 --filter=blob:none --tags "${COREDNS_REPO_URL}" "${COREDNS_DIR}"
|
||||||
cd "${COREDNS_DIR}"
|
cd "${COREDNS_DIR}"
|
||||||
git fetch --tags
|
git fetch --tags
|
||||||
@@ -33,9 +33,6 @@ main() {
|
|||||||
git fetch --tags --depth=1 origin "${LATEST_TAG}"
|
git fetch --tags --depth=1 origin "${LATEST_TAG}"
|
||||||
git checkout "${LATEST_TAG}"
|
git checkout "${LATEST_TAG}"
|
||||||
|
|
||||||
# 4. cd into the CoreDNS repo
|
|
||||||
cd "${COREDNS_DIR}"
|
|
||||||
|
|
||||||
# 5. Update plugin.cfg to include netboxdns plugin
|
# 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. [web:16][web:29]
|
||||||
if ! grep -q '^netboxdns:' plugin.cfg; then
|
if ! grep -q '^netboxdns:' plugin.cfg; then
|
||||||
@@ -50,28 +47,21 @@ main() {
|
|||||||
mv plugin.cfg.new plugin.cfg
|
mv plugin.cfg.new plugin.cfg
|
||||||
fi
|
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//')"
|
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]
|
# 7. go mod replace plugin path to the cloned action repo
|
||||||
# Adjust relative path if your repo layout differs.
|
# 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}"
|
go mod edit -replace=github.com/doubleu-labs/coredns-netbox-plugin-dns="${ACTION_REPO_DIR}"
|
||||||
|
|
||||||
# 7. Regenerate plugin source files
|
# 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
|
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
|
# 9. Compile CoreDNS
|
||||||
make coredns || make
|
make coredns || make
|
||||||
|
|
||||||
@@ -106,6 +96,20 @@ EOF
|
|||||||
dpkg-deb --build "${PKG_ROOT}" "${DEB_OUT}"
|
dpkg-deb --build "${PKG_ROOT}" "${DEB_OUT}"
|
||||||
|
|
||||||
echo "Built Debian package at: ${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 "$@"
|
main "$@"
|
||||||
|
|||||||
Reference in New Issue
Block a user