Edit:
As comment by tehhowch, your answer was already on SO. This answer is from STTP Smart Triathlon Training on SO question how to publish to the web a spreadsheet using drive API and GAS
You must first active Drive API from Console API (See Enable the Drive Platform) and activate it in your script (Resources > Google Advanced Services > Click on "Activate" on "Drive API" row )
//this function publish to the web the document given by ID (google sheets or docs)
function publishToWeb(){
var ss = SpreadsheetApp.getActiveSpreadsheet();
var fileId = ss.getId();
var revisions = Drive.Revisions.list(fileId);
var items = revisions.items;
var revisionId =items[items.length-1].id;
var resource = Drive.Revisions.get(fileId, revisionId);
resource.published = true;
resource.publishAuto = true;
resource.publishedOutsideDomain = true;
Drive.Revisions.update(resource, fileId, revisionId);
}
First answer:
As seen on the documentation page, you can use the File.setSharing(accessType, permissionType) method like :
// Get Spreadsheet and Id
var ss = SpreadsheetApp.getActiveSpreadsheet();
var id = ss.getId();
// Get the file object with the Spreadsheet Id
var file = File.getFileById(id);
// Set sharing parameters so ANYONE can VIEW this spreadsheet
file.setSharing(DriveApp.Access.ANYONE, DriveApp.Permission.VIEW);
// Get the Spreadsheet url, who is now accessible by anyone
var url = ss.getUrl();
You can't just share one sheet by this method, but you can make something.
See also File.getFileById(id), SpreadsheetApp.getUrl(), SpreadsheetApp.getId()