diff --git a/.github/workflows/publish_to_dockerhub.yml b/.github/workflows/publish_to_dockerhub.yml index 09691d4d4..f5acbc558 100644 --- a/.github/workflows/publish_to_dockerhub.yml +++ b/.github/workflows/publish_to_dockerhub.yml @@ -105,15 +105,23 @@ jobs: - name: Update Go modules run: go mod download - - name: Build images + - 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 released images to registry + - 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 diff --git a/Makefile b/Makefile index e6bcce52f..069eb5e17 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 check-version clean-cluster push-tag push-to-registry \ +.PHONY: build deps image image-latest image-push image-push-latest check-version clean-cluster push-tag push-to-registry \ run run-cluster test vet lint fmt cover build: deps @@ -50,14 +50,20 @@ postinst: install image: deps @echo "=> Building image" - @docker build -t $(IMAGE_REPO):latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . @docker build -t $(IMAGE_REPO):$(VERSION) --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . +image-latest: deps + @echo "=> Building image with 'latest' tag" + @docker build -t $(IMAGE_REPO):latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) . + image-push: @echo "=> Publish image" - @docker push $(IMAGE_REPO):latest @docker push $(IMAGE_REPO):$(VERSION) +image-push-latest: + @echo "=> Publish image with 'latest' tag" + @docker push $(IMAGE_REPO):latest + check-version: git fetch && (! git rev-list ${VERSION})