goreleaser-release-with-msi.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
  4. REPO_ROOT="$(cd "${SCRIPT_DIR}/../.." && pwd)"
  5. TIMEOUT="${GORELEASER_TIMEOUT:-60m}"
  6. ZIP_PATH="${REPO_ROOT}/dist/OliveTin-windows-amd64.zip"
  7. if [[ -z "${VERSION:-}" ]]; then
  8. echo "VERSION is required to build the Windows MSI" >&2
  9. exit 1
  10. fi
  11. wait_for_stable_file() {
  12. local file="${1}"
  13. local last_size=-1
  14. local stable_count=0
  15. while [[ "${stable_count}" -lt 2 ]]; do
  16. if [[ ! -f "${file}" ]]; then
  17. stable_count=0
  18. last_size=-1
  19. sleep 1
  20. continue
  21. fi
  22. local size
  23. size="$(stat -c%s "${file}")"
  24. if [[ "${size}" -gt 0 && "${size}" == "${last_size}" ]]; then
  25. stable_count=$((stable_count + 1))
  26. else
  27. stable_count=0
  28. fi
  29. last_size="${size}"
  30. sleep 1
  31. done
  32. }
  33. goreleaser release --clean --timeout "${TIMEOUT}" "$@" &
  34. goreleaser_pid=$!
  35. while [[ ! -f "${ZIP_PATH}" ]]; do
  36. if ! kill -0 "${goreleaser_pid}" 2>/dev/null; then
  37. wait "${goreleaser_pid}"
  38. echo "GoReleaser exited before Windows archive was created: ${ZIP_PATH}" >&2
  39. exit 1
  40. fi
  41. sleep 1
  42. done
  43. wait_for_stable_file "${ZIP_PATH}"
  44. "${SCRIPT_DIR}/build-msi.sh"
  45. wait "${goreleaser_pid}"