My recomentation of releasing internal company libraries as open source.
If there is a need to write code that can be abstracted away as a library and used in many projects and it is not written yet:
- define the needed functionality and interface
- write and publish the library following my guide as an internal project (not the client project)
- use the library in the client project as you would use any other open source library
If the code is already written as a part of a client project and you would like to have that functionality available as a library in the future projects:
- define the functionality that should be a part of the library (only functionality, not interface)
- rewrite it from scratch by someone who hasn't written the original code and who knows only the functional requirements from point 1, as an internal project (not the client project), defining the interface from scratch
- use the library in future client projects as you would use any other open source library
- optionally upgrade the original project to use the new open source library
If the original code cannot be implemented any other way then it is just boilerplate, not useful as a library.
For any interesting functionality there will be countless ways to implement it. A clean-room implementation from scratch is the only way to create a library implementing functionality that was previously implemented as a part of a client project - otherwise it cannot be released as open source without an explicit written permission of the client who paid for the development of the original project.