Skip to content

Commit 6777ace

Browse files
GorshkovIvanIvan Gorshkovclaudemfbx9da4
authored
feat: install uv for newer python SDKs (#234)
* uv instalation added * Update action references to use v prefix: @15.37-uv → @v15.37-uv 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * new tag * install uv in workflows * uv versioning added * +35 -35 sdk-publish.yaml, sdk-test.yaml, tag.yaml and 1 more --------- Co-authored-by: Ivan Gorshkov <ivangorshkov@Mac.lan> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: David Alberto Adler <dalberto.adler@gmail.com>
1 parent 6400da4 commit 6777ace

File tree

5 files changed

+46
-0
lines changed

5 files changed

+46
-0
lines changed

.github/workflows/sdk-publish.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ on:
2929
description: "The version of poetry to use"
3030
required: false
3131
type: string
32+
uv_version:
33+
description: "The version of uv to use"
34+
required: false
35+
type: string
3236
target:
3337
description: "The specific target to publish"
3438
required: false
@@ -173,6 +177,10 @@ jobs:
173177
poetry --version
174178
env:
175179
POETRY_VERSION: ${{ inputs.poetry_version }}
180+
- name: Install uv
181+
uses: astral-sh/setup-uv@v6
182+
with:
183+
version: ${{ inputs.uv_version }}
176184
- name: Check for publish.sh
177185
id: check-publish
178186
run: |

.github/workflows/workflow-executor.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@ on:
9595
description: "Version of poetry to install. Not recommended for use without consulting Speakeasy support."
9696
required: false
9797
type: string
98+
uv_version:
99+
description: "Version of uv to install. Not recommended for use without consulting Speakeasy support."
100+
required: false
101+
type: string
98102
github_repository:
99103
description: "The GitHub repository path for the SDK. Eg: speakeasy-api/speakeasy-sdk-python"
100104
default: ""
@@ -236,6 +240,7 @@ jobs:
236240
cli_environment_variables: ${{ inputs.environment }}
237241
pnpm_version: ${{ inputs.pnpm_version }}
238242
poetry_version: ${{ inputs.poetry_version }}
243+
uv_version: ${{ inputs.uv_version }}
239244
github_repository: ${{ inputs.github_repository }}
240245
- uses: ravsamhq/notify-slack-action@v2
241246
if: ${{ steps.check-label.outputs.short_circuit_label_trigger != 'true' && env.SLACK_WEBHOOK_URL != '' }}
@@ -293,6 +298,10 @@ jobs:
293298
poetry --version
294299
env:
295300
POETRY_VERSION: ${{ inputs.poetry_version }}
301+
- name: Install uv
302+
uses: astral-sh/setup-uv@v6
303+
with:
304+
version: ${{ inputs.uv_version }}
296305
- name: Check for publish.sh
297306
id: check-publish
298307
run: |

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ inputs:
108108
poetry_version:
109109
description: "Version of poetry to install. Not recommended for use without consulting Speakeasy support."
110110
required: false
111+
uv_version:
112+
description: "Version of uv to install. Not recommended for use without consulting Speakeasy support."
113+
required: false
111114
github_repository:
112115
description: "The GitHub repository path for the SDK. Eg: speakeasy-api/speakeasy-sdk-python"
113116
default: ""

internal/actions/setup_environment.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ func SetupEnvironment() error {
1717
return err
1818
}
1919

20+
if err := installUv(); err != nil {
21+
return err
22+
}
23+
2024
if pnpmVersion := environment.GetPnpmVersion(); pnpmVersion != "" {
2125
pnpmPackageSpec := "pnpm@" + pnpmVersion
2226
cmd := exec.Command("npm", "install", "-g", pnpmPackageSpec)
@@ -46,3 +50,21 @@ func installPoetry() error {
4650

4751
return nil
4852
}
53+
54+
// Installs uv using pipx. If the INPUT_UV_VERSION environment variable
55+
// is set, it will install that version.
56+
func installUv() error {
57+
uvSpec := "uv"
58+
59+
if uvVersion := environment.GetUvVersion(); uvVersion != "" {
60+
uvSpec = "uv==" + uvVersion
61+
}
62+
63+
cmd := exec.Command("pipx", "install", "--global", uvSpec)
64+
65+
if err := cmd.Run(); err != nil {
66+
return fmt.Errorf("error installing uv: %w", err)
67+
}
68+
69+
return nil
70+
}

internal/environment/environment.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,10 @@ func GetPnpmVersion() string {
228228
return os.Getenv("INPUT_PNPM_VERSION")
229229
}
230230

231+
func GetUvVersion() string {
232+
return os.Getenv("INPUT_UV_VERSION")
233+
}
234+
231235
func GetWorkflowName() string {
232236
return os.Getenv("GITHUB_WORKFLOW")
233237
}

0 commit comments

Comments
 (0)