diff --git a/.github/workflows/publish_to_dockerhub.yml b/.github/workflows/publish_to_dockerhub.yml index 741d9acff3..b1a5812e06 100644 --- a/.github/workflows/publish_to_dockerhub.yml +++ b/.github/workflows/publish_to_dockerhub.yml @@ -15,11 +15,11 @@ on: workflow_dispatch: inputs: ref: - description: 'Ref to build Docker image [default: latest master; examples: v0.92.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]' + description: 'Ref to build Docker images for Ubuntu and Windows Server Core [default: latest master; examples: v0.92.0, 0a4ff9d3e4a9ab432fd5812eb18c98e03b5a7432]' required: false default: '' push_image: - description: 'Push image to DockerHub [default: false; examples: true, false]' + description: 'Push images to DockerHub [default: false; examples: true, false]' required: false default: 'false' @@ -29,8 +29,8 @@ env: # A workflow run. jobs: - test: - name: Run tests before publishing + tests_ubuntu: + name: Run Ubuntu-based tests before publishing runs-on: ubuntu-20.04 steps: @@ -70,10 +70,10 @@ jobs: - name: Run tests run: make test - publish: + publish_ubuntu: # Ensure test job passes before pushing image. - needs: test - name: Publish image to DockerHub + needs: test_ubuntu + name: Publish Ubuntu-based image to DockerHub runs-on: ubuntu-20.04 steps: - name: Checkout (manual run) @@ -91,6 +91,52 @@ jobs: # Allows to fetch all history for all branches and tags. Need this for proper versioning. fetch-depth: 0 + - name: Build image + run: make image + + - name: Build image with 'latest' tag + if: ${{ github.event_name == 'release' && github.event.release.target_commitish == 'master' }} + run: make image-latest + + - name: Login to DockerHub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + - name: Push image to registry + if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }} + run: make image-push + + - name: Push image with 'latest' tag to registry + if: ${{ github.event_name == 'release' && github.event.release.target_commitish == 'master' }} + run: make image-push-latest + + tests_wsc: + name: Run WindowsServerCore-based tests before publishing + runs-on: windows-2022 + + steps: + - name: Checkout (manual run) + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.ref }} + # Allows to fetch all history for all branches and tags. Need this for proper versioning. + fetch-depth: 0 + + - name: Checkout (automatical run) + if: ${{ github.event_name != 'workflow_dispatch' }} + uses: actions/checkout@v2 + with: + # Allows to fetch all history for all branches and tags. Need this for proper versioning. + fetch-depth: 0 + + - name: Sync VM submodule + run: | + git submodule sync + git submodule update --init + - name: Set up Go uses: actions/setup-go@v2 with: @@ -105,12 +151,34 @@ jobs: - name: Update Go modules run: go mod download -json - - name: Build image - run: make image + - name: Run tests + run: make test + publish_wsc: + # Ensure test job passes before pushing image. + # TODO: currently test_wsc job is failing, so we have `always()` condition. + # After #2269 and #2268 this condition should be removed. + if: ${{ always() }} + needs: test_wsc + name: Publish WindowsServerCore-based image to DockerHub + runs-on: windows-2022 + steps: + - name: Checkout (manual run) + if: ${{ github.event_name == 'workflow_dispatch' }} + uses: actions/checkout@v2 + with: + ref: ${{ github.event.inputs.ref }} + # Allows to fetch all history for all branches and tags. Need this for proper versioning. + fetch-depth: 0 - - name: Build image with 'latest' tag - if: ${{ github.event_name == 'release' && github.event.release.target_commitish == 'master' }} - run: make image-latest + - name: Checkout (automatical run) + if: ${{ github.event_name != 'workflow_dispatch' }} + uses: actions/checkout@v2 + with: + # Allows to fetch all history for all branches and tags. Need this for proper versioning. + fetch-depth: 0 + + - name: Build image + run: make image-wsc - name: Login to DockerHub uses: docker/login-action@v1 @@ -120,8 +188,4 @@ jobs: - name: Push image to registry if: ${{ github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && github.event.inputs.push_image == 'true') }} - run: make image-push - - - name: Push image with 'latest' tag to registry - if: ${{ github.event_name == 'release' && github.event.release.target_commitish == 'master' }} - run: make image-push-latest + run: make image-wsc-push diff --git a/Makefile b/Makefile index 0ca1116a74..2099b5248b 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,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 deps image image-wsc image-latest image-push image-push-latest check-version clean-cluster push-tag \ +.PHONY: build deps image image-wsc image-latest image-push image-wsc-push image-push-latest check-version clean-cluster push-tag \ test vet lint fmt cover build: deps @@ -61,11 +61,15 @@ image-latest: deps @docker build -t $(IMAGE_REPO):latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . image-push: - @echo "=> Publish image" + @echo "=> Publish image for Ubuntu" @docker push $(IMAGE_REPO):$(VERSION) +image-wsc-push: + @echo "=> Publish image for Windows Server Core" + @docker push $(IMAGE_REPO):$(VERSION)_WindowsServerCore + image-push-latest: - @echo "=> Publish image with 'latest' tag" + @echo "=> Publish image for Ubuntu with 'latest' tag" @docker push $(IMAGE_REPO):latest check-version: