HOWTO: Open Source
Categories:
6 minute read
If you’ve decided that you want to have a public GitHub repository, there are several things you should do to make it a good open source project, and not a nightmare.
Repository Structure
A well-organized repository structure makes it easier for contributors to understand and navigate your project.
Standard Directories
Directory | Purpose |
---|---|
src/ or lib/ | Source code files |
docs/ | Documentation files |
tests/ or spec/ | Test files |
examples/ | Example usage of your project |
scripts/ | Utility scripts for development, building, etc. |
assets/ | Images, icons, and other static assets |
.github/ | GitHub-specific files (workflows, templates) |
dist/ or build/ | Compiled/built files (often git-ignored) |
config/ | Configuration files |
Essential Files
README.md
Your README is the first thing visitors see. A good README should include:
- Project name and logo
- Brief description of what the project does
- Badges (build status, test coverage, version)
- Installation instructions
- Basic usage examples
- Links to full documentation
- License information
- How to contribute
Example structure:
# Project Name
[](https://github.com/username/repo/actions)
[](LICENSE)
[](https://npmjs.org/package/package-name)
Brief description of your project.
## Features
- Key feature 1
- Key feature 2
- Key feature 3
## Installation
```bash
npm install your-package-name
```
## Quick Start
```javascript
import { something } from 'your-package-name';
// Example code
```
## Documentation
For full documentation, visit [docs link].
## Contributing
Contributions welcome! Read the [contributing guidelines](CONTRIBUTING.md).
## License
[MIT](LICENSE)
LICENSE
Always include a license file as LICENSE
. Common open source licenses include:
- MIT License (permissive) - allows anyone to use, modify, and distribute your code with minimal restrictions. This includes commercial use.
- Apache License 2.0 (permissive with patent protection) - similar to MIT but includes an explicit grant of patent rights from contributors.
- GNU GPL v3 (copyleft) - requires derivative works to also be open source under the same license. This is more restrictive and not suitable for commercial use without compliance.
- BSD License (permissive) - similar to MIT but with clauses regarding the use of the name of the project or its contributors.
GitHub provides a license selector when creating repositories or you can add one later.
CONTRIBUTING.md
This file explains how others can contribute to your project:
- Development environment setup
- Coding conventions
- Commit message format
- Pull request process
- How to report bugs
- How to suggest features
To create a good contributing guide, see the GitHub guide on contributing.
CODE_OF_CONDUCT.md
A code of conduct defines community standards, signals a welcoming environment, and outlines procedures for handling abuse. The Contributor Covenant is a commonly used template.
You can get a Markdown version of this doc from the bottom of this page.
CHANGELOG.md
Track all notable changes between versions of your project. Format:
# Changelog
## [Unreleased]
## [1.0.0] - 2023-05-27
### Added
- New feature X
### Changed
- Improved performance of Y
### Fixed
- Bug in component Z
## [0.9.0] - 2023-04-15
...
SECURITY.md
Explain your security policy and how to report vulnerabilities.
SUPPORT.md
Information on where users can get help with your project.
STYLE_GUIDE.md
Document your coding standards and style conventions. Consider working with your Coding LLM to analyze your project, pull out patterns about how you code, and generate a style guide based on YOU.
Or, using your Coding LLM to generate an ideal, best-practices style guide. Then you can use that to analyze and level-up your code to that Standard.
GitHub Features Configuration
Issue Templates
Create templates for bug reports, feature requests, and other common issues in .github/ISSUE_TEMPLATE/
.
Bug report template example:
---
name: Bug report
about: Create a report to help us improve
title: '[BUG] '
labels: bug
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Environment:**
- OS: [e.g. iOS]
- Browser/Runtime: [e.g. chrome, node]
- Version: [e.g. 22]
**Additional context**
Add any other context about the problem here.
Pull Request Template
Create a .github/PULL_REQUEST_TEMPLATE.md
:
## Description
Clearly describe what changes this PR introduces and why.
## Related Issue(s)
Fixes #123
## Testing
Describe how you tested these changes.
## Checklist
- [ ] I have read the [CONTRIBUTING](../CONTRIBUTING.md) document
- [ ] My code follows the project's [STYLE_GUIDE](../STYLE_GUIDE.md)
- [ ] I have added tests that prove my fix/feature works
- [ ] All tests pass locally
- [ ] I have updated the documentation accordingly
- [ ] I have added a changelog entry to [CHANGELOG.md](../CHANGELOG.md)
GitHub Workflows
Set up CI/CD workflows in .github/workflows/
to automate testing, linting, and deployment.
Basic CI workflow example (.github/workflows/ci.yml
):
name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up runtime
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Run linter
run: npm run lint
Repository Settings to Configure
Branch Protection
Protect your main branch:
- Require pull request reviews before merging
- Require status checks to pass
- Require linear history
- Do not allow force pushes
Feature Toggles
Enable/disable these GitHub features based on your needs:
Feature | Recommendation | Rationale |
---|---|---|
Issues | Enable | Tracks bugs, enhancements, tasks |
Projects | Enable for larger projects | Project management |
Discussions | Enable | Community conversation space |
Wiki | Enable for comprehensive docs | Collaborative documentation |
Sponsorship | Optional | Funding opportunities |
Packages | Optional | For published packages |
Labels
Create a comprehensive set of labels for issues and PRs:
bug
- Something isn’t workingdocumentation
- Documentation improvementsenhancement
- New features or improvementsgood first issue
- Good for newcomershelp wanted
- Extra attention neededquestion
- Further information requestedwontfix
- This won’t be worked on
Community Engagement Best Practices
- Respond promptly to issues and pull requests
- Acknowledge contributions and thank contributors
- Document versioning policy clearly
- Set expectations for maintenance and response times
- Create a roadmap to show future direction
Maintenance Tools
Consider these tools to help maintain your project:
- Automated dependency updates (Dependabot, Renovate)
- Code quality tools (SonarQube, Code Climate)
- Test coverage (Codecov, Coveralls)
- Semantic versioning for releases
- Release automation scripts/workflows
Release Process
- Update version numbers in relevant files
- Update CHANGELOG.md with all notable changes
- Create release branch if using GitFlow
- Tag the release with the version number
- Create GitHub Release with compiled assets if applicable
- Publish to relevant package managers
Final Checklist Before Going Public
- Proper LICENSE is included
- README contains all essential information
- Code of Conduct is established
- Contributing guidelines are clear
- Continuous Integration is set up
- Repository structure is organized
- Security policy is defined
- Issue and PR templates are configured
- Documentation is accessible and comprehensive
- First release is tagged
By following these best practices, you’ll create a welcoming, well-structured open source project that’s easier to maintain and more likely to attract contributors.