Initial commit
This commit is contained in:
32
lib/github/release.go
Normal file
32
lib/github/release.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package github
|
||||
|
||||
import (
|
||||
"github.com/google/go-github/v72/github"
|
||||
)
|
||||
|
||||
func (g *Github) Release() (*int64, error) {
|
||||
relInfo := &github.RepositoryRelease{
|
||||
Name: &g.app.Settings().Title,
|
||||
Body: &g.app.Settings().Description,
|
||||
Draft: &g.app.Settings().Draft,
|
||||
TagName: &g.app.Settings().Tag,
|
||||
}
|
||||
|
||||
if *relInfo.Draft {
|
||||
g.app.Logger().Info("Release will be created as draft (unpublished) release")
|
||||
} else {
|
||||
g.app.Logger().Info("Release will be created and published")
|
||||
}
|
||||
|
||||
release, _, err := g.client.Repositories.CreateRelease(
|
||||
g.app.Context(), g.app.Settings().Owner, g.app.Settings().Repo, relInfo)
|
||||
if err != nil {
|
||||
g.app.Logger().WithError(err).Error("Failed to create release")
|
||||
|
||||
return nil, err
|
||||
}
|
||||
|
||||
g.app.Logger().WithField("release-id", *release.ID).Info("Successfully created release")
|
||||
|
||||
return release.ID, nil
|
||||
}
|
||||
Reference in New Issue
Block a user