How to release object when being dragged by mouse?

I am working on a block game where you can drag blocks around. I am using the OnMouseDrag event. I don’t know how to have the block drop when in position if the mouse button is not released. How do I get the object to release (drop) if it is being dragged by the mouse button?

void OnMouseDown()

    {

        screenPoint = Camera.main.WorldToScreenPoint(gameObject.transform.position);

        

        offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, gameObject.transform.position.y, screenPoint.z));

    }

    

    void OnMouseDrag()

    {

        Vector3 curScreenPoint = new Vector3(Input.mousePosition.x, gameObject.transform.position.y, screenPoint.z);

        

        Vector3 curPosition = Camera.main.ScreenToWorldPoint(curScreenPoint)+offset;

        transform.position = curPosition;

        

    }

Just let Unity call your OnMouseDrag when it wants to. If you want to change what happens inside this function, just have a boolean variable that is set to true in OnMouseDown() and set to false when your logic decides the block is in the right place.