From afd5683b3c63e13000d2e121af041ad17c62f173 Mon Sep 17 00:00:00 2001 From: Prasanth Baskar <89722848+bupd@users.noreply.github.com> Date: Fri, 17 Jan 2025 14:57:32 +0530 Subject: [PATCH] Fix: Release & Publish Workflows (#313) * fix publish & release workflow * This commit fixes * publish on push to main * release on push tags Signed-off-by: bupd * update yaml Signed-off-by: bupd --------- Signed-off-by: bupd --- .github/workflows/default.yaml | 19 +++++----- dagger.json | 2 +- dagger/go.mod | 20 +++++------ dagger/go.sum | 46 ++++++++++++------------ dagger/main.go | 65 ++++++++++++++++++++++------------ 5 files changed, 85 insertions(+), 67 deletions(-) diff --git a/.github/workflows/default.yaml b/.github/workflows/default.yaml index 37184bf7..ac7d6ae4 100644 --- a/.github/workflows/default.yaml +++ b/.github/workflows/default.yaml @@ -105,24 +105,20 @@ jobs: contents: read id-token: write runs-on: ubuntu-latest + if: github.event_name == 'push' && github.ref == 'refs/heads/main' steps: - name: Print GitHub ref for debugging run: | echo "GitHub ref: $GITHUB_REF" - - name: Push images - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) - run: | - echo "Pushing images..." - - name: Checkout repo - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + if: github.event_name == 'push' && (github.ref == 'refs/heads/main') uses: actions/checkout@v4 with: fetch-depth: 0 - name: Publish and Sign Snapshot Image - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + if: github.event_name == 'push' && (github.ref == 'refs/heads/main') uses: ./.github/actions/publish-and-sign with: IMAGE_TAGS: latest @@ -140,13 +136,14 @@ jobs: packages: write id-token: write runs-on: ubuntu-latest + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/')) steps: - name: Print GitHub ref for debugging run: | echo "GitHub ref: $GITHUB_REF" - name: Push images - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/')) uses: ./.github/actions/publish-and-sign with: IMAGE_TAGS: latest, ${{ github.ref_name }} @@ -156,13 +153,13 @@ jobs: REGISTRY_USERNAME: ${{ vars.REGISTRY_USERNAME }} - name: Checkout repo - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/')) uses: actions/checkout@v4 with: fetch-depth: 0 - name: Create Release - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/')) uses: dagger/dagger-for-github@v7 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -172,7 +169,7 @@ jobs: args: "release --github-token=env:GITHUB_TOKEN" - name: Publish and Sign Tagged Image - if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + if: github.event_name == 'push' && (startsWith(github.ref, 'refs/tags/')) uses: ./.github/actions/publish-and-sign with: IMAGE_TAGS: "latest, ${{ github.ref_name }}" diff --git a/dagger.json b/dagger.json index 49096066..980639ec 100644 --- a/dagger.json +++ b/dagger.json @@ -1,6 +1,6 @@ { "name": "harbor-cli", - "engineVersion": "v0.14.0", + "engineVersion": "v0.15.2", "sdk": "go", "dependencies": [ { diff --git a/dagger/go.mod b/dagger/go.mod index d52dfa4e..844fd11b 100644 --- a/dagger/go.mod +++ b/dagger/go.mod @@ -3,9 +3,9 @@ module dagger/harbor-cli go 1.23.1 require ( - github.com/99designs/gqlgen v0.17.55 + github.com/99designs/gqlgen v0.17.57 github.com/Khan/genqlient v0.7.0 - github.com/vektah/gqlparser/v2 v2.5.17 + github.com/vektah/gqlparser/v2 v2.5.20 go.opentelemetry.io/otel v1.27.0 go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0 @@ -17,8 +17,8 @@ require ( go.opentelemetry.io/otel/trace v1.27.0 go.opentelemetry.io/proto/otlp v1.3.1 golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa - golang.org/x/sync v0.8.0 - google.golang.org/grpc v1.65.0 + golang.org/x/sync v0.10.0 + google.golang.org/grpc v1.68.0 ) require ( @@ -33,12 +33,12 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0 // indirect go.opentelemetry.io/otel/metric v1.27.0 go.opentelemetry.io/otel/sdk/metric v1.27.0 - golang.org/x/net v0.29.0 // indirect - golang.org/x/sys v0.26.0 // indirect - golang.org/x/text v0.18.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect - google.golang.org/protobuf v1.34.2 // indirect + golang.org/x/net v0.33.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect + google.golang.org/protobuf v1.35.2 // indirect ) replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 diff --git a/dagger/go.sum b/dagger/go.sum index c52dd24b..54ca7e35 100644 --- a/dagger/go.sum +++ b/dagger/go.sum @@ -1,5 +1,5 @@ -github.com/99designs/gqlgen v0.17.55 h1:3vzrNWYyzSZjGDFo68e5j9sSauLxfKvLp+6ioRokVtM= -github.com/99designs/gqlgen v0.17.55/go.mod h1:3Bq768f8hgVPGZxL8aY9MaYmbxa6llPM/qu1IGH1EJo= +github.com/99designs/gqlgen v0.17.57 h1:Ak4p60BRq6QibxY0lEc0JnQhDurfhxA67sp02lMjmPc= +github.com/99designs/gqlgen v0.17.57/go.mod h1:Jx61hzOSTcR4VJy/HFIgXiQ5rJ0Ypw8DxWLjbYDAUw0= github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w= github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= @@ -13,6 +13,8 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= @@ -25,10 +27,10 @@ github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sosodev/duration v1.3.1 h1:qtHBDMQ6lvMQsL15g4aopM4HEfOaYuhWBw3NPTtlqq4= github.com/sosodev/duration v1.3.1/go.mod h1:RQIBBX0+fMLc/D9+Jb/fwvVmo0eZvDDEERAikUR6SDg= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/vektah/gqlparser/v2 v2.5.17 h1:9At7WblLV7/36nulgekUgIaqHZWn5hxqluxrxGUhOmI= -github.com/vektah/gqlparser/v2 v2.5.17/go.mod h1:1lz1OeCqgQbQepsGxPVywrjdBHW2T08PUS3pJqepRww= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +github.com/vektah/gqlparser/v2 v2.5.20 h1:kPaWbhBntxoZPaNdBaIPT1Kh0i1b/onb5kXgEdP5JCo= +github.com/vektah/gqlparser/v2 v2.5.20/go.mod h1:xMl+ta8a5M1Yo1A1Iwt/k7gSpscwSnHZdw7tfhEGfTM= go.opentelemetry.io/otel v1.27.0 h1:9BZoF3yMK/O1AafMiQTVu0YDj5Ea4hPhxCs7sGva+cg= go.opentelemetry.io/otel v1.27.0/go.mod h1:DMpAK8fzYRzs+bi3rS5REupisuqTheUlSZJ1WnZaPAQ= go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88 h1:oM0GTNKGlc5qHctWeIGTVyda4iFFalOzMZ3Ehj5rwB4= @@ -63,21 +65,21 @@ go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa h1:FRnLl4eNAQl8hwxVVC17teOw8kdjVDVAiFMtgUdTSRQ= golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa/go.mod h1:zk2irFbV9DP96SEBUUAy67IdHUaZuSnrz1n472HUCLE= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo= -golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.65.0 h1:bs/cUb4lp1G5iImFFd3u5ixQzweKizoZJAwBNLR42lc= -google.golang.org/grpc v1.65.0/go.mod h1:WgYC2ypjlB0EiQi6wdKixMqukr6lBc0Vo+oOgjrM5ZQ= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc= +google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= +google.golang.org/grpc v1.68.0 h1:aHQeeJbo8zAkAa3pRzrVjZlbz6uSfeOXlJNQM0RAbz0= +google.golang.org/grpc v1.68.0/go.mod h1:fmSPC5AsjSBCK54MyHRx48kpOti1/jRfOlwEWywNjWA= +google.golang.org/protobuf v1.35.2 h1:8Ar7bF+apOIoThw1EdZl0p1oWvMqTHmpA2fRTyZO8io= +google.golang.org/protobuf v1.35.2/go.mod h1:9fA7Ob0pmnwhb644+1+CVWFRbNajQ6iRojtC/QF5bRE= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/dagger/main.go b/dagger/main.go index 1abad37d..ac6a13f4 100644 --- a/dagger/main.go +++ b/dagger/main.go @@ -65,17 +65,17 @@ func (m *HarborCli) BuildDev( WithEnvVariable("GOOS", os). WithEnvVariable("GOARCH", arch) - gitCommit, _ := builder.WithExec([]string{"git", "rev-parse", "--short", "HEAD"}).Stdout(ctx) + gitCommit, _ := builder.WithExec([]string{"git", "rev-parse", "--short", "HEAD", "--always"}).Stdout(ctx) buildTime := time.Now().UTC().Format(time.RFC3339) ldflagsArgs := fmt.Sprintf(`-X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.Version=dev -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GoVersion=%s - -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GitCommit=%s -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.BuildTime=%s + -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GitCommit=%s `, GO_VERSION, buildTime, gitCommit) builder = builder.WithExec([]string{ - "go", "build", "-ldflags", ldflagsArgs, "-o", "bin/harbor-cli", "cmd/harbor/main.go", + "go", "build", "-ldflags", ldflagsArgs, "-o", "/bin/harbor-cli", "/src/cmd/harbor/main.go", }) - return builder.File("bin/harbor-cli") + return builder.File("/bin/harbor-cli") } // Return list of containers for list of oses and arches @@ -86,17 +86,35 @@ func (m *HarborCli) BuildDev( // now so that no one calls this https://github.com/dagger/dagger/issues/8202#issuecomment-2317291483 func (m *HarborCli) build( ctx context.Context, + version string, ) []*dagger.Container { var builds []*dagger.Container fmt.Println("🛠️ Building with Dagger...") oses := []string{"linux", "darwin", "windows"} arches := []string{"amd64", "arm64"} + + // temp container with git installed + temp := dag.Container(). + From("alpine:latest"). + WithMountedDirectory("/src", m.Source). + // --no-cache option is to avoid caching the apk package index + WithExec([]string{"apk", "add", "--no-cache", "git"}). + WithWorkdir("/src") + + gitCommit, _ := temp.WithExec([]string{"git", "rev-parse", "--short", "HEAD", "--always"}).Stdout(ctx) + buildTime := time.Now().UTC().Format(time.RFC3339) + ldflagsArgs := fmt.Sprintf(`-X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.Version=%s + -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GoVersion=%s + -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.BuildTime=%s + -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GitCommit=%s + `, version, GO_VERSION, buildTime, gitCommit) + for _, goos := range oses { for _, goarch := range arches { bin_path := fmt.Sprintf("build/%s/%s/", goos, goarch) builder := dag.Container(). - From("golang:"+GO_VERSION). + From("golang:"+GO_VERSION+"-alpine"). WithMountedCache("/go/pkg/mod", dag.CacheVolume("go-mod-"+GO_VERSION)). WithEnvVariable("GOMODCACHE", "/go/pkg/mod"). WithMountedCache("/go/build-cache", dag.CacheVolume("go-build-"+GO_VERSION)). @@ -104,24 +122,12 @@ func (m *HarborCli) build( WithMountedDirectory("/src", m.Source). WithWorkdir("/src"). WithEnvVariable("GOOS", goos). - WithEnvVariable("GOARCH", goarch) - - version, _ := builder.WithExec([]string{"git", "describe", "--tags", "--abbrev=0"}).Stdout(ctx) - gitCommit, _ := builder.WithExec([]string{"git", "rev-parse", "--short", "HEAD"}).Stdout(ctx) - buildTime := time.Now().UTC().Format(time.RFC3339) - - ldflagsArgs := fmt.Sprintf(`-X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.Version=%s - -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GoVersion=%s - -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GitCommit=%s - -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.BuildTime=%s - `, version, GO_VERSION, buildTime, gitCommit) - - builder = builder.WithExec([]string{ - "go", "build", "-ldflags", ldflagsArgs, "-o", "bin/harbor-cli", "cmd/harbor/main.go", - }). + WithEnvVariable("GOARCH", goarch). + WithExec([]string{"go", "build", "-ldflags", ldflagsArgs, "-o", bin_path + "harbor", "/src/cmd/harbor/main.go"}). WithWorkdir(bin_path). WithExec([]string{"ls"}). WithEntrypoint([]string{"./harbor"}) + builds = append(builds, builder) } } @@ -143,7 +149,7 @@ func (m *HarborCli) Lint(ctx context.Context) (string, error) { return m.lint(ctx).WithExec([]string{"golangci-lint", "run"}).Stderr(ctx) } -func (m *HarborCli) lint(ctx context.Context) *dagger.Container { +func (m *HarborCli) lint(_ context.Context) *dagger.Container { fmt.Println("👀 Running linter and printing results to file golangci-lint.txt.") linter := dag.Container(). From("golangci/golangci-lint:"+GOLANGCILINT_VERSION+"-alpine"). @@ -163,7 +169,8 @@ func (m *HarborCli) PublishImage( imageTags []string, registryPassword *dagger.Secret, ) []string { - builders := m.build(ctx) + version := getVersion(imageTags) + builders := m.build(ctx, version) releaseImages := []*dagger.Container{} for i, tag := range imageTags { @@ -184,8 +191,11 @@ func (m *HarborCli) PublishImage( ctr := dag.Container(dagger.ContainerOpts{Platform: dagger.Platform(os + "/" + arch)}). From("alpine:latest"). + WithWorkdir("/"). WithFile("/harbor", builder.File("./harbor")). - WithEntrypoint([]string{"./harbor"}) + WithExec([]string{"ls", "-al"}). + WithExec([]string{"./harbor", "version"}). + WithEntrypoint([]string{"/harbor"}) releaseImages = append(releaseImages, ctr) } @@ -300,6 +310,15 @@ func parsePlatform(platform string) (string, string, error) { return parts[0], parts[1], nil } +func getVersion(tags []string) string { + for _, tag := range tags { + if strings.HasPrefix(tag, "v") { + return tag + } + } + return "latest" +} + // PublishImageAndSign builds and publishes container images to a registry with a specific tags and then signs them using Cosign. func (m *HarborCli) PublishImageAndSign( ctx context.Context,