From 012e80f357239d04b652275aa7adf5fdb88fb72d Mon Sep 17 00:00:00 2001 From: Nelson PROIA Date: Wed, 27 May 2026 15:16:03 +0200 Subject: [PATCH] ci: create GitHub Release after PyPI publish Restores tag + GitHub Release creation that was previously handled by the Speakeasy reusable workflow. Tag scheme matches what Speakeasy used (v). Release body is built from the latest entry in RELEASES.md so the format matches v1.x / v2.x releases through v2.4.5. PyPI publishing is atomic (no staging), so the release is created after gh-action-pypi-publish succeeds. Adds contents: write to the workflow permissions, required by gh release create. --- .../workflows/sdk_publish_mistralai_sdk.yaml | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sdk_publish_mistralai_sdk.yaml b/.github/workflows/sdk_publish_mistralai_sdk.yaml index cd1ba183..8d4d3f37 100644 --- a/.github/workflows/sdk_publish_mistralai_sdk.yaml +++ b/.github/workflows/sdk_publish_mistralai_sdk.yaml @@ -1,6 +1,6 @@ name: Publish MISTRALAI-SDK permissions: - contents: read + contents: write id-token: write "on": workflow_dispatch: @@ -48,3 +48,46 @@ jobs: 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