func (g *GHR) CreateRelease(ctx context.Context, req *github.RepositoryRelease, recreate bool) (*github.RepositoryRelease, error) {
	if *req.Draft {
		fmt.Fprintln(g.outStream, "==> Create a draft release")
		return g.GitHub.CreateRelease(ctx, req)
	}
	req.Draft = github.Bool(true)
	release, err := g.GitHub.GetRelease(ctx, *req.TagName)
	if err != nil {
		if err != ErrReleaseNotFound {
			return nil, errors.Wrap(err, "failed to get release")
		}
		Debugf("Release (with tag %s) not found: create a new one",
			*req.TagName)
		if recreate {
			fmt.Fprintf(g.outStream,
				"WARNING: '-recreate' is specified but release (%s) not found",
				*req.TagName)
		}
		fmt.Fprintln(g.outStream, "==> Create a new release")
		return g.GitHub.CreateRelease(ctx, req)
	}
	if !recreate {
		Debugf("Release (with tag %s) exists: use existing one",
			*req.TagName)
		fmt.Fprintf(g.outStream, "WARNING: found release (%s). Use existing one.\n",
			*req.TagName)
		return release, nil
	}
	fmt.Fprintln(g.outStream, "==> Recreate a release")
	if err := g.DeleteRelease(ctx, *release.ID, *req.TagName); err != nil {
		return nil, err
	}
	return g.GitHub.CreateRelease(ctx, req)
}
CreateRelease creates (or recreates) a new package release
package main
import (
	"context"
	"fmt"
	"io"
	"path/filepath"
	"time"
	"github.com/google/go-github/github"
	"github.com/pkg/errors"
	"golang.org/x/sync/errgroup"
)
type GHR struct {
	GitHub GitHub
	outStream io.Writer
}