From 238fd28d8e7b05a12bf57421ea08532b87e85f70 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 16 Sep 2020 08:01:14 +0200 Subject: [PATCH 1/2] Update Gitea SDK to v0.13.0 --- go.mod | 2 +- go.sum | 4 ++-- plugin.go | 11 ++++++----- release.go | 10 +++++----- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/go.mod b/go.mod index 3635091..ccca439 100644 --- a/go.mod +++ b/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 diff --git a/go.sum b/go.sum index a624175..4502036 100644 --- a/go.sum +++ b/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= diff --git a/plugin.go b/plugin.go index b59dfcc..734cb0c 100644 --- a/plugin.go +++ b/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{ diff --git a/release.go b/release.go index 1f4757c..e80d84b 100644 --- a/release.go +++ b/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) } From b433d4222aa89b60b76bddc6acc8fb86258e9fed Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 16 Sep 2020 08:26:19 +0200 Subject: [PATCH 2/2] golang 1.13 --- .drone.windows.yml | 16 ++++++++-------- .drone.yml | 22 +++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/.drone.windows.yml b/.drone.windows.yml index 785cacc..1443eb2 100644 --- a/.drone.windows.yml +++ b/.drone.windows.yml @@ -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 diff --git a/.drone.yml b/.drone.yml index fa4413d..f23a5db 100644 --- a/.drone.yml +++ b/.drone.yml @@ -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