Step 1: are you UK tax resident?
Residence is worked out each tax year (6 April to 5 April) under the Statutory Residence Test. You are automatically UK resident if, for example, you spend 183 days or more in the UK in the tax year, or your only home is in the UK for at least 91 days in a row and you stay there for at least 30 days of the year.
When you arrive part way through a year, split-year treatment can mean you are only taxed as a UK resident from your arrival date. Your status can change from year to year, so it is worth checking every year.