docker.bash 974 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env bash
  2. function docker_image_name() {
  3. _export_versions
  4. echo browsh/browsh:v"$BROWSH_VERSION"
  5. }
  6. function docker_build() {
  7. local og_xpi && og_xpi=$(versioned_xpi_file)
  8. [ ! -f "$og_xpi" ] && _panic "Can't find latest webextension build: $og_xpi"
  9. [ ! -f "$XPI_PATH" ] && _panic "Can't find bundleable browsh.xpi: $XPI_PATH"
  10. if [ "$(_md5 "$og_xpi")" != "$(_md5 "$XPI_PATH")" ]; then
  11. _panic "XPI file's MD5 does not match original XPI file's MD5"
  12. fi
  13. docker build -t "$(docker_image_name)" .
  14. }
  15. function is_docker_logged_in() {
  16. docker system info | grep -E 'Username|Registry'
  17. }
  18. function docker_login() {
  19. docker login docker.io \
  20. -u tombh \
  21. -p "$DOCKER_ACCESS_TOKEN"
  22. }
  23. function docker_tag_latest() {
  24. local latest=browsh/browsh:latest
  25. docker tag "$(docker_image_name)" "$latest"
  26. docker push "$latest"
  27. }
  28. function docker_release() {
  29. ! is_docker_logged_in && try_docker_login
  30. docker_build
  31. docker push "$(docker_image_name)"
  32. docker_tag_latest
  33. }