#!/bin/bash

trap 'rm -f third-party-licenses.copy.md' EXIT

go install github.com/google/go-licenses@latest
go-licenses report ./... --template .github/licenses.tmpl > third-party-licenses.copy.md || echo "Ignore warnings"
# if not diff -s then exit 1

if ! diff -s third-party-licenses.copy.md third-party-licenses.md; then
  echo "License check failed. Please update the license file."
  exit 1
fi
