Skip to content

Commit e6c7148

Browse files
refactor: simplify align-version to only run when set_version provided
- Only run align-version job if inputs.set_version is set - Use the provided version directly instead of reading from gen.lock - Simplified step logic
1 parent 3999f03 commit e6c7148

File tree

3 files changed

+21
-99
lines changed

3 files changed

+21
-99
lines changed

.github/workflows/sdk_generation_mistralai_azure_sdk.yaml

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,58 +30,32 @@ jobs:
3030

3131
align-version:
3232
needs: generate
33+
if: ${{ inputs.set_version != '' }}
3334
runs-on: ubuntu-latest
3435
steps:
3536
- name: Find Speakeasy PR branch
3637
id: find-branch
3738
env:
3839
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3940
run: |
40-
# Find the most recent open PR from speakeasybot for this target
4141
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-
if [ -z "$BRANCH" ]; then
43-
echo "No Speakeasy PR found, skipping"
44-
echo "skip=true" >> $GITHUB_OUTPUT
45-
else
46-
echo "Found branch: $BRANCH"
47-
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
48-
echo "skip=false" >> $GITHUB_OUTPUT
49-
fi
42+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
5043
5144
- name: Checkout PR branch
52-
if: steps.find-branch.outputs.skip != 'true'
5345
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5446
with:
5547
ref: ${{ steps.find-branch.outputs.branch }}
5648

5749
- name: Install uv
58-
if: steps.find-branch.outputs.skip != 'true'
5950
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
6051

6152
- name: Update pyproject.toml version
62-
if: steps.find-branch.outputs.skip != 'true'
63-
run: |
64-
# Use set_version input if provided, otherwise read from gen.lock
65-
VERSION="${{ github.event.inputs.set_version }}"
66-
if [ -z "$VERSION" ]; then
67-
VERSION=$(grep 'releaseVersion:' packages/azure/.speakeasy/gen.lock | head -1 | awk '{print $2}')
68-
fi
69-
echo "Aligning pyproject.toml to version: $VERSION"
70-
uv version "$VERSION" --directory packages/azure
71-
72-
- name: Configure git
73-
if: steps.find-branch.outputs.skip != 'true'
74-
run: |
75-
git config --local user.email "action@github.com"
76-
git config --local user.name "GitHub Action"
53+
run: uv version "${{ inputs.set_version }}" --directory packages/azure
7754

7855
- name: Commit and push
79-
if: steps.find-branch.outputs.skip != 'true'
8056
run: |
57+
git config user.email "action@github.com"
58+
git config user.name "GitHub Action"
8159
git add packages/azure/pyproject.toml
82-
if git diff --cached --quiet; then
83-
echo "No version change needed"
84-
else
85-
git commit -m "chore: align pyproject.toml version with gen.lock"
86-
git push
87-
fi
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: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,58 +30,32 @@ jobs:
3030

3131
align-version:
3232
needs: generate
33+
if: ${{ inputs.set_version != '' }}
3334
runs-on: ubuntu-latest
3435
steps:
3536
- name: Find Speakeasy PR branch
3637
id: find-branch
3738
env:
3839
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3940
run: |
40-
# Find the most recent open PR from speakeasybot for this target
4141
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-
if [ -z "$BRANCH" ]; then
43-
echo "No Speakeasy PR found, skipping"
44-
echo "skip=true" >> $GITHUB_OUTPUT
45-
else
46-
echo "Found branch: $BRANCH"
47-
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
48-
echo "skip=false" >> $GITHUB_OUTPUT
49-
fi
42+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
5043
5144
- name: Checkout PR branch
52-
if: steps.find-branch.outputs.skip != 'true'
5345
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5446
with:
5547
ref: ${{ steps.find-branch.outputs.branch }}
5648

5749
- name: Install uv
58-
if: steps.find-branch.outputs.skip != 'true'
5950
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
6051

6152
- name: Update pyproject.toml version
62-
if: steps.find-branch.outputs.skip != 'true'
63-
run: |
64-
# Use set_version input if provided, otherwise read from gen.lock
65-
VERSION="${{ github.event.inputs.set_version }}"
66-
if [ -z "$VERSION" ]; then
67-
VERSION=$(grep 'releaseVersion:' packages/gcp/.speakeasy/gen.lock | head -1 | awk '{print $2}')
68-
fi
69-
echo "Aligning pyproject.toml to version: $VERSION"
70-
uv version "$VERSION" --directory packages/gcp
71-
72-
- name: Configure git
73-
if: steps.find-branch.outputs.skip != 'true'
74-
run: |
75-
git config --local user.email "action@github.com"
76-
git config --local user.name "GitHub Action"
53+
run: uv version "${{ inputs.set_version }}" --directory packages/gcp
7754

7855
- name: Commit and push
79-
if: steps.find-branch.outputs.skip != 'true'
8056
run: |
57+
git config user.email "action@github.com"
58+
git config user.name "GitHub Action"
8159
git add packages/gcp/pyproject.toml
82-
if git diff --cached --quiet; then
83-
echo "No version change needed"
84-
else
85-
git commit -m "chore: align pyproject.toml version with gen.lock"
86-
git push
87-
fi
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: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -30,58 +30,32 @@ jobs:
3030

3131
align-version:
3232
needs: generate
33+
if: ${{ inputs.set_version != '' }}
3334
runs-on: ubuntu-latest
3435
steps:
3536
- name: Find Speakeasy PR branch
3637
id: find-branch
3738
env:
3839
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3940
run: |
40-
# Find the most recent open PR from speakeasybot for this target
4141
BRANCH=$(gh pr list --repo ${{ github.repository }} --author speakeasybot --state open --json headRefName,title --jq '.[] | select(.title | contains("MISTRALAI-SDK")) | .headRefName' | head -1)
42-
if [ -z "$BRANCH" ]; then
43-
echo "No Speakeasy PR found, skipping"
44-
echo "skip=true" >> $GITHUB_OUTPUT
45-
else
46-
echo "Found branch: $BRANCH"
47-
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
48-
echo "skip=false" >> $GITHUB_OUTPUT
49-
fi
42+
echo "branch=$BRANCH" >> $GITHUB_OUTPUT
5043
5144
- name: Checkout PR branch
52-
if: steps.find-branch.outputs.skip != 'true'
5345
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
5446
with:
5547
ref: ${{ steps.find-branch.outputs.branch }}
5648

5749
- name: Install uv
58-
if: steps.find-branch.outputs.skip != 'true'
5950
uses: astral-sh/setup-uv@d0cc045d04ccac9d8b7881df0226f9e82c39688e # v6
6051

6152
- name: Update pyproject.toml version
62-
if: steps.find-branch.outputs.skip != 'true'
63-
run: |
64-
# Use set_version input if provided, otherwise read from gen.lock
65-
VERSION="${{ github.event.inputs.set_version }}"
66-
if [ -z "$VERSION" ]; then
67-
VERSION=$(grep 'releaseVersion:' .speakeasy/gen.lock | head -1 | awk '{print $2}')
68-
fi
69-
echo "Aligning pyproject.toml to version: $VERSION"
70-
uv version "$VERSION"
71-
72-
- name: Configure git
73-
if: steps.find-branch.outputs.skip != 'true'
74-
run: |
75-
git config --local user.email "action@github.com"
76-
git config --local user.name "GitHub Action"
53+
run: uv version "${{ inputs.set_version }}"
7754

7855
- name: Commit and push
79-
if: steps.find-branch.outputs.skip != 'true'
8056
run: |
57+
git config user.email "action@github.com"
58+
git config user.name "GitHub Action"
8159
git add pyproject.toml
82-
if git diff --cached --quiet; then
83-
echo "No version change needed"
84-
else
85-
git commit -m "chore: align pyproject.toml version with gen.lock"
86-
git push
87-
fi
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)