Skip to content

Commit 977f05c

Browse files
committed
update shell script to setup latest python version
1 parent fb89531 commit 977f05c

File tree

5 files changed

+64
-36
lines changed

5 files changed

+64
-36
lines changed

azure/build-prereqs.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ parameters:
44
default: 'utils'
55

66
steps:
7-
# - bash: |
8-
# echo "Setting python tool cache path"
9-
# echo "##vso[task.setvariable variable=LD_LIBRARY_PATH;]:/agent/_work/_tool/Python/3.13.7/x64/lib/"
10-
# displayName: 'Set python tool cache path'
117
- bash: |
12-
PATCH=$(curl -s https://api.github.com/repos/actions/python-versions/releases \
13-
| jq -r '[.[] | .tag_name | select(startswith("3.13"))] | .[]' \
14-
| sort -V | tail -n 1 | cut -d- -f1)
8+
pyversion="3.13"
9+
PATCH=curl -fsSL https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json \
10+
| jq -r --arg pyversion "$pyversion" '
11+
[ .[]
12+
| select(.stable == true)
13+
| .version
14+
| select(test("^" + ($pyversion|gsub("\\.";"\\.")) + "\\.\\d+$"))
15+
| split(".") | map(tonumber)
16+
]
17+
| max
18+
| join(".")'
1519
1620
echo "##vso[task.setvariable variable=PY_VER]$PATCH"
1721
echo "Resolved latest python version: $PATCH"
@@ -21,7 +25,7 @@ steps:
2125
2226
- task: UsePythonVersion@0
2327
name: UsePy
24-
displayName: 'Use Python $(PY_VER)'
28+
displayName: 'Use Python 3.13'
2529
inputs:
2630
versionSpec: '$(PY_VER)'
2731

azure/cleanup-ecs-pr-proxies.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,17 @@ jobs:
6161
displayName: cache utils pre-requisites
6262

6363
- bash: |
64-
PATCH=$(curl -s https://api.github.com/repos/actions/python-versions/releases \
65-
| jq -r '[.[] | .tag_name | select(startswith("3.13"))] | .[]' \
66-
| sort -V | tail -n 1 | cut -d- -f1)
64+
pyversion="3.13"
65+
PATCH=curl -fsSL https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json \
66+
| jq -r --arg pyversion "$pyversion" '
67+
[ .[]
68+
| select(.stable == true)
69+
| .version
70+
| select(test("^" + ($pyversion|gsub("\\.";"\\.")) + "\\.\\d+$"))
71+
| split(".") | map(tonumber)
72+
]
73+
| max
74+
| join(".")'
6775
6876
echo "##vso[task.setvariable variable=PY_VER]$PATCH"
6977
echo "Resolved latest python version: $PATCH"
@@ -73,7 +81,7 @@ jobs:
7381
7482
- task: UsePythonVersion@0
7583
name: UsePy
76-
displayName: 'Use Python $(PY_VER)'
84+
displayName: 'Use Python 3.13'
7785
inputs:
7886
versionSpec: '$(PY_VER)'
7987

azure/common/apigee-build.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,23 +143,28 @@ jobs:
143143
parameters:
144144
service_name: "${{ parameters.service_name }}"
145145

146-
# - bash: |
147-
# echo "Setting python tool cache path"
148-
# echo "##vso[task.setvariable variable=LD_LIBRARY_PATH;]:/agent/_work/_tool/Python/${{ parameters.python_version }}/x64/lib/"
149-
# displayName: 'Set python tool cache path'
150-
151146
- bash: |
152-
PATCH=$(curl -s https://api.github.com/repos/actions/python-versions/releases \
153-
| jq -r '[.[] | .tag_name | select(startswith("'"${{ parameters.python_version }}"'"))] | .[]' \
154-
| sort -V | tail -n 1 | cut -d- -f1)
155-
echo "Resolved latest python version: $PATCH"
147+
pyversion=${{ parameters.python_version }}
148+
PATCH=curl -fsSL https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json \
149+
| jq -r --arg pyversion "$pyversion" '
150+
[ .[]
151+
| select(.stable == true)
152+
| .version
153+
| select(test("^" + ($pyversion|gsub("\\.";"\\.")) + "\\.\\d+$"))
154+
| split(".") | map(tonumber)
155+
]
156+
| max
157+
| join(".")'
158+
156159
echo "##vso[task.setvariable variable=PY_VER]$PATCH"
160+
echo "Resolved latest python version: $PATCH"
157161
echo "##vso[task.setvariable variable=LD_LIBRARY_PATH;]/agent/_work/_tool/Python/${PATCH}/x64/lib/"
158-
displayName: 'Query and set python tool cache path'
162+
displayName: 'Query and set python tool cache path'
163+
159164
160165
- task: UsePythonVersion@0
161166
name: UsePy
162-
displayName: 'Use Python $(PY_VER)'
167+
displayName: 'Use Python ${{ parameters.python_version }}'
163168
inputs:
164169
versionSpec: '$(PY_VER)'
165170

azure/common/deploy-stage.yml

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,17 @@ stages:
125125
aws_account: "${{ parameters.aws_account }}"
126126

127127
- bash: |
128-
PATCH=$(curl -s https://api.github.com/repos/actions/python-versions/releases \
129-
| jq -r '[.[] | .tag_name | select(startswith("3.13"))] | .[]' \
130-
| sort -V | tail -n 1 | cut -d- -f1)
128+
pyversion="3.13"
129+
PATCH=curl -fsSL https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json \
130+
| jq -r --arg pyversion "$pyversion" '
131+
[ .[]
132+
| select(.stable == true)
133+
| .version
134+
| select(test("^" + ($pyversion|gsub("\\.";"\\.")) + "\\.\\d+$"))
135+
| split(".") | map(tonumber)
136+
]
137+
| max
138+
| join(".")'
131139
132140
echo "##vso[task.setvariable variable=PY_VER]$PATCH"
133141
echo "Resolved latest python version: $PATCH"
@@ -137,7 +145,7 @@ stages:
137145
138146
- task: UsePythonVersion@0
139147
name: UsePy
140-
displayName: 'Use Python $(PY_VER)'
148+
displayName: 'Use Python 3.13'
141149
inputs:
142150
versionSpec: '$(PY_VER)'
143151

azure/utils-pr-pipeline.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@ jobs:
2929
workspace:
3030
clean: all
3131
steps:
32-
# - bash: |
33-
# echo "Setting python tool cache path"
34-
# echo "##vso[task.setvariable variable=LD_LIBRARY_PATH;]:/agent/_work/_tool/Python/3.13.7/x64/lib/"
35-
# displayName: 'Set python tool cache path'
36-
3732
- bash: |
38-
PATCH=$(curl -s https://api.github.com/repos/actions/python-versions/releases \
39-
| jq -r '[.[] | .tag_name | select(startswith("3.13"))] | .[]' \
40-
| sort -V | tail -n 1 | cut -d- -f1)
33+
pyversion="3.13"
34+
PATCH=curl -fsSL https://raw.githubusercontent.com/actions/python-versions/main/versions-manifest.json \
35+
| jq -r --arg pyversion "$pyversion" '
36+
[ .[]
37+
| select(.stable == true)
38+
| .version
39+
| select(test("^" + ($pyversion|gsub("\\.";"\\.")) + "\\.\\d+$"))
40+
| split(".") | map(tonumber)
41+
]
42+
| max
43+
| join(".")'
4144
4245
echo "##vso[task.setvariable variable=PY_VER]$PATCH"
4346
echo "Resolved latest python version: $PATCH"
@@ -47,7 +50,7 @@ jobs:
4750
4851
- task: UsePythonVersion@0
4952
name: UsePy
50-
displayName: 'Use Python $(PY_VER)'
53+
displayName: 'Use Python 3.13'
5154
inputs:
5255
versionSpec: '$(PY_VER)'
5356

0 commit comments

Comments
 (0)