Making source code open and reusable
The Digital Scotland Service Standard requires that new source code is open and reusable. This is because it:
- reduces duplication and saves time
- encourages collaboration between teams and organisations
- makes services more transparent and accountable
How to publish your code
You should make your code publicly available in an open internet source code repository. This includes code developed for you by a third party, such as a development agency.
The Scottish Government Digital Publishing team makes its code available on GitHub. So does the Design System.
When publishing your code, you should:
- include clear documentation so others can understand and reuse your code
- add a README file that explains what the code does and how to use it
License your code
You should publish your code under an Open Source Initiative compatible licence. This lets others know they can reuse and adapt your code. Add the licence file to your repository.
The MIT licence is commonly used by Scottish Government and the Government Digital Service.
Check for sensitive information
Before publishing your code:
- remove passwords, API keys, and personal data
- review your code for security risks
Maintain your code
You need to maintain your code after publication and make it clear when you release updates, for example by using Semantic Versioning.
There’s a good chance you'll need to react to and manage:
- requests for new features
- bug reports
- pull requests to merge code into the main codebase
- vulnerabilities in the code or the libraries you are using to create it
GOV.UK has a style guide for pull requests.
Track changes to your code
It's good practice to keep track of changes to your code using version control.
Services like GitHub make version control much easier. They allow you to track issues and read documentation alongside your code. This shows what has changed and why.
GOV.UK has more information about maintaining version control in coding.
Closed code
There’s some code that should remain closed, including:
- keys and credentials
- algorithms used to detect fraud
- unreleased policy
Ideally, you will have a technical architect on your project who can advise on which parts of your code you can publish in the open. It's also advisable to have a security architect or security information risk advisor to help assess the risk of open sourcing code.
You can find more information on GOV.UK about: