Skip to content

Remove unnecessary "./" and print version for testing #4

Remove unnecessary "./" and print version for testing

Remove unnecessary "./" and print version for testing #4

Workflow file for this run

name: Build Binary
on:
push:
# Enable after development is completed.
# 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:
# You can test your matrix by printing the current Go version
- name: Display Go version
run: go version
# Fetch the coredns repository first
- name: Fetch the coredns repository at a tag
uses: actions/checkout@v4
with:
repository: 'coredns/coredns'
ref: 'v1.11.1'
# Fetch this repository first
- name: Fetch the present repository
uses: actions/checkout@v4
with:
path: './plugin/blocker'
- name: Move plugin.cfg to the top level
run: |
ls -lsh plugin.cfg
head plugin.cfg
mv ./plugin/blocker/plugin.cfg ./plugin.cfg
ls -lsh plugin.cfg
head plugin.cfg
- name: Test everything works well
run: |
ls -lsh .
ls -lsh ./plugin
ls -lsh ./plugin/blocker/
# 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
./$OUTPUT_FILE_NAME -version
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 }}