0
0
mirror of https://github.com/thegeeklab/wp-gitea-release.git synced 2024-11-24 13:00:40 +00:00

Merge pull request #24 from 6543-forks/update-gitea-sdk

Update Gitea SDK to v0.13.0
This commit is contained in:
Thomas Boerger 2020-09-16 13:45:30 +02:00 committed by GitHub
commit 55aefa6b57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 32 deletions

View File

@ -10,7 +10,7 @@ platform:
steps:
- name: vet
pull: always
image: golang:1.11-windowsservercore-1803
image: golang:1.13-windowsservercore-1803
commands:
- go vet ./...
environment:
@ -21,7 +21,7 @@ steps:
- name: test
pull: always
image: golang:1.11-windowsservercore-1803
image: golang:1.13-windowsservercore-1803
commands:
- go test -cover ./...
environment:
@ -52,7 +52,7 @@ platform:
steps:
- name: build-push
pull: always
image: golang:1.11-windowsservercore-1803
image: golang:1.13-windowsservercore-1803
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
environment:
@ -65,7 +65,7 @@ steps:
- name: build-tag
pull: always
image: golang:1.11-windowsservercore-1803
image: golang:1.13-windowsservercore-1803
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
environment:
@ -77,7 +77,7 @@ steps:
- name: executable
pull: always
image: golang:1.11-windowsservercore-1803
image: golang:1.13-windowsservercore-1803
commands:
- ./release/windows/amd64/drone-gitea-release.exe --help
@ -148,7 +148,7 @@ platform:
steps:
- name: build-push
pull: always
image: golang:1.11-windowsservercore-1809
image: golang:1.13-windowsservercore-1809
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
environment:
@ -161,7 +161,7 @@ steps:
- name: build-tag
pull: always
image: golang:1.11-windowsservercore-1809
image: golang:1.13-windowsservercore-1809
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
environment:
@ -173,7 +173,7 @@ steps:
- name: executable
pull: always
image: golang:1.11-windowsservercore-1809
image: golang:1.13-windowsservercore-1809
commands:
- ./release/windows/amd64/drone-gitea-release.exe --help

View File

@ -9,7 +9,7 @@ platform:
steps:
- name: vet
pull: always
image: golang:1.11
image: golang:1.13
commands:
- go vet ./...
environment:
@ -20,7 +20,7 @@ steps:
- name: test
pull: always
image: golang:1.11
image: golang:1.13
commands:
- go test -cover ./...
environment:
@ -50,7 +50,7 @@ platform:
steps:
- name: build-push
pull: always
image: golang:1.11
image: golang:1.13
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-gitea-release"
environment:
@ -63,7 +63,7 @@ steps:
- name: build-tag
pull: always
image: golang:1.11
image: golang:1.13
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-gitea-release"
environment:
@ -75,7 +75,7 @@ steps:
- name: executable
pull: always
image: golang:1.11
image: golang:1.13
commands:
- ./release/linux/amd64/drone-gitea-release --help
@ -134,7 +134,7 @@ platform:
steps:
- name: build-push
pull: always
image: golang:1.11
image: golang:1.13
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-gitea-release"
environment:
@ -147,7 +147,7 @@ steps:
- name: build-tag
pull: always
image: golang:1.11
image: golang:1.13
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-gitea-release"
environment:
@ -159,7 +159,7 @@ steps:
- name: executable
pull: always
image: golang:1.11
image: golang:1.13
commands:
- ./release/linux/arm64/drone-gitea-release --help
@ -218,7 +218,7 @@ platform:
steps:
- name: build-push
pull: always
image: golang:1.11
image: golang:1.13
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-gitea-release"
environment:
@ -231,7 +231,7 @@ steps:
- name: build-tag
pull: always
image: golang:1.11
image: golang:1.13
commands:
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-gitea-release"
environment:
@ -243,7 +243,7 @@ steps:
- name: executable
pull: always
image: golang:1.11
image: golang:1.13
commands:
- ./release/linux/arm/drone-gitea-release --help

2
go.mod
View File

@ -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
View File

@ -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=

View File

@ -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{

View File

@ -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)
}