From f8fd30239eb7b04795f922325346054f47e733fa Mon Sep 17 00:00:00 2001 From: wangyizhi1 Date: Mon, 9 Oct 2023 15:50:44 +0800 Subject: [PATCH] feat: update ci Signed-off-by: wangyizhi1 --- .github/workflows/push-images.yml | 31 +++++++++++++++++++++++++++++++ Makefile | 9 +++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/push-images.yml diff --git a/.github/workflows/push-images.yml b/.github/workflows/push-images.yml new file mode 100644 index 00000000000..a33d3d9ce68 --- /dev/null +++ b/.github/workflows/push-images.yml @@ -0,0 +1,31 @@ +# This workflow will build a golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Go + +on: + push: + tags: + - "v*.*.*" + +jobs: + push-images: + runs-on: ubuntu-latest + permissions: + packages: write + contents: read + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Set up qemu + uses: docker/setup-qemu-action@v2 + - name: Login registry + run: | + echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + - name: Push images + env: + ON_PLUGINS: true + run: | + make upload-images \ No newline at end of file diff --git a/Makefile b/Makefile index 952ecb4772f..8f89f58ed2a 100644 --- a/Makefile +++ b/Makefile @@ -19,11 +19,16 @@ all: coredns coredns: $(CHECKS) CGO_ENABLED=$(CGO_ENABLED) GOOS=${GOOS} GOARCH=${GOARCH} go build $(BUILDOPTS) -ldflags="-s -w -X github.com/coredns/coredns/coremain.GitCommit=$(GITCOMMIT)" -o $(BINARY) -.PHONY: image -image: coredns +.PHONY: images +images: coredns set -e;\ docker buildx build --output=type=docker --platform ${GOOS}/${GOARCH} --tag ${REGISTRY}/coredns:v${VERSION} . +.PHONY: push-images +upload-images: images + @echo "push images to $(REGISTRY)" + docker push ${REGISTRY}/coredns:${VERSION} + .PHONY: check check: core/plugin/zplugin.go core/dnsserver/zdirectives.go