If you're using a cover letter to apply for a job, it means you have no human inside the company that is advocating on your behalf. Your friend wouldn't ask you for a cover letter (in most cases) if he/she was going to refer you internally. So when you are required to use a cover letter, it usually means you're applying to a job 100% 'cold' as an outsider.
Unfortunately that may be the case sometimes. If a cover letter is required, there are a few key elements
1 - prove to the reader that you actually paid a bit of attention to the job requirement. I spent 20 years in recruiting, and generic cover letters that clearly weren't written for me ("Dear Esteemed Employer") never got my attention. I want to know what interested you in this opportunity, or briefly what you know about the company (could be lots of things).
2 - Talk a bit about what you're interested in from a work perspective. What kind of work do you want to be doing (and hopefully that is the work we're offering).
3 - Maybe check off a few boxes from the job spec. If they require a degree and n years with Python, a few sentences to check off those boxes will make it easy for the reader (often a recruiter or admin with little experience and limited knowledge of the domain) to say yes to you as a candidate.
Semi-formal tone. You can link to GitHub, but usually I link GitHub and LinkedIn on a resume.