code: func (s *deployerService) createRelease(ctx context.Context, db *gorm.DB, ss twelvefactor.StatusStream, opts DeployOpts) (*Release, error) {
  	app, img := opts.App, opts.Image
  
  	// If no app is specified, attempt to find the app that relates to this
  	// images repository, or create it if not found.
  	if app == nil {
  		var err error
  		app, err = appsFindOrCreateByRepo(db, img.Repository)
  		if err != nil {
  			return nil, err
  		}
  	} else {
  		// If the app doesn't already have a repo attached to it, we'll attach
  		// this image's repo.
  		if err := appsEnsureRepo(db, app, img.Repository); err != nil {
  			return nil, err
  		}
  	}
  
  	// Grab the latest config.
  	config, err := s.configs.Config(db, app)
  	if err != nil {
  		return nil, err
  	}
  
  	// Create a new slug for the docker image.
  	slug, err := s.slugs.Create(ctx, db, img, opts.Output)
  	if err != nil {
  		return nil, err
  	}
  
  	// Create a new release for the Config
  	// and Slug.
  	desc := fmt.Sprintf("Deploy %s", img.String())
  	desc = appendMessageToDescription(desc, opts.User, opts.Message)
  
  	r, err := s.releases.Create(ctx, db, &Release{
  		App:         app,
  		Config:      config,
  		Slug:        slug,
  		Description: desc,
  	})
  	return r, err
  }
docs: // createRelease creates a new release that can be deployed