diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 016de7845..003d14989 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,10 +66,39 @@ jobs: build_image: needs: build_cli name: Build Docker image - runs-on: ${{matrix.os}} - strategy: - matrix: - os: [ubuntu-20.04, windows-2022] + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.ref }} + fetch-depth: 0 + + - name: Set up QEMU + if: runner.os != 'Windows' + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Set vars + id: setvars + run: make gh-docker-vars + + - name: Build and push + uses: docker/build-push-action@v3 + with: + push: false + platforms: linux/amd64,linux/arm64 + build-args: | + REPO=${{ steps.setvars.outputs.repo }} + VERSION=${{ steps.setvars.outputs.version }} + tags: ${{ steps.setvars.outputs.repo }}:${{ steps.setvars.outputs.version }}${{ steps.setvars.outputs.suffix }} + + build_image_wsc: + needs: build_cli + name: Build Docker image (Windows Server Core) + runs-on: windows-2022 steps: - uses: actions/checkout@v2 @@ -100,6 +129,9 @@ jobs: ref: ${{ github.event.inputs.ref }} fetch-depth: 0 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + # For proper `deps` make target execution. - name: Set up Go uses: actions/setup-go@v2 diff --git a/Makefile b/Makefile index dd8bb62ff..3ad6298c0 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ IMAGE_REPO=nspccdev/neo-go # All of the targets are phony here because we don't really use make dependency # tracking for files .PHONY: build $(BINARY) deps image docker/$(BINARY) image-latest image-push image-push-latest clean-cluster \ - test vet lint fmt cover + test vet lint fmt cover version gh-docker-vars build: deps @echo "=> Building binary" @@ -92,6 +92,15 @@ deps: @CGO_ENABLED=0 \ go mod tidy -v +version: + @echo $(VERSION) + +gh-docker-vars: + @echo "::set-output name=file::$(D_FILE)" + @echo "::set-output name=version::$(VERSION)" + @echo "::set-output name=repo::$(REPO)" + @echo "::set-output name=suffix::$(IMAGE_SUFFIX)" + test: @go test ./... -cover