From 0b4f9322ad5d81880b1498f89135bd5355acb01f Mon Sep 17 00:00:00 2001 From: David O'Sullivan Date: Thu, 21 Sep 2023 16:55:12 +0100 Subject: [PATCH] updates Dockerfile to remove upx, adds source Maven action --- actions/Dockerfile | 6 +----- actions/maven-dependency/main.go | 27 ++++++++++++++++++++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/actions/Dockerfile b/actions/Dockerfile index 42c70c76..46a058e3 100644 --- a/actions/Dockerfile +++ b/actions/Dockerfile @@ -1,6 +1,4 @@ -FROM golang:1.20.8-bullseye as build-stage - -RUN apt-get update && apt-get install -y --no-install-recommends upx +FROM golang:1.20 as build-stage WORKDIR /src ENV GO111MODULE=on CGO_ENABLED=0 @@ -17,8 +15,6 @@ RUN go build \ RUN strip /bin/action -RUN upx -q -9 /bin/action - FROM scratch COPY --from=build-stage /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt COPY --from=build-stage /bin/action /bin/action diff --git a/actions/maven-dependency/main.go b/actions/maven-dependency/main.go index dc113430..d0eb20ec 100644 --- a/actions/maven-dependency/main.go +++ b/actions/maven-dependency/main.go @@ -68,18 +68,28 @@ func main() { panic(fmt.Errorf("unable to decode payload\n%w", err)) } + sources := make(map[string]string) versions := make(actions.Versions) for _, v := range raw.Versioning.Versions { if p := versionPattern.MatchString(v); p { w := fmt.Sprintf("%s/%s/%s/%s", u, strings.ReplaceAll(g, ".", "/"), a, v) w = fmt.Sprintf("%s/%s-%s", w, a, v) + src := w + if s, ok := inputs["classifier"]; ok { w = fmt.Sprintf("%s-%s", w, s) } + if sc, ok := inputs["source_classifier"]; ok { + src = fmt.Sprintf("%s-%s", src, sc) + } else { + src = fmt.Sprintf("%s-%s", src, "src") + } if s, ok := inputs["packaging"]; ok { w = fmt.Sprintf("%s.%s", w, s) + src = fmt.Sprintf("%s.%s", src, s) } else { w = fmt.Sprintf("%s.jar", w) + src = fmt.Sprintf("%s.jar", src) } n, err := actions.NormalizeVersion(v) @@ -88,12 +98,23 @@ func main() { } versions[n] = w + sources[n] = src } } - if o, err := versions.GetLatest(inputs); err != nil { + latestVersion, err := versions.GetLatestVersion(inputs) + if err != nil { + panic(err) + } + latestSource := actions.Outputs{} + if sources != nil { + latestSource["source"] = sources[latestVersion.Original()] + } + + o, err := actions.NewOutputs(versions[latestVersion.Original()], latestVersion, latestSource) + if err != nil { panic(err) - } else { + }else { o.Write() } } @@ -104,4 +125,4 @@ type Metadata struct { type Versioning struct { Versions []string `xml:"versions>version"` -} +} \ No newline at end of file