What worked for me was publishing only electronically.
I wrote three tech books that way. One was successful, the other two sold a little but weren’t worth my time in.
No expense other than the ISBN which was cheap. I sold a few hundred copies of the more popular one at $29.95 on my website and when that dropped off I put it on Amazon for the minimum price. It sold and still sells dribbles all these many years later— every now and then Amazon sends me a couple of dollars.
But I found books too much work for the payback. Yes, I made a few thousand dollars but it took me almost a month to write. It was okay, but I did better with articles, so I stayed with that.