Becoming a Lawful Permanent Resident mid-year tax implications

Hello,

Say I receive an immigrant visa abroad at a US embassy, say in February, then I sell my house (my only residence I have lived in for 25 years) and then I move to the US say in July of the same year.

I understand I only become a lawful permanent resident on the day I enter the US, right?

Since I'll be a resident for tax purposes for the remainder of the year (July to December), I will need to file a tax return.

Question: Will I be taxed for the sale of my home in the foreign country before I entered the US and became a permanent resident?