code: def publish(self):
          
          with db.session.begin_nested():
              deposit = self.deposit_class.create(self.metadata)
              deposit['_deposit']['created_by'] = self.event.user_id
              deposit['_deposit']['owners'] = [self.event.user_id]
  
              # Fetch the deposit files
              for key, url in self.files:
                  deposit.files[key] = self.gh.api.session.get(
                      url, stream=True).raw
  
              deposit.publish()
              recid, record = deposit.fetch_published()
              self.model.recordmetadata = record.model
docs: Publish GitHub release as record.