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