Skip to content

Commit fd4294c

Browse files
authored
Fix latest go sdk version to push the right images (temporalio#458)
1 parent 8462bd8 commit fd4294c

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

Diff for: .github/workflows/ci.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
latest-sdk-versions:
1515
runs-on: 'ubuntu-latest'
1616
outputs:
17-
go_latest: 'v1.26.1'
17+
go_latest: '1.26.1'
1818
typescript_latest: '1.9.3'
1919
java_latest: '1.23.0'
2020
python_latest: '1.4.0'
@@ -119,7 +119,7 @@ jobs:
119119
uses: ./.github/workflows/go.yaml
120120
with:
121121
version: ${{ needs.latest-sdk-versions.outputs.go_latest }}
122-
version-is-repo-ref: true
122+
version-is-repo-ref: false
123123
features-repo-ref: ${{ github.head_ref }}
124124
features-repo-path: ${{ github.event.pull_request.head.repo.full_name }}
125125

@@ -157,7 +157,7 @@ jobs:
157157
# TODO: Find some way to automatically upgrade to "latest"
158158
with:
159159
do-push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
160-
go-repo-ref: ${{ needs.latest-sdk-versions.outputs.go_latest }}
160+
go-ver: 'v${{ needs.latest-sdk-versions.outputs.go_latest }}'
161161
ts-ver: 'v${{ needs.latest-sdk-versions.outputs.typescript_latest }}'
162162
java-ver: 'v${{ needs.latest-sdk-versions.outputs.java_latest }}'
163163
py-ver: 'v${{ needs.latest-sdk-versions.outputs.python_latest }}'

Diff for: sdkbuild/go.go

+9-8
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ type BuildGoProgramOptions struct {
1818
// Directory that will have a temporary directory created underneath
1919
BaseDir string
2020
// If not set, not put in go.mod which means go mod tidy will automatically
21-
// use latest. If set and does not start with a "v", it is assumed to be a
22-
// path, otherwise it is a specific version.
21+
// use latest. If set and contains a slash, it is assumed to be a path,
22+
// otherwise it is a specific version (with leading "v" is trimmed if
23+
// present).
2324
Version string
2425
// The SDK Repository import to use. If unspecified we default to go.temporal.io/sdk
2526
// If specified version must also be provided
@@ -79,22 +80,22 @@ func BuildGoProgram(ctx context.Context, options BuildGoProgramOptions) (*GoProg
7980
goMod := options.GoModContents
8081
// If a version is specified, overwrite the SDK to use that
8182
if options.Version != "" || options.SDKRepository != "" {
82-
// If version does not start with a "v" we assume path unless the SDK repository is provided
83+
// If version has a "/" we assume path unless the SDK repository is provided
8384
if options.SDKRepository != "" {
8485
if options.Version == "" {
8586
return nil, errors.New("Version must be provided alongside SDKRepository")
8687
}
87-
goMod += fmt.Sprintf("\nreplace %s => %s %s", sdkImport, options.SDKRepository, options.Version)
88-
} else if strings.HasPrefix(options.Version, "v") {
89-
goMod += fmt.Sprintf("\nreplace %s => %s %s", sdkImport, sdkImport, options.Version)
88+
goMod += fmt.Sprintf("\nreplace %s => %s v%s", sdkImport, options.SDKRepository, strings.TrimPrefix(options.Version, "v"))
89+
} else if !strings.Contains(options.Version, "/") {
90+
goMod += fmt.Sprintf("\nreplace %s => %s v%s", sdkImport, sdkImport, strings.TrimPrefix(options.Version, "v"))
9091
} else {
9192
absVersion, err := filepath.Abs(options.Version)
9293
if err != nil {
93-
return nil, fmt.Errorf("version does not start with 'v' and cannot get abs dir: %w", err)
94+
return nil, fmt.Errorf("version has a '/' and cannot get abs dir: %w", err)
9495
}
9596
relVersion, err := filepath.Rel(dir, absVersion)
9697
if err != nil {
97-
return nil, fmt.Errorf("version does not start with 'v' and unable to relativize: %w", err)
98+
return nil, fmt.Errorf("version has a '/' and unable to relativize: %w", err)
9899
}
99100
goMod += fmt.Sprintf("\nreplace %s => %s", sdkImport, filepath.ToSlash(relVersion))
100101
}

0 commit comments

Comments
 (0)