Skip to content

Commit 4c343a6

Browse files
committed
update go releaser
Signed-off-by: bupd <[email protected]>
1 parent fbf63d0 commit 4c343a6

File tree

5 files changed

+32
-137
lines changed

5 files changed

+32
-137
lines changed

.github/workflows/docker_publish.yml

+2-27
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
11
name: Docker Publish
22

33
on:
4-
release:
5-
types: [published]
64
push:
75
tags:
86
- "v*"
97

108
jobs:
11-
github-get-tags:
12-
runs-on: ubuntu-latest
13-
environment: production
14-
steps:
15-
- name: GitHub Tag Name example
16-
run: |
17-
echo "Tag name from GITHUB_REF_NAME: $GITHUB_REF_NAME"
18-
echo "Tag name from github.ref_name: ${{ github.ref_name }}"
19-
echo "cosign password: ${{ secrets.COSIGN_PASSWORD }}"
20-
echo "reg password: ${{ secrets.REGISTRY_PASSWORD }}"
21-
echo "reg password: ${{ secrets.doesnotexist }}"
22-
echo "reg username: ${{ env.REGISTRY_USERNAME }}"
23-
echo "publish publish-address: ${{ vars.PUBLISH_ADDRESS }}"
249
docker-publish:
2510
runs-on: ubuntu-latest
2611
permissions:
@@ -32,21 +17,11 @@ jobs:
3217
COSIGN_KEY: ${{ secrets.COSIGN_KEY }}
3318
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
3419
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
20+
REGISTRY_ADDRESS: ${{ vars.REGISTRY_ADDRESS }}
3521
PUBLISH_ADDRESS: ${{ vars.PUBLISH_ADDRESS }}
3622
TAG: ${{ github.ref_name }}
3723

3824
steps:
39-
- name: Debugging
40-
run: |
41-
echo "COSIGN_KEY: ${{ secrets.COSIGN_KEY }}"
42-
echo "COSIGN_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}"
43-
echo "REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}"
44-
echo "REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}"
45-
echo "PUBLISH_ADDRESS: ${{ env.PUBLISH_ADDRESS }}"
46-
echo "TAG: ${{ env.TAG }}"
47-
echo "Environment Variables:"
48-
env # List all environment variables for debugging
49-
5025
- name: Checkout repo
5126
uses: actions/checkout@v4
5227
with:
@@ -57,4 +32,4 @@ jobs:
5732
with:
5833
version: "latest"
5934
verb: call
60-
args: "publish-image --source=. --cosign-password='${{ env.COSIGN_PASSWORD }}' --cosign-key='${{ env.COSIGN_KEY }}' --reg-username='${{ env.REGISTRY_USERNAME }}' --reg-password='${{ env.REGISTRY_PASSWORD }}' --publish-address='${{ env.PUBLISH_ADDRESS }}' --tag='${{ env.TAG }}'"
35+
args: "publish-image --source=. --cosign-password='${{ env.COSIGN_PASSWORD }}' --cosign-key='${{ env.COSIGN_KEY }}' --reg-username='${{ env.REGISTRY_USERNAME }}' --reg-password='${{ env.REGISTRY_PASSWORD }}' --reg-address='${{ env.REGISTRY_ADDRESS }}' --publish-address='${{ env.PUBLISH_ADDRESS }}' --tag='${{ env.TAG }}'"

.goreleaser.yaml

+17-10
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
1+
version: 2
12
project_name: harbor
23

34
before:
45
hooks:
56
- go mod tidy
6-
7+
78
builds:
89
- main: ./cmd/harbor/main.go
910

1011
env:
11-
- CGO_ENABLED=0
12+
- CGO_ENABLED=0
1213
ldflags:
1314
- -w -s -X github.com/goharbor/harbor-cli/cmd/harbor/internal/version.GitCommit={{.FullCommit}}
1415
goos:
@@ -18,7 +19,7 @@ builds:
1819
goarch:
1920
- amd64
2021
- arm64
21-
ignore:
22+
ignore:
2223
- goos: windows
2324
goarch: arm
2425
- goos: windows
@@ -46,21 +47,27 @@ sboms:
4647

4748
checksum:
4849
name_template: 'checksums.txt'
49-
snapshot:
50-
name_template: "{{ .Tag }}-next"
50+
snapshot:
51+
version_template: "{{ .Tag }}-next"
5152
release:
5253
name_template: "HarborCLI {{.Tag}}"
53-
# draft: true
54-
# prerelease: auto
55-
54+
draft: false # Set to false to ensure that releases are published, not kept as drafts
55+
prerelease: auto # Auto-detect prereleases based on tag
56+
disable: false # Ensure release publishing is enabled
57+
github:
58+
owner: bupd # Your GitHub repository owner
59+
name: harbor-cli # Your GitHub repository name
60+
5661
changelog:
57-
sort: asc
5862
use: github
63+
format: "{{.SHA}}: {{.Message}} (@{{.AuthorUsername}})"
64+
sort: asc
5965
filters:
6066
exclude:
6167
- "^docs:"
6268
- "^test:"
6369
- "merge conflict"
70+
6471
groups:
6572
- title: Dependency updates
6673
regexp: '^.*?(.+)\(deps\)!?:.+$'
@@ -81,4 +88,4 @@ changelog:
8188
regexp: ^.*?(build|ci)(\(.+\))??!?:.+$
8289
order: 400
8390
- title: Other work
84-
order: 9999
91+
order: 9999

dagger/main.go

+7-24
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const (
1111
GOLANGCILINT_VERSION = "v1.61.0"
1212
GO_VERSION = "1.22.5"
1313
SYFT_VERSION = "v1.9.0"
14-
GORELEASER_VERSION = "v2.1.0"
14+
GORELEASER_VERSION = "v2.3.2"
1515
)
1616

1717
type HarborCli struct{}
@@ -89,7 +89,7 @@ func (m *HarborCli) Release(
8989
source *dagger.Directory,
9090
githubToken string,
9191
) {
92-
goreleaser := goreleaserContainer(source, githubToken).WithExec([]string{"release", "--clean"})
92+
goreleaser := goreleaserContainer(source, githubToken).WithExec([]string{"ls", "-la"}).WithExec([]string{"goreleaser", "release", "--clean"})
9393
_, err := goreleaser.Stderr(ctx)
9494
if err != nil {
9595
log.Printf("Error occured during release: %s", err)
@@ -114,6 +114,7 @@ func (m *HarborCli) PublishImage(
114114
cosignPassword string,
115115
regUsername string,
116116
regPassword string,
117+
regAddress string,
117118
publishAddress string,
118119
tag string,
119120
) string {
@@ -144,42 +145,24 @@ func (m *HarborCli) PublishImage(
144145
}
145146
}
146147

147-
// // Create a builder container for multi-architecture images
148-
// multiArchBuilder := dag.Container().
149-
// From("docker/buildx:latest").
150-
// WithWorkdir("/workspace")
151-
//
152-
// // Add binaries for each OS and architecture to the multi-arch image
153-
// oses := []string{"linux", "darwin", "windows"}
154-
// arches := []string{"amd64", "arm64"}
155-
//
156-
// for _, goos := range oses {
157-
// for _, goarch := range arches {
158-
// binPath := fmt.Sprintf("build/%s/%s/harbor", goos, goarch)
159-
// multiArchBuilder = multiArchBuilder.WithFile(fmt.Sprintf("/workspace/%s/%s/harbor", goos, goarch), builder.File(binPath))
160-
// }
161-
// }
162-
163-
// Build the multi-architecture image
164-
// multiArchImage := fmt.Sprintf("%s:%s", publishAddress, tag)
165-
166148
cosign_key := dag.SetSecret("cosign_key", cosignKey)
167149
cosign_password := dag.SetSecret("cosign_password", cosignPassword)
168150
regpassword := dag.SetSecret("reg_password", regPassword)
169151

152+
publisher := cli_runtime.WithRegistryAuth(regAddress, regUsername, regpassword)
170153
// Push the versioned tag
171154
versionedAddress := fmt.Sprintf("%s:%s", publishAddress, tag)
172-
addr, err := cli_runtime.Publish(ctx, versionedAddress, dagger.ContainerPublishOpts{PlatformVariants: filteredBuilders})
155+
addr, err := publisher.Publish(ctx, versionedAddress, dagger.ContainerPublishOpts{PlatformVariants: filteredBuilders})
173156
if err != nil {
174157
panic(err)
175158
}
176-
177159
// Push the latest tag
178160
latestAddress := fmt.Sprintf("%s:latest", publishAddress)
179-
addr, err = cli_runtime.Publish(ctx, latestAddress)
161+
addr, err = publisher.Publish(ctx, latestAddress)
180162
if err != nil {
181163
panic(err)
182164
}
165+
183166
_, err = dag.Cosign().Sign(ctx, cosign_key, cosign_password, []string{addr}, dagger.CosignSignOpts{RegistryUsername: regUsername, RegistryPassword: regpassword})
184167
if err != nil {
185168
panic(err)

go.mod

+6-25
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ require (
1111
github.com/spf13/cobra v1.8.1
1212
github.com/spf13/viper v1.19.0
1313
github.com/stretchr/testify v1.9.0
14-
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56
15-
golang.org/x/sync v0.8.0
1614
)
1715

1816
require (
@@ -42,6 +40,7 @@ require (
4240
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
4341
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
4442
github.com/rivo/uniseg v0.4.7 // indirect
43+
github.com/rogpeppe/go-internal v1.12.0 // indirect
4544
github.com/sagikazarmark/locafero v0.6.0 // indirect
4645
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
4746
github.com/sahilm/fuzzy v0.1.1 // indirect
@@ -51,15 +50,14 @@ require (
5150
github.com/subosito/gotenv v1.6.0 // indirect
5251
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
5352
go.uber.org/multierr v1.11.0 // indirect
53+
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
54+
golang.org/x/sync v0.8.0 // indirect
5455
gopkg.in/ini.v1 v1.67.0 // indirect
5556
gopkg.in/yaml.v3 v3.0.1 // indirect
5657
)
5758

5859
require (
59-
github.com/99designs/gqlgen v0.17.49
60-
github.com/Khan/genqlient v0.7.0
6160
github.com/asaskevich/govalidator v0.0.0-20230301143203-a9d515a09cc2 // indirect
62-
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
6361
github.com/go-logr/logr v1.4.2 // indirect
6462
github.com/go-logr/stdr v1.2.2 // indirect
6563
github.com/go-openapi/analysis v0.23.0 // indirect
@@ -74,37 +72,20 @@ require (
7472
github.com/go-openapi/validate v0.24.0 // indirect
7573
github.com/goharbor/go-client v0.210.0
7674
github.com/google/uuid v1.6.0 // indirect
77-
github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect
7875
github.com/inconshreveable/mousetrap v1.1.0 // indirect
7976
github.com/josharian/intern v1.0.0 // indirect
8077
github.com/mailru/easyjson v0.7.7 // indirect
8178
github.com/mitchellh/mapstructure v1.5.0 // indirect
8279
github.com/oklog/ulid v1.3.1 // indirect
8380
github.com/opentracing/opentracing-go v1.2.0 // indirect
84-
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
85-
github.com/sosodev/duration v1.3.1 // indirect
8681
github.com/spf13/pflag v1.0.5 // indirect
87-
github.com/vektah/gqlparser/v2 v2.5.16
8882
go.mongodb.org/mongo-driver v1.16.0 // indirect
89-
go.opentelemetry.io/otel v1.28.0
90-
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240726164100-16a4e332762c
91-
go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.4.0
92-
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.28.0 // indirect
93-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.28.0
94-
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.28.0
95-
go.opentelemetry.io/otel/log v0.4.0
83+
go.opentelemetry.io/otel v1.28.0 // indirect
9684
go.opentelemetry.io/otel/metric v1.28.0 // indirect
97-
go.opentelemetry.io/otel/sdk v1.28.0
98-
go.opentelemetry.io/otel/sdk/log v0.4.0
99-
go.opentelemetry.io/otel/trace v1.28.0
100-
go.opentelemetry.io/proto/otlp v1.3.1
101-
golang.org/x/net v0.29.0 // indirect
85+
go.opentelemetry.io/otel/sdk v1.28.0 // indirect
86+
go.opentelemetry.io/otel/trace v1.28.0 // indirect
10287
golang.org/x/sys v0.25.0 // indirect
10388
golang.org/x/text v0.18.0 // indirect
104-
google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect
105-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
106-
google.golang.org/grpc v1.65.0
107-
google.golang.org/protobuf v1.34.2 // indirect
10889
)
10990

11091
replace go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc => go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88

0 commit comments

Comments
 (0)