forked from VapiAI/docs
-
Notifications
You must be signed in to change notification settings - Fork 1
94 lines (80 loc) · 3.32 KB
/
release-python-sdk.yml
File metadata and controls
94 lines (80 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
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