If you simply want to allow people to view your code, you can just upload it to GitHub or something similar.
By default, your work is copyright and you hold all rights, excluding those you give up to GitHub.
Open-Sourcing your project is all about choosing the license that you want your users to use.
Please, for the love of God, choose an existing license. Don't go out and try to make one yourself or mix and match. Not only do you open yourself up to liability but it just makes it harder for you to keep track of it.
Choosing a license is all about your personal preference and what your goals are. The two ends of the spectrum:
- MIT License: do whatever you want, so long as you attribute me. Most libraries use this license.
- GPL/AGPL: if you use my code, you must also release using GPL/AGPL or similarly appropriate license. Linux Kernel famously uses version 2. Linus Torvalds has issues with some of the terms in V3.
There is a lot of middle ground between these two philosophies. Most of the major licenses have seen some level of court cases. I personally use AGPL, which is often seen as one of the strongest, most restrictive, licenses.
I do not recommend releasing code to public domain. This often is a point of contention between OSS purists and OSS "spirit". I personally believe we're entering a new world of AI-driven content and I don't want more code feeding that beast.
The license is then copied and pasted to a LICENSE
file at the root of your repo and, boom. You've open sourced your code.
Keep in mind: that commit (and all future commits) will be available under that license until your copyright expires, so long as that license exists in your repo. You cannot claw it back.
One word of advice: you aren't likely going to see a bunch of people downloading your stuff. So don't get your hopes up that you'll have people submitting bug reports or making PRs, etc. All of my projects are just for me to use with one or two people reviewing it for fun. All but one, anyway.