Makefile 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. # switchbot-mqtt - MQTT client controlling SwitchBot button & curtain automators,
  2. # compatible with home-assistant.io's MQTT Switch & Cover platform
  3. #
  4. # Copyright (C) 2020 Fabian Peter Hammerle <fabian@hammerle.me>
  5. #
  6. # This program is free software: you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation, either version 3 of the License, or
  9. # any later version.
  10. #
  11. # This program is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <https://www.gnu.org/licenses/>.
  18. IMAGE_NAME = docker.io/fphammerle/switchbot-mqtt
  19. PROJECT_VERSION = $(shell git describe --match=v* --dirty | sed -e 's/^v//')
  20. ARCH = $(shell arch)
  21. # architecture[arm_variant]
  22. # https://github.com/opencontainers/image-spec/blob/v1.0.1/image-index.md#image-index-property-descriptions
  23. IMAGE_TAG_ARCH_aarch64 = arm64
  24. IMAGE_TAG_ARCH_armv6l = armv6
  25. IMAGE_TAG_ARCH_armv7l = armv7
  26. IMAGE_TAG_ARCH_x86_64 = amd64
  27. IMAGE_TAG_ARCH = ${IMAGE_TAG_ARCH_${ARCH}}
  28. IMAGE_TAG = ${PROJECT_VERSION}-${IMAGE_TAG_ARCH}
  29. .PHONY: docker-build podman-build docker-push
  30. docker-build:
  31. sudo docker build --tag="${IMAGE_NAME}:${IMAGE_TAG}" .
  32. podman-build:
  33. # --format=oci (default) not fully supported by hub.docker.com
  34. # https://github.com/docker/hub-feedback/issues/1871#issuecomment-748924149
  35. podman build --format=docker --tag="${IMAGE_NAME}:${IMAGE_TAG}" .
  36. docker-push: docker-build
  37. sudo docker push "${IMAGE_NAME}:${IMAGE_TAG}"
  38. @echo git tag --sign --message '$(shell sudo docker image inspect --format '{{join .RepoDigests "\n"}}' "${IMAGE_NAME}:${IMAGE_TAG}")' docker/${IMAGE_TAG} $(shell git rev-parse HEAD)