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:
commit
55aefa6b57
@ -10,7 +10,7 @@ platform:
|
|||||||
steps:
|
steps:
|
||||||
- name: vet
|
- name: vet
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11-windowsservercore-1803
|
image: golang:1.13-windowsservercore-1803
|
||||||
commands:
|
commands:
|
||||||
- go vet ./...
|
- go vet ./...
|
||||||
environment:
|
environment:
|
||||||
@ -21,7 +21,7 @@ steps:
|
|||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11-windowsservercore-1803
|
image: golang:1.13-windowsservercore-1803
|
||||||
commands:
|
commands:
|
||||||
- go test -cover ./...
|
- go test -cover ./...
|
||||||
environment:
|
environment:
|
||||||
@ -52,7 +52,7 @@ platform:
|
|||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- name: build-push
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11-windowsservercore-1803
|
image: golang:1.13-windowsservercore-1803
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
|
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
|
||||||
environment:
|
environment:
|
||||||
@ -65,7 +65,7 @@ steps:
|
|||||||
|
|
||||||
- name: build-tag
|
- name: build-tag
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11-windowsservercore-1803
|
image: golang:1.13-windowsservercore-1803
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
|
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
|
||||||
environment:
|
environment:
|
||||||
@ -77,7 +77,7 @@ steps:
|
|||||||
|
|
||||||
- name: executable
|
- name: executable
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11-windowsservercore-1803
|
image: golang:1.13-windowsservercore-1803
|
||||||
commands:
|
commands:
|
||||||
- ./release/windows/amd64/drone-gitea-release.exe --help
|
- ./release/windows/amd64/drone-gitea-release.exe --help
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ platform:
|
|||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- name: build-push
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11-windowsservercore-1809
|
image: golang:1.13-windowsservercore-1809
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
|
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
|
||||||
environment:
|
environment:
|
||||||
@ -161,7 +161,7 @@ steps:
|
|||||||
|
|
||||||
- name: build-tag
|
- name: build-tag
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11-windowsservercore-1809
|
image: golang:1.13-windowsservercore-1809
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
|
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/windows/amd64/drone-gitea-release.exe"
|
||||||
environment:
|
environment:
|
||||||
@ -173,7 +173,7 @@ steps:
|
|||||||
|
|
||||||
- name: executable
|
- name: executable
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11-windowsservercore-1809
|
image: golang:1.13-windowsservercore-1809
|
||||||
commands:
|
commands:
|
||||||
- ./release/windows/amd64/drone-gitea-release.exe --help
|
- ./release/windows/amd64/drone-gitea-release.exe --help
|
||||||
|
|
||||||
|
22
.drone.yml
22
.drone.yml
@ -9,7 +9,7 @@ platform:
|
|||||||
steps:
|
steps:
|
||||||
- name: vet
|
- name: vet
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- go vet ./...
|
- go vet ./...
|
||||||
environment:
|
environment:
|
||||||
@ -20,7 +20,7 @@ steps:
|
|||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- go test -cover ./...
|
- go test -cover ./...
|
||||||
environment:
|
environment:
|
||||||
@ -50,7 +50,7 @@ platform:
|
|||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- name: build-push
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-gitea-release"
|
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/amd64/drone-gitea-release"
|
||||||
environment:
|
environment:
|
||||||
@ -63,7 +63,7 @@ steps:
|
|||||||
|
|
||||||
- name: build-tag
|
- name: build-tag
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-gitea-release"
|
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/amd64/drone-gitea-release"
|
||||||
environment:
|
environment:
|
||||||
@ -75,7 +75,7 @@ steps:
|
|||||||
|
|
||||||
- name: executable
|
- name: executable
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- ./release/linux/amd64/drone-gitea-release --help
|
- ./release/linux/amd64/drone-gitea-release --help
|
||||||
|
|
||||||
@ -134,7 +134,7 @@ platform:
|
|||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- name: build-push
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-gitea-release"
|
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm64/drone-gitea-release"
|
||||||
environment:
|
environment:
|
||||||
@ -147,7 +147,7 @@ steps:
|
|||||||
|
|
||||||
- name: build-tag
|
- name: build-tag
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-gitea-release"
|
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm64/drone-gitea-release"
|
||||||
environment:
|
environment:
|
||||||
@ -159,7 +159,7 @@ steps:
|
|||||||
|
|
||||||
- name: executable
|
- name: executable
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- ./release/linux/arm64/drone-gitea-release --help
|
- ./release/linux/arm64/drone-gitea-release --help
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ platform:
|
|||||||
steps:
|
steps:
|
||||||
- name: build-push
|
- name: build-push
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-gitea-release"
|
- "go build -v -ldflags \"-X main.version=${DRONE_COMMIT_SHA:0:8}\" -a -tags netgo -o release/linux/arm/drone-gitea-release"
|
||||||
environment:
|
environment:
|
||||||
@ -231,7 +231,7 @@ steps:
|
|||||||
|
|
||||||
- name: build-tag
|
- name: build-tag
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-gitea-release"
|
- "go build -v -ldflags \"-X main.version=${DRONE_TAG##v}\" -a -tags netgo -o release/linux/arm/drone-gitea-release"
|
||||||
environment:
|
environment:
|
||||||
@ -243,7 +243,7 @@ steps:
|
|||||||
|
|
||||||
- name: executable
|
- name: executable
|
||||||
pull: always
|
pull: always
|
||||||
image: golang:1.11
|
image: golang:1.13
|
||||||
commands:
|
commands:
|
||||||
- ./release/linux/arm/drone-gitea-release --help
|
- ./release/linux/arm/drone-gitea-release --help
|
||||||
|
|
||||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/drone-plugins/drone-gitea-release
|
|||||||
go 1.14
|
go 1.14
|
||||||
|
|
||||||
require (
|
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/Sirupsen/logrus v1.0.5
|
||||||
github.com/joho/godotenv v1.2.0
|
github.com/joho/godotenv v1.2.0
|
||||||
github.com/onsi/ginkgo v1.12.2 // indirect
|
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.13.0 h1:iHognp8ZMhMFLooUUNZFpm8IHaC9qoHJDvAE5vTm5aw=
|
||||||
code.gitea.io/sdk/gitea v0.12.0/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
|
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 h1:447dy9LxSj+Iaa2uN3yoFHOzU9yJcJYiQPtNz8OXtv0=
|
||||||
github.com/Sirupsen/logrus v1.0.5/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U=
|
github.com/Sirupsen/logrus v1.0.5/go.mod h1:rmk17hk6i8ZSAJkSDa7nOxamrG+SP4P0mm+DAvExv4U=
|
||||||
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
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 {
|
if p.Config.Insecure {
|
||||||
cookieJar, _ := cookiejar.New(nil)
|
cookieJar, _ := cookiejar.New(nil)
|
||||||
|
httpClient = &http.Client{
|
||||||
var insecureClient = &http.Client{
|
|
||||||
Jar: cookieJar,
|
Jar: cookieJar,
|
||||||
Transport: &http.Transport{
|
Transport: &http.Transport{
|
||||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
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{
|
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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ func (rc *releaseClient) newRelease() (*gitea.Release, error) {
|
|||||||
Note: rc.Note,
|
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 {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Failed to create release: %s", err)
|
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 {
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("Failed to fetch existing assets: %s", err)
|
return fmt.Errorf("Failed to fetch existing assets: %s", err)
|
||||||
@ -113,7 +113,7 @@ files:
|
|||||||
|
|
||||||
for _, attachment := range attachments {
|
for _, attachment := range attachments {
|
||||||
if attachment.Name == path.Base(file) {
|
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)
|
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)
|
return fmt.Errorf("Failed to upload %s artifact: %s", file, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user