Release Python SDK #27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release Python SDK | |
| on: | |
| workflow_call: | |
| inputs: | |
| makePR: | |
| description: Make Pull Request | |
| default: false | |
| type: boolean | |
| version: | |
| description: "The version of the Python SDK that you would like to release (optional - will auto-increment patch version if not provided)" | |
| required: false | |
| type: string | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "The version of the Python SDK that you would like to release (optional - will auto-increment patch version if not provided)" | |
| required: false | |
| type: string | |
| makePR: | |
| description: Make Pull Request | |
| required: true | |
| default: false | |
| type: boolean | |
| jobs: | |
| determine-version: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.version }} | |
| steps: | |
| - name: Determine version | |
| id: version | |
| run: | | |
| if [ -n "${{ inputs.version }}" ]; then | |
| echo "Using provided version: ${{ inputs.version }}" | |
| echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "Fetching latest version from VapiAI/server-sdk-python..." | |
| # Fetch latest release version from the Python SDK repository | |
| LATEST_VERSION=$(curl -s https://api.github.com/repos/VapiAI/server-sdk-python/releases/latest | jq -r .tag_name || echo "") | |
| # If no release found, check tags | |
| if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then | |
| echo "No release found, checking tags..." | |
| LATEST_VERSION=$(curl -s https://api.github.com/repos/VapiAI/server-sdk-python/tags | jq -r '.[0].name' || echo "") | |
| fi | |
| # If still no version found, default to 0.0.0 | |
| if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then | |
| echo "No version found, defaulting to v0.0.0" | |
| LATEST_VERSION="v0.0.0" | |
| fi | |
| # Remove 'v' prefix if present | |
| LATEST_VERSION=${LATEST_VERSION#v} | |
| echo "Latest version: $LATEST_VERSION" | |
| # Parse version components | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION" | |
| # Increment patch version | |
| NEW_PATCH=$((PATCH + 1)) | |
| NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}" | |
| echo "New version: $NEW_VERSION" | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| fi | |
| release: | |
| needs: determine-version | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v3 | |
| - name: Setup node | |
| uses: actions/setup-node@v3 | |
| - name: Download Fern | |
| run: npm install -g fern-api | |
| - name: Release Python SDK | |
| env: | |
| FERN_TOKEN: ${{ secrets.FERN_TOKEN }} | |
| PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} | |
| run: | | |
| if [ "${{ github.event.inputs.makePR }}" = "true" ]; then | |
| fern generate --api api --group python-sdk --version ${{ needs.determine-version.outputs.version }} --mode pull-request --log-level debug | |
| else | |
| fern generate --api api --group python-sdk --version ${{ needs.determine-version.outputs.version }} --log-level debug | |
| fi |