Skip to content

Commit 864ceca

Browse files
authored
Speakeasy update workflow (#254)
* Add the update_speakeasy.py script * Fix linter errors * Make it an invoke task * Rename scripts/update_speakeasy.py -> utils/speakeasy.py * Add GHA Workflow * Add missing permissions * Revert python >= 3.10
1 parent d4c691d commit 864ceca

File tree

8 files changed

+422
-63
lines changed

8 files changed

+422
-63
lines changed

.genignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pyproject.toml
22
examples/*
3+
/utils/*
34
src/mistral/extra/*
45
pylintrc
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
name: Update Speakeasy SDKs
2+
permissions:
3+
checks: write
4+
contents: write
5+
pull-requests: write
6+
statuses: write
7+
on:
8+
workflow_dispatch:
9+
inputs:
10+
version:
11+
description: 'Speakeasy version to update to (e.g., 1.580.2)'
12+
required: true
13+
type: string
14+
targets:
15+
description: 'Targets to update. If not provided, all targets will be updated.'
16+
type: choice
17+
options:
18+
- mistralai-sdk
19+
- mistralai-azure-sdk
20+
- mistralai-gcp-sdk
21+
22+
jobs:
23+
update-sdks:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
28+
29+
- name: Set up Python
30+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
31+
with:
32+
python-version: '3.11'
33+
34+
- name: Install Poetry
35+
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
36+
with:
37+
version: latest
38+
virtualenvs-create: true
39+
virtualenvs-in-project: true
40+
41+
- name: Install dependencies
42+
run: |
43+
poetry install --with dev
44+
45+
- name: Configure Git
46+
run: |
47+
git config --local user.email "[email protected]"
48+
git config --local user.name "GitHub Action"
49+
50+
- name: Create branch
51+
run: |
52+
git checkout -b update-speakeasy-to-${{ github.event.inputs.version }}-${{ github.run_id }}
53+
54+
- name: Update Speakeasy SDKs
55+
run: |
56+
# Split targets and build command with multiple --targets flags
57+
TARGETS_ARGS=""
58+
for target in ${{ github.event.inputs.targets }}; do
59+
TARGETS_ARGS="$TARGETS_ARGS --targets $target"
60+
done
61+
62+
poetry run inv update-speakeasy \
63+
--version "${{ github.event.inputs.version }}" \
64+
$TARGETS_ARGS
65+
66+
- name: Check for changes
67+
id: check-changes
68+
run: |
69+
if [ -n "$(git status --porcelain)" ]; then
70+
echo "has_changes=true" >> $GITHUB_OUTPUT
71+
echo "Files changed:"
72+
git status --porcelain
73+
else
74+
echo "has_changes=false" >> $GITHUB_OUTPUT
75+
echo "No changes detected"
76+
fi
77+
78+
- name: Commit and push changes
79+
if: steps.check-changes.outputs.has_changes == 'true'
80+
run: |
81+
git add .
82+
git commit -m "Update Speakeasy SDKs to version ${{ github.event.inputs.version }}
83+
84+
Targets updated: ${{ github.event.inputs.targets }}
85+
86+
This PR was automatically generated by the Update Speakeasy workflow."
87+
git push origin ${{ github.event.inputs.branch_name }}
88+
89+
- name: Create Pull Request
90+
if: steps.check-changes.outputs.has_changes == 'true'
91+
uses: peter-evans/create-pull-request@271a8d0340265f705b14b6d32b9829c1cb33d45e # v7.0.8
92+
with:
93+
token: ${{ secrets.GITHUB_TOKEN }}
94+
base: main
95+
branch: ${{ github.event.inputs.branch_name }}
96+
title: "Update Speakeasy SDKs to version ${{ github.event.inputs.version }}"
97+
body: |
98+
## Summary
99+
100+
This PR updates the Speakeasy SDKs to version `${{ github.event.inputs.version }}`.
101+
102+
## Changes
103+
104+
- **Version**: Updated to `${{ github.event.inputs.version }}`
105+
- **Targets**: ${{ github.event.inputs.targets }}
106+
107+
## Files Updated
108+
109+
The following SDK files have been regenerated:
110+
- Generated SDK code files
111+
- Updated dependencies and configurations
112+
113+
## How to Review
114+
115+
1. Check that the generated files look correct
116+
2. Verify that the version update is appropriate
117+
3. Ensure all target SDKs are properly updated
118+
119+
---
120+
121+
*This PR was automatically generated by the [Update Speakeasy workflow](.github/workflows/update_speakeasy.yaml)*
122+
labels: automated
123+
assignees: ${{ github.actor }}
124+
125+
- name: Comment on workflow run
126+
if: steps.check-changes.outputs.has_changes == 'false'
127+
run: |
128+
echo "No changes were detected. The SDKs are already up to date with version ${{ github.event.inputs.version }}."

0 commit comments

Comments
 (0)