If the consumer makes a change which can break the contract test can only be identified if producer is also build but if we don't build the producer the wrong consumer will be released to production.
Is there an approach which can be followed to overcome these type of scenarios.
Yes, there is definitely an approach! We go into length about this on our article how to build an effective Pact pipeline.
Some of the key tips described in the article:
can-i-deploy
to prevent consumers/providers releasing a change that will break the integration