Skip to content

Commit a8f1f51

Browse files
authored
Automation to keep Envoy API up to date with latest release (envoyproxy#200)
Signed-off-by: rulex123 <[email protected]>
1 parent aae3c86 commit a8f1f51

File tree

7 files changed

+74
-17
lines changed

7 files changed

+74
-17
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: compare-envoy-versions
2+
on:
3+
workflow_call:
4+
outputs:
5+
target-version:
6+
description: "Envoy version we need to update to"
7+
value: ${{ jobs.compare-envoy-versions.outputs.target-version }}
8+
9+
jobs:
10+
compare-envoy-versions:
11+
runs-on: ubuntu-latest
12+
outputs:
13+
target-version: ${{ steps.compare-latest-to-current-version.outputs.target-version }}
14+
steps:
15+
- uses: actions/checkout@v2
16+
- name: Fetch latest Envoy version
17+
id: latest-envoy-version
18+
run: |
19+
echo 'ENVOY_LATEST<<EOF' >> $GITHUB_ENV
20+
curl -s https://api.github.com/repos/envoyproxy/envoy/releases/latest | jq -r '.tag_name' >> $GITHUB_ENV
21+
echo 'EOF' >> $GITHUB_ENV
22+
- name: Read current Envoy version
23+
id: current-envoy-version
24+
run: |
25+
echo 'ENVOY_CURRENT<<EOF' >> $GITHUB_ENV
26+
cat envoy_release >> $GITHUB_ENV
27+
echo 'EOF' >> $GITHUB_ENV
28+
- name: Compare latest to current
29+
id: compare-latest-to-current-version
30+
run: |
31+
if [[ "${{ env.ENVOY_LATEST }}" == "${{ env.ENVOY_CURRENT }}" ]]
32+
then
33+
echo "::set-output name=target-version::noop"
34+
else
35+
echo "::set-output name=target-version::${{ env.ENVOY_LATEST }}"
36+
fi

.github/workflows/scheduled.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: scheduled
2+
on:
3+
schedule:
4+
# every Monday at 10
5+
- cron: '0 10 * * 1'
6+
7+
jobs:
8+
call-compare-envoy-versions-workflow:
9+
uses: ./.github/workflows/compare-envoy-versions.yml
10+
11+
call-update-protobuf:
12+
needs: call-compare-envoy-versions-workflow
13+
if: ${{ needs.call-compare-envoy-versions-workflow.outputs.target-version != 'noop' }}
14+
uses: ./.github/workflows/update-protobuf.yml
15+
with:
16+
envoy_version: ${{ needs.call-compare-envoy-versions-workflow.outputs.target-version }}

.github/workflows/update-protobuf.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
name: update-protobuf
22
on:
3-
workflow_dispatch:
3+
workflow_call:
44
inputs:
55
envoy_version:
66
description: 'Envoy version to update to'
77
required: true
8+
type: string
89

910
jobs:
1011
update-protobuf:
@@ -14,14 +15,14 @@ jobs:
1415
- name: Run scripts
1516
working-directory: ./tools/
1617
run: |
17-
./update-sha.sh ${{ github.event.inputs.envoy_version }} | tee API_SHAS
18+
./update-sha.sh ${{ inputs.envoy_version }} | tee API_SHAS
1819
./update-api.sh
1920
- name: Create Pull Request
2021
uses: peter-evans/create-pull-request@v3
2122
with:
22-
branch: update-protobuf-to-${{ github.event.inputs.envoy_version }}
23+
branch: update-protobuf-to-${{ inputs.envoy_version }}
2324
signoff: true
24-
title: '[protobuf] Update protobuf definitions to ${{ github.event.inputs.envoy_version }}'
25+
title: '[protobuf] Update protobuf definitions to ${{ inputs.envoy_version }}'
2526
body: |
2627
This is an automatic PR created by github action workflow:
2728
- Updated protobuf files

README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,19 @@ mvn clean package
2727
More thorough usage examples are still TODO, but there is a basic test implementation in
2828
[TestMain](server/src/test/java/io/envoyproxy/controlplane/server/TestMain.java).
2929

30-
#### Bring api up-to-date with data-plane-api
31-
To bring this repository's protobuf files up-to-date with the source
32-
of truth protobuf files in in envoyproxy/data-plane-api, do the
33-
following:
34-
35-
1. update [tools/API_SHAS](tools/API_SHAS) (instructions are in the
36-
file) and then
37-
2. run [tools/update-api.sh](tools/update-api.sh) from the `tools`
38-
directory.
39-
3. update envoy-alpine-dev docker image version [EnvoyContainer.java] according to envoy SHA in first point.
40-
41-
#### Releasing a new version
30+
### Envoy API
31+
There is automation built into this repo to keep the Envoy API (i.e. protobuf files)
32+
up to date with the latest available Envoy release.
33+
34+
This automation uses Github Workflows and works as follows: a scheduled workflow runs with
35+
weekly cadence, and calls a reusable workflow that fetches the latest available Envoy release
36+
and compares it with the version currently used in the repo.
37+
38+
If the latest available Envoy release doesn't match the version currently used, another
39+
reusable workflow is called which creates a PR that upgrades the Envoy API to the latest
40+
available release.
41+
42+
### Releasing a new version
4243
To release and publish a new version, do the following:
4344
1. create a personal API token in CircleCI by following the instructions listed [here](https://circleci.com/docs/2.0/managing-api-tokens/#creating-a-personal-api-token)
4445
2. from terminal, curl the CircleCI API as follows

envoy_release

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
v1.20.0

tools/update-api.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
set -o errexit
44
set -o pipefail
5-
set -o nounset
65
set -o xtrace
76

87
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

tools/update-sha.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,6 @@ UDPA_SHA=\"$UDPA_SHA\" # $UDPA_DATE
6060

6161
# replace version in EnvoyContainer.java
6262
sed -i 's/\(envoy-alpine-dev:\).*\(\");\)/\1'"$ENVOY_VERSION"'\2/g' ../server/src/test/java/io/envoyproxy/controlplane/server/EnvoyContainer.java
63+
64+
# update tag in envoy_release file
65+
echo $1 > enovy_release

0 commit comments

Comments
 (0)