chore: bump sdk to v1.5.0
This commit is contained in:
parent
fa883499d0
commit
5a37d05e67
6 changed files with 14 additions and 31 deletions
1
.dockerignore
Normal file
1
.dockerignore
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
.git
|
||||||
|
|
@ -7,7 +7,7 @@ WORKDIR /app
|
||||||
COPY go.mod go.sum /app/
|
COPY go.mod go.sum /app/
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
|
|
||||||
COPY *.go /app/
|
COPY . /app/
|
||||||
RUN go build -o app .
|
RUN go build -o app .
|
||||||
|
|
||||||
FROM docker.io/alpine:3.22
|
FROM docker.io/alpine:3.22
|
||||||
|
|
|
||||||
28
github.go
28
github.go
|
|
@ -6,11 +6,11 @@ import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"mime"
|
|
||||||
"mime/multipart"
|
"mime/multipart"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
|
||||||
|
"code.geekeey.de/actions/sdk"
|
||||||
)
|
)
|
||||||
|
|
||||||
type ApiClient interface {
|
type ApiClient interface {
|
||||||
|
|
@ -43,24 +43,6 @@ func NewGitHub(client ApiClient) *GitHub {
|
||||||
return &GitHub{client: client}
|
return &GitHub{client: client}
|
||||||
}
|
}
|
||||||
|
|
||||||
func HasContentType(r *http.Response, mimetype string) bool {
|
|
||||||
contentType := r.Header.Get("content-type")
|
|
||||||
if contentType == "" {
|
|
||||||
return mimetype == "application/octet-stream"
|
|
||||||
}
|
|
||||||
|
|
||||||
for _, v := range strings.Split(contentType, ",") {
|
|
||||||
t, _, err := mime.ParseMediaType(v)
|
|
||||||
if err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
if t == mimetype {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
type GitTag struct {
|
type GitTag struct {
|
||||||
Commit struct {
|
Commit struct {
|
||||||
Created string `json:"created,omitempty"`
|
Created string `json:"created,omitempty"`
|
||||||
|
|
@ -87,7 +69,7 @@ func (gh *GitHub) GetGitTagInfo(repository, tag string, ctx context.Context) (*G
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if !HasContentType(res, "application/json") {
|
if !sdk.HasContentType(res, "application/json") {
|
||||||
return nil, fmt.Errorf("content-type: %q should be %q",
|
return nil, fmt.Errorf("content-type: %q should be %q",
|
||||||
res.Header.Get("content-type"), "application/json")
|
res.Header.Get("content-type"), "application/json")
|
||||||
}
|
}
|
||||||
|
|
@ -161,7 +143,7 @@ func (gh *GitHub) CreateRelease(creq *CreateReleaseRequest, ctx context.Context)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if !HasContentType(res, "application/json") {
|
if !sdk.HasContentType(res, "application/json") {
|
||||||
return nil, fmt.Errorf("content-type: %q should be %q",
|
return nil, fmt.Errorf("content-type: %q should be %q",
|
||||||
res.Header.Get("content-type"), "application/json")
|
res.Header.Get("content-type"), "application/json")
|
||||||
}
|
}
|
||||||
|
|
@ -264,7 +246,7 @@ func (gh *GitHub) CreateReleaseArtifact(creq *CreateReleaseArtifactRequest, ctx
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
if !HasContentType(res, "application/json") {
|
if !sdk.HasContentType(res, "application/json") {
|
||||||
return nil, fmt.Errorf("content-type: %q should be %q",
|
return nil, fmt.Errorf("content-type: %q should be %q",
|
||||||
res.Header.Get("content-type"), "application/json")
|
res.Header.Get("content-type"), "application/json")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
go.mod
2
go.mod
|
|
@ -2,4 +2,4 @@ module code.geekeey.de/actions/release
|
||||||
|
|
||||||
go 1.23.2
|
go 1.23.2
|
||||||
|
|
||||||
require code.geekeey.de/actions/sdk v1.2.0
|
require code.geekeey.de/actions/sdk v1.5.0
|
||||||
|
|
|
||||||
4
go.sum
4
go.sum
|
|
@ -1,2 +1,2 @@
|
||||||
code.geekeey.de/actions/sdk v1.2.0 h1:qQvOdTBtZVpR1xATNnApeiW78y34Jh83OjsQg1ajPjA=
|
code.geekeey.de/actions/sdk v1.5.0 h1:7Ly8QsBniiwDVbv2Gm14l28+ccK1Z9fVUqsPHw9lSMg=
|
||||||
code.geekeey.de/actions/sdk v1.2.0/go.mod h1:7iIOi3YUmdDe2BCz9s59wK1t0Ckec34e664q+TOreiE=
|
code.geekeey.de/actions/sdk v1.5.0/go.mod h1:7iIOi3YUmdDe2BCz9s59wK1t0Ckec34e664q+TOreiE=
|
||||||
|
|
|
||||||
8
main.go
8
main.go
|
|
@ -39,8 +39,6 @@ type ReleaseAction struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (action *ReleaseAction) setup() error {
|
func (action *ReleaseAction) setup() error {
|
||||||
var err error
|
|
||||||
|
|
||||||
action.repository = action.GetInput("repository")
|
action.repository = action.GetInput("repository")
|
||||||
if ok, err := regexp.MatchString(`^(\w+)/(\w+)$`, action.repository); !ok || err != nil {
|
if ok, err := regexp.MatchString(`^(\w+)/(\w+)$`, action.repository); !ok || err != nil {
|
||||||
return fmt.Errorf("input 'repository': is empty or does not match <onwer>/<repo>")
|
return fmt.Errorf("input 'repository': is empty or does not match <onwer>/<repo>")
|
||||||
|
|
@ -69,17 +67,19 @@ func (action *ReleaseAction) setup() error {
|
||||||
|
|
||||||
// draft might be a bool constant or a regex which determins if it is
|
// draft might be a bool constant or a regex which determins if it is
|
||||||
// a draft by matching against the input version
|
// a draft by matching against the input version
|
||||||
action.draft, err = pattern("draft")
|
draft, err := pattern("draft")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("input 'draft': is not a bool or a valid regex")
|
return fmt.Errorf("input 'draft': is not a bool or a valid regex")
|
||||||
}
|
}
|
||||||
|
action.draft = draft
|
||||||
|
|
||||||
// prerelease might be a bool constant or a regex which determins if it is
|
// prerelease might be a bool constant or a regex which determins if it is
|
||||||
// a prelease by matching against the input version
|
// a prelease by matching against the input version
|
||||||
action.prerelease, err = pattern("prerelease")
|
prerelease, err := pattern("prerelease")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("input 'prerelease': is not a bool or a valid regex")
|
return fmt.Errorf("input 'prerelease': is not a bool or a valid regex")
|
||||||
}
|
}
|
||||||
|
action.prerelease = prerelease
|
||||||
|
|
||||||
action.label = action.GetInput("label")
|
action.label = action.GetInput("label")
|
||||||
action.notes = action.GetInput("notes")
|
action.notes = action.GetInput("notes")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue