Skip to content

Commit 7232d96

Browse files
add auto version for go & python
1 parent e16590c commit 7232d96

File tree

4 files changed

+172
-72
lines changed

4 files changed

+172
-72
lines changed

.actrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# act configuration file
2+
-P ubuntu-latest=catthehacker/ubuntu:act-latest
3+
--container-architecture linux/amd64

.github/workflows/release-all.yml

Lines changed: 63 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,76 @@
1-
name: Release all SDKs
1+
# This is deprecated - use the individual release workflows instead
2+
# this is wrong because SDK don't just have one version, they have multiple versions
23

3-
on:
4-
workflow_dispatch:
5-
inputs:
6-
version:
7-
description: "The version of the Go SDK that you would like to release"
8-
required: true
9-
type: string
4+
# name: Release all SDKs
105

11-
env:
12-
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
13-
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
14-
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
15-
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
16-
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
17-
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
18-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
6+
# on:
7+
# workflow_dispatch:
8+
# inputs:
9+
# version:
10+
# description: "The version of the Go SDK that you would like to release"
11+
# required: true
12+
# type: string
1913

20-
jobs:
21-
csharp:
22-
uses: ./.github/workflows/release-csharp-sdk.yml
23-
secrets: inherit
24-
with:
25-
version: ${{ inputs.version }}
14+
# env:
15+
# FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
16+
# NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
17+
# MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
18+
# MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
19+
# PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
20+
# RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
21+
# NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
22+
23+
# jobs:
24+
# csharp:
25+
# uses: ./.github/workflows/release-csharp-sdk.yml
26+
# secrets: inherit
27+
# with:
28+
# version: ${{ inputs.version }}
2629

27-
go:
28-
uses: ./.github/workflows/release-go-sdk.yml
29-
secrets: inherit
30-
with:
31-
version: ${{ inputs.version }}
30+
# go:
31+
# uses: ./.github/workflows/release-go-sdk.yml
32+
# secrets: inherit
33+
# with:
34+
# version: ${{ inputs.version }}
3235

33-
java:
34-
uses: ./.github/workflows/release-java-sdk.yml
35-
secrets: inherit
36-
with:
37-
version: ${{ inputs.version }}
36+
# java:
37+
# uses: ./.github/workflows/release-java-sdk.yml
38+
# secrets: inherit
39+
# with:
40+
# version: ${{ inputs.version }}
3841

39-
python:
40-
uses: ./.github/workflows/release-python-sdk.yml
41-
secrets: inherit
42-
with:
43-
version: ${{ inputs.version }}
42+
# python:
43+
# uses: ./.github/workflows/release-python-sdk.yml
44+
# secrets: inherit
45+
# with:
46+
# version: ${{ inputs.version }}
4447

45-
ruby:
46-
uses: ./.github/workflows/release-ruby-sdk.yml
47-
secrets: inherit
48-
with:
49-
version: ${{ inputs.version }}
48+
# ruby:
49+
# uses: ./.github/workflows/release-ruby-sdk.yml
50+
# secrets: inherit
51+
# with:
52+
# version: ${{ inputs.version }}
5053

51-
ts:
52-
uses: ./.github/workflows/release-ts-sdk.yml
53-
secrets: inherit
54-
with:
55-
version: ${{ inputs.version }}
54+
# ts:
55+
# uses: ./.github/workflows/release-ts-sdk.yml
56+
# secrets: inherit
57+
# with:
58+
# version: ${{ inputs.version }}
5659

57-
generate-docs:
58-
needs: [csharp, go, java, python, ruby, ts]
59-
runs-on: ubuntu-latest
60-
steps:
61-
- uses: actions/checkout@v4
60+
# generate-docs:
61+
# needs: [csharp, go, java, python, ruby, ts]
62+
# runs-on: ubuntu-latest
63+
# steps:
64+
# - uses: actions/checkout@v4
6265

63-
- name: Setup Node.js
64-
uses: actions/setup-node@v4
66+
# - name: Setup Node.js
67+
# uses: actions/setup-node@v4
6568

66-
- name: Install Fern
67-
run: npm install -g fern-api
69+
# - name: Install Fern
70+
# run: npm install -g fern-api
6871

69-
- name: Generate Documentation
70-
run: fern generate --docs
71-
env:
72-
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
72+
# - name: Generate Documentation
73+
# run: fern generate --docs
74+
# env:
75+
# FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
7376

.github/workflows/release-go-sdk.yml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ on:
88
default: false
99
type: boolean
1010
version:
11-
description: "The version of the C# SDK that you would like to release"
12-
required: true
11+
description: "The version of the Go SDK that you would like to release (optional - will auto-increment patch version if not provided)"
12+
required: false
1313
type: string
1414
workflow_dispatch:
1515
inputs:
1616
version:
17-
description: "The version of the Go SDK that you would like to release"
18-
required: true
17+
description: "The version of the Go SDK that you would like to release (optional - will auto-increment patch version if not provided)"
18+
required: false
1919
type: string
2020
makePR:
2121
description: Make Pull Request
@@ -24,7 +24,53 @@ on:
2424
type: boolean
2525

2626
jobs:
27+
determine-version:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
version: ${{ steps.version.outputs.version }}
31+
steps:
32+
- name: Determine version
33+
id: version
34+
run: |
35+
if [ -n "${{ inputs.version }}" ]; then
36+
echo "Using provided version: ${{ inputs.version }}"
37+
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
38+
else
39+
echo "Fetching latest version from VapiAI/server-sdk-go..."
40+
41+
# Fetch latest release version from the Go SDK repository
42+
LATEST_VERSION=$(curl -s https://api.github.com/repos/VapiAI/server-sdk-go/releases/latest | jq -r .tag_name || echo "")
43+
44+
# If no release found, check tags
45+
if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then
46+
echo "No release found, checking tags..."
47+
LATEST_VERSION=$(curl -s https://api.github.com/repos/VapiAI/server-sdk-go/tags | jq -r '.[0].name' || echo "")
48+
fi
49+
50+
# If still no version found, default to 0.0.0
51+
if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then
52+
echo "No version found, defaulting to v0.0.0"
53+
LATEST_VERSION="v0.0.0"
54+
fi
55+
56+
# Remove 'v' prefix if present
57+
LATEST_VERSION=${LATEST_VERSION#v}
58+
59+
echo "Latest version: $LATEST_VERSION"
60+
61+
# Parse version components
62+
IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION"
63+
64+
# Increment patch version
65+
NEW_PATCH=$((PATCH + 1))
66+
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
67+
68+
echo "New version: $NEW_VERSION"
69+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
70+
fi
71+
2772
release:
73+
needs: determine-version
2874
runs-on: ubuntu-latest
2975
steps:
3076
- name: Checkout repo
@@ -41,7 +87,9 @@ jobs:
4187
FERN_TOKEN: ${{ secrets.FERN_TOKEN }}
4288
run: |
4389
if [ "${{ github.event.inputs.makePR }}" = "true" ]; then
44-
fern generate --api api --group go-sdk --version ${{ inputs.version }} --mode pull-request --log-level debug
90+
echo "Generating Go SDK for version ${{ needs.determine-version.outputs.version }} in pull request mode"
91+
fern generate --api api --group go-sdk --version ${{ needs.determine-version.outputs.version }} --mode pull-request --log-level debug
4592
else
46-
fern generate --api api --group go-sdk --version ${{ inputs.version }} --log-level debug
93+
echo "Generating Go SDK for version ${{ needs.determine-version.outputs.version }}"
94+
fern generate --api api --group go-sdk --version ${{ needs.determine-version.outputs.version }} --log-level debug
4795
fi

.github/workflows/release-python-sdk.yml

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ on:
88
default: false
99
type: boolean
1010
version:
11-
description: "The version of the C# SDK that you would like to release"
12-
required: true
11+
description: "The version of the Python SDK that you would like to release (optional - will auto-increment patch version if not provided)"
12+
required: false
1313
type: string
1414
workflow_dispatch:
1515
inputs:
1616
version:
17-
description: "The version of the Python SDK that you would like to release"
18-
required: true
17+
description: "The version of the Python SDK that you would like to release (optional - will auto-increment patch version if not provided)"
18+
required: false
1919
type: string
2020
makePR:
2121
description: Make Pull Request
@@ -24,7 +24,53 @@ on:
2424
type: boolean
2525

2626
jobs:
27+
determine-version:
28+
runs-on: ubuntu-latest
29+
outputs:
30+
version: ${{ steps.version.outputs.version }}
31+
steps:
32+
- name: Determine version
33+
id: version
34+
run: |
35+
if [ -n "${{ inputs.version }}" ]; then
36+
echo "Using provided version: ${{ inputs.version }}"
37+
echo "version=${{ inputs.version }}" >> $GITHUB_OUTPUT
38+
else
39+
echo "Fetching latest version from VapiAI/server-sdk-python..."
40+
41+
# Fetch latest release version from the Python SDK repository
42+
LATEST_VERSION=$(curl -s https://api.github.com/repos/VapiAI/server-sdk-python/releases/latest | jq -r .tag_name || echo "")
43+
44+
# If no release found, check tags
45+
if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then
46+
echo "No release found, checking tags..."
47+
LATEST_VERSION=$(curl -s https://api.github.com/repos/VapiAI/server-sdk-python/tags | jq -r '.[0].name' || echo "")
48+
fi
49+
50+
# If still no version found, default to 0.0.0
51+
if [ -z "$LATEST_VERSION" ] || [ "$LATEST_VERSION" = "null" ]; then
52+
echo "No version found, defaulting to v0.0.0"
53+
LATEST_VERSION="v0.0.0"
54+
fi
55+
56+
# Remove 'v' prefix if present
57+
LATEST_VERSION=${LATEST_VERSION#v}
58+
59+
echo "Latest version: $LATEST_VERSION"
60+
61+
# Parse version components
62+
IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_VERSION"
63+
64+
# Increment patch version
65+
NEW_PATCH=$((PATCH + 1))
66+
NEW_VERSION="${MAJOR}.${MINOR}.${NEW_PATCH}"
67+
68+
echo "New version: $NEW_VERSION"
69+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
70+
fi
71+
2772
release:
73+
needs: determine-version
2874
runs-on: ubuntu-latest
2975
steps:
3076
- name: Checkout repo
@@ -42,7 +88,7 @@ jobs:
4288
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
4389
run: |
4490
if [ "${{ github.event.inputs.makePR }}" = "true" ]; then
45-
fern generate --api api --group python-sdk --version ${{ inputs.version }} --mode pull-request --log-level debug
91+
fern generate --api api --group python-sdk --version ${{ needs.determine-version.outputs.version }} --mode pull-request --log-level debug
4692
else
47-
fern generate --api api --group python-sdk --version ${{ inputs.version }} --log-level debug
93+
fern generate --api api --group python-sdk --version ${{ needs.determine-version.outputs.version }} --log-level debug
4894
fi

0 commit comments

Comments
 (0)