There are many advantages to open sourcing your code. It’s more cost-effective, you’ll get-to-market faster, and most importantly, you get access to the talented and welcoming open source community. If you’re thinking about open sourcing your library, there are some things you need to be mindful of in order to make sure you are following all the rules and that the code is ready for the community. In this video, we’ll give you a checklist of tasks you need to complete before open sourcing your code. Let’s get started!
Step 1: Is the code secure?
Before submitting your code, you should check it to ensure that no proprietary information is present. Examples of information you don’t want to open source are usernames and passwords. Check to make sure that your configuration uses environment variables where necessary. Your code won’t be portable with hardcoded database names and credentials, so environment variables are convenient and are a secure default.
Step 2: Declare your dependencies
You should make sure your dependencies are encapsulated and explicitly declared. Your open source community needs to know what they are getting and if your code will work within their existing dependencies.
Step 3: Check for licensed code
If there is any General Public Licensed code or any other code that requires a specific license in the codebase, the open source community will not be able to work with your code. Restrictive licenses limit what people can do with your code and can get you into legal trouble.
Step 4: Follow best practices
You want your code to follow best practices for variable names, whitespace, and so on for the language you’re working with. This will make it easier for the community to jump right in and start contributing to your project. It will also make implementing the library your open sourcing easier if it follows convention.
Step 5: Provide unit tests
You will want to make sure the unit tests pass when following setup instructions. These will instill confidence in users as well as maintainers when it’s time to merge community contributions into the code repos.
Step 6: Create a new repo and move the code into it
This will ensure there’s no git history with lingering credentials or internal comments, allowing the community to start with a blank slate while reviewing your code.
Step 7: Add files needed for the public repo
There are a few files that need to be added for onboarding your community of contributors. First is a README text file that contains set-up instructions and code examples. You will also want to add a LICENSE text file containing the MIT license and a CHANGELOG. Providing these tools makes it easier for people evaluating your project to determine if it meets their needs.
Step 8: Version the library
Versions not only indicate to humans when things change, but they can also be processed by machines. Many package managers allow users to define a range of allowed versions based on major, minor, and revision numbers. Semantic versioning makes sure your code follows what both humans and machines expect.
Step 9: Add helpful utilities or create issues indicating the need for them
These are signs of a well-maintained project and are valuable tools to the maintainers of the repo. Some utilities we like include travis-ci and code climate.
Step 10: Publish the code as a package, if you can
There may be a package manager for the language you’re working with which will allow you to publish your code as a package. This will make it easier for people to use your code. Make sure you document the publication process for yourself.
Step 11: Make the repo public and post about it wherever you can!
Now that you have officially open sourced your code, tell everyone about it!
In just 11 steps, you’re now ready to open source your code! These practices will make sure you and your code are protected and will make it easy for the community to contribute to your project. The entire community is at your fingertips, and by open sourcing your code, you can take your project to new heights. So what are you waiting for?