Skip to content

Commit 43fec2d

Browse files
authored
ci: create GitHub Release after PyPI publish (#555)
Restores tag + GitHub Release creation that was previously handled by the Speakeasy reusable workflow. Tag scheme matches what Speakeasy used (v<version>). 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.
1 parent 784334a commit 43fec2d

1 file changed

Lines changed: 44 additions & 1 deletion

File tree

.github/workflows/sdk_publish_mistralai_sdk.yaml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Publish MISTRALAI-SDK
22
permissions:
3-
contents: read
3+
contents: write
44
id-token: write
55
"on":
66
workflow_dispatch:
@@ -48,3 +48,46 @@ jobs:
4848
print-hash: true
4949
verbose: true
5050
skip-existing: true
51+
52+
- name: Create GitHub Release
53+
env:
54+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
run: |
56+
set -euo pipefail
57+
58+
VERSION=$(awk -F\" '/^version[[:space:]]*=/ {print $2; exit}' pyproject.toml)
59+
if [ -z "$VERSION" ]; then
60+
echo "Could not read version from pyproject.toml" >&2
61+
exit 1
62+
fi
63+
echo "Detected version: $VERSION"
64+
65+
TAG="v${VERSION}"
66+
INVOKE_TIME=$(date -u '+%Y-%m-%d %H:%M:%S')
67+
68+
BODY_FILE=$(mktemp)
69+
{
70+
printf '# Generated by Speakeasy CLI\n\n'
71+
if [ -f RELEASES.md ]; then
72+
awk '/^## /{buf=""} {buf=buf $0 "\n"} END{printf "%s", buf}' RELEASES.md
73+
fi
74+
printf '\nPublishing Completed\n'
75+
} > "$BODY_FILE"
76+
77+
# PEP 440 prerelease tokens: aN / bN / rcN / .devN / .postN-with-dev
78+
PRERELEASE_FLAG=""
79+
if [[ "$VERSION" =~ (a|b|rc|\.dev)[0-9]+ ]]; then
80+
PRERELEASE_FLAG="--prerelease"
81+
fi
82+
83+
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
84+
echo "Release $TAG already exists, skipping."
85+
exit 0
86+
fi
87+
88+
gh release create "$TAG" \
89+
--repo "$GITHUB_REPOSITORY" \
90+
--target "$GITHUB_SHA" \
91+
--title "python - ${TAG} - ${INVOKE_TIME}" \
92+
--notes-file "$BODY_FILE" \
93+
$PRERELEASE_FLAG

0 commit comments

Comments
 (0)