Two files, one sidebar
A sidebar is two pieces: a .gs file that opens it and exposes server functions, and an .html file that renders inside the panel. In the Apps Script editor, create sidebar.gs with the code above, then add a new HTML file named sidebar (no extension needed in the editor; it saves as sidebar.html). The name you pass to createHtmlOutputFromFile must match that file name exactly, or you get a silent failure with no useful error in the console.
To wire a menu item that opens it, add an onOpen trigger: function onOpen() { SpreadsheetApp.getUi().createMenu('Tools').addItem('Open sidebar', 'showSidebar').addToUi(); }. That runs automatically whenever the sheet loads, putting your entry in the top menu bar.