Since the transportation between cities is included in our package, and there are no direct flights from San Sebastian to Porto or Lisbon, I believe we should start the trip in San Sebastian, and then head to Barcelona. In this case, there are many flights a day from Barcelona to Porto.
San Sebastian → (flight) → Barcelona → (flight) → Porto → (train) → Lisbon → (train or bus) → Lagos