-
Notifications
You must be signed in to change notification settings - Fork 980
53 lines (47 loc) · 1.78 KB
/
xds-compare-versions.yml
File metadata and controls
53 lines (47 loc) · 1.78 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
name: Compare upstream envoy versions
permissions:
contents: read
on:
workflow_call:
outputs:
target_version:
description: "Envoy version we need to update to"
value: ${{ jobs.compare-envoy-versions.outputs.target_version }}
should_update:
description: "Whether the apis should be updated"
value: ${{ jobs.compare-envoy-versions.outputs.should_update }}
jobs:
compare-envoy-versions:
runs-on: ubuntu-latest
outputs:
target_version: ${{ steps.latest-envoy-version.outputs.version }}
should_update: ${{ steps.compare.outputs.should_update }}
steps:
- uses: actions/checkout@v4
- name: Fetch latest Envoy version
id: latest-envoy-version
run: |
version=$(curl -s https://api.github.com/repos/envoyproxy/envoy/releases/latest | jq -r '.tag_name')
echo "version=$version" >> $GITHUB_OUTPUT
- name: Read current Envoy version
id: current-envoy-version
run: |
version=$(cat ./xds-api/tools/envoy_release)
echo "version=$version" >> $GITHUB_OUTPUT
- name: Compare latest to current
id: compare
run: |
latest="${{ steps.latest-envoy-version.outputs.version }}"
current="${{ steps.current-envoy-version.outputs.version }}"
# Remove 'v' prefix if present
latest_clean=${latest#v}
current_clean=${current#v}
# Function to compare semantic versions
version_greater() {
printf '%s\n%s\n' "$1" "$2" | sort -V | head -n1 | grep -q "^$2$"
}
if version_greater "$latest_clean" "$current_clean"; then
echo "should_update=true" >> $GITHUB_OUTPUT
else
echo "should_update=false" >> $GITHUB_OUTPUT
fi