They are two separate procedures at two different authorities, each with its own 30-day deadline. Official texts do not prescribe a fixed order, but a residence permit extension needs your work permit proof, so the work permit must stay valid.
Nationwide (all cities)
Two separate documents
Article 41 of the Exit-Entry Administration Law requires both a work permit and a work-type residence document to work in China. They are issued by different authorities — the work permit by the labour or foreign-expert department, the residence document by the public security exit-entry administration — and one does not produce the other.
Two separate deadlines
Each has its own deadline. For the residence document, Article 32 requires an application at least 30 days before expiry to the exit-entry administration in your place of residence. For the work permit, the official Guide to Working and Living in China for Foreign Business People (2025 edition) says the employer must apply for extension to the local work permit authority 30 days before the work permit expires.
No prescribed order
No official text prescribes a fixed order for the two. But a residence permit extension must be filed with documents related to your purpose of application, and for a work-type permit that means your current work permit proof (NIA service guide). In practice your work permit therefore has to remain valid across the residence period you are applying for.
Local windows may open earlier
Local handling windows can open earlier. Tianjin's handling guide for foreign work permits requires extension applications to be filed 30 to 90 days before the permit expires, and the system stops accepting them with less than 30 days left. Check the work permit authority in your own city for its exact window.