Skip to content

Update Speakeasy SDKs #18

Update Speakeasy SDKs

Update Speakeasy SDKs #18

name: Update Speakeasy SDKs
permissions:
checks: write
contents: write
pull-requests: write
statuses: write
on:
workflow_dispatch:
inputs:
version:
description: 'Speakeasy version to update to (e.g., 1.580.2)'
required: true
type: string
targets:
description: 'Targets to update.'
required: true
type: choice
options:
- mistralai-sdk
- mistralai-azure-sdk
- mistralai-gcp-sdk
- all
jobs:
update-sdks:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4.3.0
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: '3.11'
- name: Install Poetry
uses: snok/install-poetry@76e04a911780d5b312d89783f7b1cd627778900a # v1.4.1
with:
version: latest
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install dependencies
run: |
cp README.md README-PYPI.md
poetry install --with dev
- name: Install Speakeasy CLI
run: |
curl -fsSL https://go.speakeasy.com/cli-install.sh | sh
speakeasy --version
- name: Configure Git
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git config --local --type bool push.autoSetupRemote true
- name: Create branch
run: |
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
echo "TIMESTAMP=$TIMESTAMP" >> $GITHUB_ENV
git checkout -b update-speakeasy-to-${{ github.event.inputs.version }}-$TIMESTAMP
- name: Update Speakeasy SDKs
run: |
# Split targets and build command with multiple --targets flags
TARGETS_ARGS=""
for target in ${{ github.event.inputs.targets }}; do
TARGETS_ARGS="$TARGETS_ARGS --targets $target"
done
poetry run inv update-speakeasy \
--version "${{ github.event.inputs.version }}" \
$TARGETS_ARGS
env:
SPEAKEASY_API_KEY: ${{ secrets.SPEAKEASY_API_KEY }}
- name: Check for changes
id: check-changes
run: |
if [ -n "$(git status --porcelain)" ]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "Files changed:"
git status --porcelain
else
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No changes detected"
fi
- name: Commit and push changes
if: steps.check-changes.outputs.has_changes == 'true'
run: |
git add .
git commit -m "Update Speakeasy SDKs to version ${{ github.event.inputs.version }}"
git push origin update-speakeasy-to-${{ github.event.inputs.version }}-${{ env.TIMESTAMP }}
- name: Create Pull Request
if: steps.check-changes.outputs.has_changes == 'true'
run: |
gh pr create \
--base main \
--head update-speakeasy-to-${{ github.event.inputs.version }}-${{ env.TIMESTAMP }} \
--title "Update Speakeasy SDKs to version ${{ github.event.inputs.version }}" \
--body "This PR updates the Speakeasy SDKs to version ${{ github.event.inputs.version }}. It was automatically generated by the [Update Speakeasy workflow](.github/workflows/update_speakeasy.yaml)." \
--label automated \
--label speakeasy-update \
--assignee ${{ github.actor }}
env:
GITHUB_TOKEN: ${{ secrets.SPEAKEASY_WORKFLOW_GITHUB_PAT }}
- name: Comment on workflow run
if: steps.check-changes.outputs.has_changes == 'false'
run: |
echo "No changes were detected. The SDKs are already up to date with version ${{ github.event.inputs.version }}."