Outbound:
You need to complete an online Health Control Form prior to travel, here:
https://www.spth.gob.es/
You then need to present proof of vaccination upon arrival. Spain accepts the UK's Covid pass (via the 'NHS' app, NOT the 'NHS Covid-19' one).
Return:
Spain is currently on the UK's 'Amber' list. Assuming that remains unchanged, you need to take a Covid test in the three days prior to travelling. (A lateral flow test will suffice. You don't need to take a PCR one).
You also need to book a Covid test in the UK, to be taken within two days of your arrival. (
https://www.gov.uk/find-travel-test-provider ).
You further need to complete an online passenger locator form prior to travel:
https://provide-journey-contact-details.homeoffice.gov.uk/passengerLocatorFormUserAccountHolderQuestion
The information above is sourced from here
https://www.gov.uk/foreign-travel-advice/spain/entry-requirements
and here
https://www.gov.uk/guidance/red-amber-and-green-list-rules-for-entering-england
and assumes that you'll be travelling to England. (The rules might be slightly different for other parts of the UK).