code: def create_release():
      
      build = g.build
      release_name = request.form.get('release_name')
      utils.jsonify_assert(release_name, 'release_name required')
      url = request.form.get('url')
      utils.jsonify_assert(release_name, 'url required')
  
      release = models.Release(
          name=release_name,
          url=url,
          number=1,
          build_id=build.id)
  
      last_candidate = (
          models.Release.query
          .filter_by(build_id=build.id, name=release_name)
          .order_by(models.Release.number.desc())
          .first())
      if last_candidate:
          release.number += last_candidate.number
          if last_candidate.status == models.Release.PROCESSING:
              canceled_task_count = work_queue.cancel(
                  release_id=last_candidate.id)
              logging.info('Canceling %d tasks for previous attempt '
                           'build_id=%r, release_name=%r, release_number=%d',
                           canceled_task_count, build.id, last_candidate.name,
                           last_candidate.number)
              last_candidate.status = models.Release.BAD
              db.session.add(last_candidate)
  
      db.session.add(release)
      db.session.commit()
  
      signals.release_updated_via_api.send(app, build=build, release=release)
  
      logging.info('Created release: build_id=%r, release_name=%r, url=%r, '
                   'release_number=%d', build.id, release.name,
                   url, release.number)
  
      return flask.jsonify(
          success=True,
          build_id=build.id,
          release_name=release.name,
          release_number=release.number,
          url=url)
docs: Creates a new release candidate for a build.