Renew your passport first. A passport with less than 6 months of validity blocks the residence-permit renewal, so you cannot complete the next step on a near-expired passport. In the meantime you can apply for a temporary stay-and-exit document (the Foreigner's Exit-Entry Permit) with a note from your embassy, but the real fix is a new passport.
Nationwide (all cities)
Passport validity is a hard gate
The passport validity is a hard gate. The National Immigration Administration's official answers make this explicit: when the passport has less than half a year of validity left, the residence-permit renewal cannot be processed normally — you must first apply for a new passport at your country's embassy or consulate in China, and only then apply for the extension.
The bridging measure
There is a bridging measure while you wait for the new passport. If you are in China without a valid passport or other travel document and cannot get one from your embassy in time, you can submit a note from your embassy or a temporary identity document that substitutes for the passport, and apply to the exit-entry authority for a short-term stay-and-exit document (the Foreigner's Exit-Entry Permit).
The sequence
So the sequence is: start the passport renewal immediately (it takes time), use the Exit-Entry Permit to bridge the gap if your stay is running out, and complete the residence change once you hold the new passport.