Apart from driving and slogging it by bus, the best way will be by train.
The overnight Sud Expresso - Lisbon to Paris leaves Coimbra at 18:26. It arrives in San Sebastian the next morning at 6:34.
If one gets the 16:52 from Porto Arriving Coimbra at 17:56 this will connect nicely.
You can find more info and nuggets at:
www.cp.pt