Implies that OP is correct. In order to penalizing yourself you need to do something you consider a punishment. In this case donating to charity...
Fortunately it isn't working because as others pointed out, "penalize himself" and "donate to charity" concepts aren't directly tied together. Where the donation actually goes is immaterial, so it's not possible to argue that "punish himself" implies "donate to charity" is punishment.
mistake > punish himself > donate to charity to punish himself
Donating to charity as a method to achieve the punishment goal is precisely material in this case.
GP is asking if this method, which contains both a gain and loss, actually results in a punishment with an intended loss.
But to make it worthwhile (aka the reward part of the punishment), the donations are directed to charity since they need to go somewhere. So that's a small reward built into the punishment.
When I play a game with my buddies, I try to win, but even if I lose I still have a good time.
This is a very similar concept. Also, don't assume that this is the only money he gives. Games are fun.
Incidentally, I somewhat envy people who are capable to pull such strategy off. It requires some amount of suspension of disbelief, forgetting for a moment that you're the game master and playing the game by the book way past the point it's become uncomfortable. I don't have that. I tried many times, but my mind just refuses to participate in self-trickery.
That doesn't make sense. Penalties aren't fun. Building software isn't a game (generally).
And there sure seems like there's a real possibility of wasteful behavior, e.g. someone 'spamming' the build system to effect a large overall donation.
I would go one step further and pick an amount that I want to donate and then each fail action moves a unit of money from the "good" to "bad" bucket. ie start with $100 and each failed build puts $1 into the Big Endian / Kodos / Republican and each successful build the dollar goes into the Little Endian / Krang / Democrat charity bucket.
As a programmer I can sympathize with wanting to get my head out of the clouds once in a while. Sure, my customers use my software, but my internal build processes are invisible to them.