Skip to content

Commit d2142b4

Browse files
refactor: use PR-triggered workflow for version alignment
- Add new align_pyproject_version.yaml workflow triggered on PR events - Triggers when speakeasybot opens/updates a PR with gen.lock changes - Uses github.head_ref for reliable branch reference - Remove align-version job from SDK generation workflows
1 parent e6c7148 commit d2142b4

4 files changed

Lines changed: 58 additions & 96 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Align pyproject.toml version
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize]
6+
paths:
7+
- ".speakeasy/gen.lock"
8+
- "packages/azure/.speakeasy/gen.lock"
9+
- "packages/gcp/.speakeasy/gen.lock"
10+
11+
permissions:
12+
contents: write
13+
14+
jobs:
15+
align-version:
16+
if: github.actor == 'speakeasybot'
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout PR branch
20+
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
21+
with:
22+
ref: ${{ github.head_ref }}
23+
24+
- name: Install uv
25+
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
26+
27+
- name: Align main SDK version
28+
if: hashFiles('.speakeasy/gen.lock') != ''
29+
run: |
30+
VERSION=$(grep 'releaseVersion:' .speakeasy/gen.lock | head -1 | awk '{print $2}')
31+
echo "Aligning main SDK to version: $VERSION"
32+
uv version "$VERSION"
33+
34+
- name: Align Azure SDK version
35+
if: hashFiles('packages/azure/.speakeasy/gen.lock') != ''
36+
run: |
37+
VERSION=$(grep 'releaseVersion:' packages/azure/.speakeasy/gen.lock | head -1 | awk '{print $2}')
38+
echo "Aligning Azure SDK to version: $VERSION"
39+
uv version "$VERSION" --directory packages/azure
40+
41+
- name: Align GCP SDK version
42+
if: hashFiles('packages/gcp/.speakeasy/gen.lock') != ''
43+
run: |
44+
VERSION=$(grep 'releaseVersion:' packages/gcp/.speakeasy/gen.lock | head -1 | awk '{print $2}')
45+
echo "Aligning GCP SDK to version: $VERSION"
46+
uv version "$VERSION" --directory packages/gcp
47+
48+
- name: Commit and push
49+
run: |
50+
git config user.email "action@github.com"
51+
git config user.name "GitHub Action"
52+
git add pyproject.toml packages/*/pyproject.toml 2>/dev/null || true
53+
if git diff --cached --quiet; then
54+
echo "No version change needed"
55+
else
56+
git commit -m "chore: align pyproject.toml version with gen.lock"
57+
git push
58+
fi

.github/workflows/sdk_generation_mistralai_azure_sdk.yaml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,3 @@ jobs:
2727
github_access_token: ${{ secrets.GITHUB_TOKEN }}
2828
pypi_token: ${{ secrets.PYPI_TOKEN }}
2929
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
30-
31-
align-version:
32-
needs: generate
33-
if: ${{ inputs.set_version != '' }}
34-
runs-on: ubuntu-latest
35-
steps:
36-
- name: Find Speakeasy PR branch
37-
id: find-branch
38-
env:
39-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
run: |
41-
BRANCH=$(gh pr list --repo ${{ github.repository }} --author speakeasybot --state open --json headRefName,title --jq '.[] | select(.title | contains("MISTRALAI-AZURE-SDK")) | .headRefName' | head -1)
42-
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
43-
44-
- name: Checkout PR branch
45-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
46-
with:
47-
ref: ${{ steps.find-branch.outputs.branch }}
48-
49-
- name: Install uv
50-
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
51-
52-
- name: Update pyproject.toml version
53-
run: uv version "${{ inputs.set_version }}" --directory packages/azure
54-
55-
- name: Commit and push
56-
run: |
57-
git config user.email "action@github.com"
58-
git config user.name "GitHub Action"
59-
git add packages/azure/pyproject.toml
60-
git diff --cached --quiet || git commit -m "chore: align pyproject.toml version to ${{ inputs.set_version }}"
61-
git push

.github/workflows/sdk_generation_mistralai_gcp_sdk.yaml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,3 @@ jobs:
2727
github_access_token: ${{ secrets.GITHUB_TOKEN }}
2828
pypi_token: ${{ secrets.PYPI_TOKEN }}
2929
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
30-
31-
align-version:
32-
needs: generate
33-
if: ${{ inputs.set_version != '' }}
34-
runs-on: ubuntu-latest
35-
steps:
36-
- name: Find Speakeasy PR branch
37-
id: find-branch
38-
env:
39-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
run: |
41-
BRANCH=$(gh pr list --repo ${{ github.repository }} --author speakeasybot --state open --json headRefName,title --jq '.[] | select(.title | contains("MISTRALAI-GCP-SDK")) | .headRefName' | head -1)
42-
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
43-
44-
- name: Checkout PR branch
45-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
46-
with:
47-
ref: ${{ steps.find-branch.outputs.branch }}
48-
49-
- name: Install uv
50-
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
51-
52-
- name: Update pyproject.toml version
53-
run: uv version "${{ inputs.set_version }}" --directory packages/gcp
54-
55-
- name: Commit and push
56-
run: |
57-
git config user.email "action@github.com"
58-
git config user.name "GitHub Action"
59-
git add packages/gcp/pyproject.toml
60-
git diff --cached --quiet || git commit -m "chore: align pyproject.toml version to ${{ inputs.set_version }}"
61-
git push

.github/workflows/sdk_generation_mistralai_sdk.yaml

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,35 +27,3 @@ jobs:
2727
github_access_token: ${{ secrets.GITHUB_TOKEN }}
2828
pypi_token: ${{ secrets.PYPI_TOKEN }}
2929
speakeasy_api_key: ${{ secrets.SPEAKEASY_API_KEY }}
30-
31-
align-version:
32-
needs: generate
33-
if: ${{ inputs.set_version != '' }}
34-
runs-on: ubuntu-latest
35-
steps:
36-
- name: Find Speakeasy PR branch
37-
id: find-branch
38-
env:
39-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
40-
run: |
41-
BRANCH=$(gh pr list --repo ${{ github.repository }} --author speakeasybot --state open --json headRefName,title --jq '.[] | select(.title | contains("MISTRALAI-SDK")) | .headRefName' | head -1)
42-
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
43-
44-
- name: Checkout PR branch
45-
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
46-
with:
47-
ref: ${{ steps.find-branch.outputs.branch }}
48-
49-
- name: Install uv
50-
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
51-
52-
- name: Update pyproject.toml version
53-
run: uv version "${{ inputs.set_version }}"
54-
55-
- name: Commit and push
56-
run: |
57-
git config user.email "action@github.com"
58-
git config user.name "GitHub Action"
59-
git add pyproject.toml
60-
git diff --cached --quiet || git commit -m "chore: align pyproject.toml version to ${{ inputs.set_version }}"
61-
git push

0 commit comments

Comments
 (0)