-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from icyflame/build-binary-coredns
Build coredns binary for multiple architectures and OS
- Loading branch information
Showing
2 changed files
with
84 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
name: Build Binary | ||
|
||
on: | ||
push: | ||
tags: | ||
- v* | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
strategy: | ||
matrix: | ||
go-version: [ '1.22.5' ] | ||
os-flavor: [ 'linux' ] | ||
architecture: [ 'amd64', 'arm', 'arm64' ] | ||
|
||
steps: | ||
# Fetch the coredns repository first. This is expanded at ./ | ||
- name: Fetch the coredns repository at a tag | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: 'coredns/coredns' | ||
ref: 'v1.11.1' | ||
# Fetch this repository next. It is put inside ./plugin/blocker/ | ||
- name: Fetch the present repository | ||
uses: actions/checkout@v4 | ||
with: | ||
path: './plugin/blocker' | ||
- name: Move plugin.cfg from blocker plugin to the top level (coredns level) | ||
run: | | ||
mv ./plugin/blocker/plugin.cfg ./plugin.cfg | ||
# Caching is enabled by default when using setup-go | ||
- name: Setup Go ${{ matrix.go-version }} | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: ${{ matrix.go-version }} | ||
- name: Build binary of CoreDNS | ||
id: build-binary | ||
run: | | ||
echo "Ref: ${{ github.ref }}; Commit: $GITHUB_SHA" | ||
OUTPUT_FILE_NAME="coredns-${{ matrix.os-flavor }}-${{ matrix.architecture }}" | ||
go generate | ||
GOOS=${{ matrix.os-flavor }} GOARCH=${{ matrix.architecture }} CGO_ENABLED=0 \ | ||
go build \ | ||
-ldflags="-s -w -X \"github.com/coredns/coredns/coremain.GitCommit=Blocker plugin ${{ github.ref }} $GITHUB_SHA\"" \ | ||
-o $OUTPUT_FILE_NAME | ||
sha256sum $OUTPUT_FILE_NAME > $OUTPUT_FILE_NAME.checksum | ||
file $OUTPUT_FILE_NAME | ||
file $OUTPUT_FILE_NAME.checksum | ||
chmod 755 $OUTPUT_FILE_NAME | ||
chmod 644 $OUTPUT_FILE_NAME.checksum | ||
tar --create --gzip --file $OUTPUT_FILE_NAME.tar.gz $OUTPUT_FILE_NAME $OUTPUT_FILE_NAME.checksum | ||
ls -lsh . | ||
{ | ||
echo 'OUTPUT_FILES<<EOF' | ||
echo $OUTPUT_FILE_NAME.tar.gz | ||
echo EOF | ||
} >> "$GITHUB_OUTPUT" | ||
- name: Upload binaries if a tag was pushed | ||
uses: softprops/action-gh-release@v2 | ||
if: startsWith(github.ref, 'refs/tags/') | ||
with: | ||
files: ${{ steps.build-binary.outputs.OUTPUT_FILES }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# This file defines the order in which plugins are executed for an incoming request. | ||
# The order of plugins in the Corefile is immaterial. | ||
# Reference: https://coredns.io/2017/06/08/how-queries-are-processed-in-coredns/ | ||
# Order of plugin execution is from top to bottom. | ||
metadata:metadata | ||
prometheus:metrics | ||
log:log | ||
any:any | ||
blocker:blocker | ||
forward:forward |