mirror of
https://github.com/thegeeklab/wp-gitea-release.git
synced 2024-11-21 13:50:40 +00:00
Update Gitea SDK to v0.13.0
This commit is contained in:
parent
ca63c2ddea
commit
238fd28d8e
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/drone-plugins/drone-gitea-release
|
||||
go 1.14
|
||||
|
||||
require (
|
||||
code.gitea.io/sdk/gitea v0.12.0
|
||||
code.gitea.io/sdk/gitea v0.13.0
|
||||
github.com/Sirupsen/logrus v1.0.5
|
||||
github.com/joho/godotenv v1.2.0
|
||||
github.com/onsi/ginkgo v1.12.2 // indirect
|
||||
|
4
go.sum
4
go.sum
@ -1,5 +1,5 @@
|
||||
code.gitea.io/sdk/gitea v0.12.0 h1:hvDCz4wtFvo7rf5Ebj8tGd4aJ4wLPKX3BKFX9Dk1Pgs=
|
||||
code.gitea.io/sdk/gitea v0.12.0/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
|
||||
code.gitea.io/sdk/gitea v0.13.0 h1:iHognp8ZMhMFLooUUNZFpm8IHaC9qoHJDvAE5vTm5aw=
|
||||
code.gitea.io/sdk/gitea v0.13.0/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
|
||||
github.com/Sirupsen/logrus v1.0.5 h1:447dy9LxSj+Iaa2uN3yoFHOzU9yJcJYiQPtNz8OXtv0=
|
||||
github.com/Sirupsen/logrus v1.0.5/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U=
|
||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||
|
11
plugin.go
11
plugin.go
@ -110,18 +110,19 @@ func (p Plugin) Exec() error {
|
||||
}
|
||||
}
|
||||
|
||||
client := gitea.NewClient(p.Config.BaseURL, p.Config.APIKey)
|
||||
|
||||
httpClient := &http.Client{}
|
||||
if p.Config.Insecure {
|
||||
cookieJar, _ := cookiejar.New(nil)
|
||||
|
||||
var insecureClient = &http.Client{
|
||||
httpClient = &http.Client{
|
||||
Jar: cookieJar,
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
},
|
||||
}
|
||||
client.SetHTTPClient(insecureClient)
|
||||
}
|
||||
client, err := gitea.NewClient(p.Config.BaseURL, gitea.SetToken(p.Config.APIKey), gitea.SetHTTPClient(httpClient))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
rc := releaseClient{
|
||||
|
10
release.go
10
release.go
@ -42,7 +42,7 @@ func (rc *releaseClient) buildRelease() (*gitea.Release, error) {
|
||||
}
|
||||
|
||||
func (rc *releaseClient) getRelease() (*gitea.Release, error) {
|
||||
releases, err := rc.Client.ListReleases(rc.Owner, rc.Repo, gitea.ListReleasesOptions{})
|
||||
releases, _, err := rc.Client.ListReleases(rc.Owner, rc.Repo, gitea.ListReleasesOptions{})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -65,7 +65,7 @@ func (rc *releaseClient) newRelease() (*gitea.Release, error) {
|
||||
Note: rc.Note,
|
||||
}
|
||||
|
||||
release, err := rc.Client.CreateRelease(rc.Owner, rc.Repo, r)
|
||||
release, _, err := rc.Client.CreateRelease(rc.Owner, rc.Repo, r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("Failed to create release: %s", err)
|
||||
}
|
||||
@ -75,7 +75,7 @@ func (rc *releaseClient) newRelease() (*gitea.Release, error) {
|
||||
}
|
||||
|
||||
func (rc *releaseClient) uploadFiles(releaseID int64, files []string) error {
|
||||
attachments, err := rc.Client.ListReleaseAttachments(rc.Owner, rc.Repo, releaseID, gitea.ListReleaseAttachmentsOptions{})
|
||||
attachments, _, err := rc.Client.ListReleaseAttachments(rc.Owner, rc.Repo, releaseID, gitea.ListReleaseAttachmentsOptions{})
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to fetch existing assets: %s", err)
|
||||
@ -113,7 +113,7 @@ files:
|
||||
|
||||
for _, attachment := range attachments {
|
||||
if attachment.Name == path.Base(file) {
|
||||
if err := rc.Client.DeleteReleaseAttachment(rc.Owner, rc.Repo, releaseID, attachment.ID); err != nil {
|
||||
if _, err := rc.Client.DeleteReleaseAttachment(rc.Owner, rc.Repo, releaseID, attachment.ID); err != nil {
|
||||
return fmt.Errorf("Failed to delete %s artifact: %s", file, err)
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ files:
|
||||
}
|
||||
}
|
||||
|
||||
if _, err = rc.Client.CreateReleaseAttachment(rc.Owner, rc.Repo, releaseID, handle, path.Base(file)); err != nil {
|
||||
if _, _, err = rc.Client.CreateReleaseAttachment(rc.Owner, rc.Repo, releaseID, handle, path.Base(file)); err != nil {
|
||||
return fmt.Errorf("Failed to upload %s artifact: %s", file, err)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user