diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d64a9658..eec00c86 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -5,30 +5,42 @@ on: # rebuild any PRs and main branch changes push: branches: - main + workflow_dispatch: + inputs: + go_sdk_version: + default: '' + type: string + typescript_sdk_version: + default: '' + type: string + java_sdk_version: + default: '' + type: string + python_sdk_version: + default: '' + type: string + dotnet_sdk_version: + default: '' + type: string concurrency: group: ${{ github.head_ref || github.run_id }} cancel-in-progress: true jobs: - latest-sdk-versions: - runs-on: 'ubuntu-latest' - outputs: - go_latest: '1.28.1' - typescript_latest: '1.10.3' - java_latest: '1.25.0' - python_latest: '1.7.0' - csharp_latest: '1.2.0' - steps: - - run: 'echo noop' - - # Build cli and harnesses + # Build cli and harnesses and get the latest SDK versions build-go: strategy: fail-fast: true matrix: os: [ubuntu-latest] # windows-latest - like 8x slower. Excluded for now since we're just building. runs-on: ${{ matrix.os }} + outputs: + go_latest: ${{ steps.latest_version.outputs.go_latest }} + typescript_latest: ${{ steps.latest_version.outputs.typescript_latest }} + java_latest: ${{ steps.latest_version.outputs.java_latest }} + python_latest: ${{ steps.latest_version.outputs.python_latest }} + csharp_latest: ${{ steps.latest_version.outputs.csharp_latest }} steps: - name: Print build information run: 'echo head_ref: "$GITHUB_HEAD_REF", ref: "$GITHUB_REF", os: ${{ matrix.os }}' @@ -39,6 +51,44 @@ jobs: - run: go build -o temporal-features + - name: Get the latest release version + id: latest_version + run: | + go_latest="${{ github.event.inputs.go_sdk_version }}" + if [ -z "$go_latest" ]; then + go_latest=$(./temporal-features latest-sdk-version --lang go) + echo "Derived latest Go SDK release version: $go_latest" + fi + echo "go_latest=$go_latest" >> $GITHUB_OUTPUT + + typescript_latest="${{ github.event.inputs.typescript_sdk_version }}" + if [ -z "$typescript_latest" ]; then + typescript_latest=$(./temporal-features latest-sdk-version --lang ts) + echo "Derived latest Typescript SDK release version: $typescript_latest" + fi + echo "typescript_latest=$typescript_latest" >> $GITHUB_OUTPUT + + java_latest="${{ github.event.inputs.java_sdk_version }}" + if [ -z "$java_latest" ]; then + java_latest=$(./temporal-features latest-sdk-version --lang java) + echo "Derived latest Java SDK release version: $java_latest" + fi + echo "java_latest=$java_latest" >> $GITHUB_OUTPUT + + python_latest="${{ github.event.inputs.python_sdk_version }}" + if [ -z "$python_latest" ]; then + python_latest=$(./temporal-features latest-sdk-version --lang py) + echo "Derived latest Python SDK release version: $python_latest" + fi + echo "python_latest=$python_latest" >> $GITHUB_OUTPUT + + csharp_latest="${{ github.event.inputs.dotnet_sdk_version }}" + if [ -z "$csharp_latest" ]; then + csharp_latest=$(./temporal-features latest-sdk-version --lang cs) + echo "Derived latest Dotnet SDK release version: $csharp_latest" + fi + echo "csharp_latest=$csharp_latest" >> $GITHUB_OUTPUT + build-ts: strategy: fail-fast: true @@ -106,59 +156,58 @@ jobs: - run: dotnet test feature-tests-ts: - needs: latest-sdk-versions + needs: build-go uses: ./.github/workflows/typescript.yaml with: - version: ${{ needs.latest-sdk-versions.outputs.typescript_latest }} + version: ${{ needs.build-go.outputs.typescript_latest }} version-is-repo-ref: false features-repo-ref: ${{ github.head_ref }} features-repo-path: ${{ github.event.pull_request.head.repo.full_name }} feature-tests-go: - needs: latest-sdk-versions + needs: build-go uses: ./.github/workflows/go.yaml with: - version: ${{ needs.latest-sdk-versions.outputs.go_latest }} + version: ${{ needs.build-go.outputs.go_latest }} version-is-repo-ref: false features-repo-ref: ${{ github.head_ref }} features-repo-path: ${{ github.event.pull_request.head.repo.full_name }} feature-tests-python: - needs: latest-sdk-versions + needs: build-go uses: ./.github/workflows/python.yaml with: - version: ${{ needs.latest-sdk-versions.outputs.python_latest }} + version: ${{ needs.build-go.outputs.python_latest }} version-is-repo-ref: false features-repo-ref: ${{ github.head_ref }} features-repo-path: ${{ github.event.pull_request.head.repo.full_name }} feature-tests-java: - needs: latest-sdk-versions + needs: build-go uses: ./.github/workflows/java.yaml with: - version: 'v${{ needs.latest-sdk-versions.outputs.java_latest }}' + version: 'v${{ needs.build-go.outputs.java_latest }}' version-is-repo-ref: false features-repo-ref: ${{ github.head_ref }} features-repo-path: ${{ github.event.pull_request.head.repo.full_name }} feature-tests-dotnet: - needs: latest-sdk-versions + needs: build-go uses: ./.github/workflows/dotnet.yaml with: - version: ${{ needs.latest-sdk-versions.outputs.csharp_latest }} + version: ${{ needs.build-go.outputs.csharp_latest }} version-is-repo-ref: false features-repo-ref: ${{ github.head_ref }} features-repo-path: ${{ github.event.pull_request.head.repo.full_name }} build-docker-images: - needs: latest-sdk-versions + needs: build-go uses: ./.github/workflows/all-docker-images.yaml secrets: inherit - # TODO: Find some way to automatically upgrade to "latest" with: do-push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - go-ver: 'v${{ needs.latest-sdk-versions.outputs.go_latest }}' - ts-ver: 'v${{ needs.latest-sdk-versions.outputs.typescript_latest }}' - java-ver: 'v${{ needs.latest-sdk-versions.outputs.java_latest }}' - py-ver: 'v${{ needs.latest-sdk-versions.outputs.python_latest }}' - cs-ver: 'v${{ needs.latest-sdk-versions.outputs.csharp_latest }}' + go-ver: 'v${{ needs.build-go.outputs.go_latest }}' + ts-ver: 'v${{ needs.build-go.outputs.typescript_latest }}' + java-ver: 'v${{ needs.build-go.outputs.java_latest }}' + py-ver: 'v${{ needs.build-go.outputs.python_latest }}' + cs-ver: 'v${{ needs.build-go.outputs.csharp_latest }}' diff --git a/cmd/build_image.go b/cmd/build_image.go index 8bf899de..aaf35ac4 100644 --- a/cmd/build_image.go +++ b/cmd/build_image.go @@ -21,7 +21,7 @@ func buildImageCmd() *cli.Command { var config ImageBuildConfig return &cli.Command{ Name: "build-image", - Usage: "build a 'prepared' single language docker image", + Usage: "Build a 'prepared' single language docker image", Flags: config.flags(), Action: func(ctx *cli.Context) error { return NewImageBuilder(config).BuildImage(ctx.Context) diff --git a/cmd/cmd.go b/cmd/cmd.go index 6f72f243..dfa42b73 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -30,6 +30,7 @@ func NewApp() *cli.App { runCmd(), buildImageCmd(), publishImageCmd(), + latestSdkVersionCmd(), }, } } diff --git a/cmd/latest_sdk_version.go b/cmd/latest_sdk_version.go new file mode 100644 index 00000000..b3b19030 --- /dev/null +++ b/cmd/latest_sdk_version.go @@ -0,0 +1,65 @@ +package cmd + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "strings" + + "github.com/urfave/cli/v2" +) + +func latestSdkVersionCmd() *cli.Command { + var config LatestSdkVersionConfig + return &cli.Command{ + Name: "latest-sdk-version", + Usage: "get the latest SDK version", + Flags: config.flags(), + Action: func(ctx *cli.Context) error { + return getLatestSdkVersion(config) + }, + } +} + +type LatestSdkVersionConfig struct { + Lang string +} + +func (p *LatestSdkVersionConfig) flags() []cli.Flag { + return []cli.Flag{ + langFlag(&p.Lang), + } +} + +func getLatestSdkVersion(config LatestSdkVersionConfig) error { + var sdk string + sdk, err := expandLangName(config.Lang) + if err != nil { + return err + } + + url := fmt.Sprintf("https://api.github.com/repos/temporalio/sdk-%s/releases/latest", sdk) + resp, err := http.Get(url) + if err != nil { + return fmt.Errorf("failed to query the GH API for SDK version: %w", err) + } + + defer resp.Body.Close() + body, err := io.ReadAll(resp.Body) + if err != nil { + return fmt.Errorf("failed to read body of GitHub Get request: %w", err) + } + + var version struct { + TagName string `json:"tag_name"` + } + err = json.Unmarshal(body, &version) + if err != nil { + return fmt.Errorf("failed to decode json response: %w", err) + } + + fmt.Println(strings.TrimPrefix(version.TagName, "v")) + + return nil +} diff --git a/cmd/prepare.go b/cmd/prepare.go index 3cf70d1c..08138d42 100644 --- a/cmd/prepare.go +++ b/cmd/prepare.go @@ -16,7 +16,7 @@ func prepareCmd() *cli.Command { var config PrepareConfig return &cli.Command{ Name: "prepare", - Usage: "prepare an SDK for execution", + Usage: "Prepare an SDK for execution", Flags: config.flags(), Action: func(ctx *cli.Context) error { return NewPreparer(config).Prepare(ctx.Context) diff --git a/cmd/push_images.go b/cmd/push_images.go index 94673f32..1824d1bd 100644 --- a/cmd/push_images.go +++ b/cmd/push_images.go @@ -13,7 +13,7 @@ func publishImageCmd() *cli.Command { var config PublishImageConfig return &cli.Command{ Name: "push-images", - Usage: "Push docker image(s) to our test repository. Used by CI.", + Usage: "Push docker image(s) to our test repository. Used by CI", Flags: config.flags(), Action: func(ctx *cli.Context) error { return publishImages(config) diff --git a/cmd/run.go b/cmd/run.go index 5e995d73..3ac022be 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -38,7 +38,7 @@ func runCmd() *cli.Command { var config RunConfig return &cli.Command{ Name: "run", - Usage: "run a test or set of tests", + Usage: "Run a test or set of tests", Flags: config.flags(), Action: func(ctx *cli.Context) error { return NewRunner(config).Run(ctx.Context, ctx.Args().Slice()) diff --git a/dotnet.csproj b/dotnet.csproj index dde1e3d9..5bf9be3b 100644 --- a/dotnet.csproj +++ b/dotnet.csproj @@ -23,7 +23,7 @@ - +