I'm writing a paper on a side project with a friend, should I involve my supervisor? Some months ago I was contacted by a friend who works in my scientific field, regarding a collaboration project (we're both postdocs). We exchanged some emails and considerations. He provided me the dataset, and I developed a simple program able to make some interesting scientific discoveries (at least, from my understanding).

We've not given too much importance to this project, but now it turns out that it could lead to a scientific paper to submit to a good journal.

Even if I dedicated to this side project a small amount of time (~3 hours / week), it surely took away some time from my main project, which is much more important.

Now in the writing phase, I wondering if I should tell my supervisor about this project and this paper.
On one hand, I'm worried that he might not like that I dedicated some working time to it instead of my main project... on the other side, I think he would be happy to collaborate in writing this paper with me and gain a new journal publication.

What do you think I should do?

What do you think my supervisor would say about this side project and its paper?
I recommend that you should talk with the supervisor about side projects. Perhaps revealing the nature of a project at once is not a good idea if the relation with the supervisor is not so close. You can start for example telling your supervisor that you are/will be collaborating with a friend on a project and see the reaction and the comments, and after a few weeks you can expose the whole project and paper to the supervisor. I don't think you have invested such a long time in your project, 3h/week is a small amount of time, so you didn't took much effort from your principal project, you have nothing to worry about.