Skip to content

chore: 🐝 Update SDK - Generate MISTRALAI MISTRALAI-SDK [speakeasy/mis… #84

chore: 🐝 Update SDK - Generate MISTRALAI MISTRALAI-SDK [speakeasy/mis…

chore: 🐝 Update SDK - Generate MISTRALAI MISTRALAI-SDK [speakeasy/mis… #84

name: Publish MISTRALAI-SDK
permissions:
contents: write
id-token: write
"on":
workflow_dispatch:
inputs:
confirm_publish:
description: 'Type "publish" to confirm.'
required: false
type: string
push:
branches:
- main
paths:
- RELEASES.md
jobs:
publish:
name: Publish Python SDKs to PyPI
# Auto-publish on push to main branch; require manual confirmation for workflow_dispatch
if: |
(github.event_name == 'push' && github.ref == 'refs/heads/main') ||
(github.event_name == 'workflow_dispatch' && github.event.inputs.confirm_publish == 'publish')
runs-on: ubuntu-24.04
environment:
name: publish
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: "3.12"
- name: Install uv
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
- name: Build mistralai
run: |
python scripts/prepare_readme.py
uv build --sdist --wheel --out-dir dist/mistralai
- name: Publish mistralai to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13
with:
packages-dir: dist/mistralai/
print-hash: true
verbose: true
skip-existing: true
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
VERSION=$(awk -F\" '/^version[[:space:]]*=/ {print $2; exit}' pyproject.toml)
if [ -z "$VERSION" ]; then
echo "Could not read version from pyproject.toml" >&2
exit 1
fi
echo "Detected version: $VERSION"
TAG="v${VERSION}"
INVOKE_TIME=$(date -u '+%Y-%m-%d %H:%M:%S')
BODY_FILE=$(mktemp)
{
printf '# Generated by Speakeasy CLI\n\n'
if [ -f RELEASES.md ]; then
awk '/^## /{buf=""} {buf=buf $0 "\n"} END{printf "%s", buf}' RELEASES.md
fi
printf '\nPublishing Completed\n'
} > "$BODY_FILE"
# PEP 440 prerelease tokens: aN / bN / rcN / .devN / .postN-with-dev
PRERELEASE_FLAG=""
if [[ "$VERSION" =~ (a|b|rc|\.dev)[0-9]+ ]]; then
PRERELEASE_FLAG="--prerelease"
fi
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
echo "Release $TAG already exists, skipping."
exit 0
fi
gh release create "$TAG" \
--repo "$GITHUB_REPOSITORY" \
--target "$GITHUB_SHA" \
--title "python - ${TAG} - ${INVOKE_TIME}" \
--notes-file "$BODY_FILE" \
$PRERELEASE_FLAG