Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion .github/CODEOWNERS

This file was deleted.

1 change: 0 additions & 1 deletion .github/tw-rules.yaml

This file was deleted.

39 changes: 14 additions & 25 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Build and Test"
name: "Build"

on:
pull_request:
Expand All @@ -11,29 +11,18 @@ on:
jobs:
build:
name: "Build"
runs-on:
- ubuntu-latest
env:
GRADLE_OPTS: "-Djava.security.egd=file:/dev/./urandom -Dorg.gradle.parallel=true"
container:
image: azul/zulu-openjdk:11
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: "Install packages"
run: apt-get update && apt-get install -y git
- name: Checkout repository
uses: actions/checkout@v4
- name: "Validate version tag doesn't exist"
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew validateVersion --console=plain --no-daemon
- name: "Gradle cache"
uses: actions/cache@v4
- uses: actions/checkout@v7
- uses: actions/setup-java@v6
with:
path: |
~/.gradle
key: gradle-v1-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties', '**/*.gradle*') }}
- name: "Assemble jar"
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew assemble --console=plain --no-daemon
- name: "Test if publishing works"
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew publishToMavenLocal --console=plain --no-daemon --stacktrace
- name: "Tag release"
if: github.ref == 'refs/heads/main'
run: GRADLE_USER_HOME=$HOME/.gradle ./gradlew tagRelease --console=plain --no-daemon
distribution: zulu
java-version: 25
- uses: bufbuild/buf-action@v1
with:
setup_only: true
- uses: gradle/actions/setup-gradle@v6
- name: "Build and publish locally"
run: ./gradlew build publishToMavenLocal --console=plain
87 changes: 87 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: "Release"

# Publishes every Envoy release (as labelled in the Buf registry) that has no v<version> tag here yet.
# Does nothing until the repository variable PUBLISH is set to "true" and the Maven Central secrets exist.

on:
schedule:
- cron: "17 6 * * *"
workflow_dispatch:
inputs:
envoy_version:
description: "Publish only this Envoy version, e.g. 1.40.0 (default: every unpublished release)"
required: false
build_number:
description: "Rebuild suffix, publishing <version>-<n> (only with envoy_version)"
required: false

concurrency: release

jobs:
release:
name: "Release"
if: vars.PUBLISH == 'true'
runs-on: ubuntu-latest
permissions:
contents: write # push release tags
env:
MIN_ENVOY_VERSION: "1.31.0" # oldest release Envoy labels in the Buf registry
MAX_RELEASES_PER_RUN: "5" # a build takes several minutes; later runs catch up on a backlog
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
OSS_SIGNING_KEY: ${{ secrets.OSS_SIGNING_KEY }}
OSS_SIGNING_PASSWORD: ${{ secrets.OSS_SIGNING_PASSWORD }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0 # tags
- uses: actions/setup-java@v6
with:
distribution: zulu
java-version: 25
- uses: bufbuild/buf-action@v1
with:
setup_only: true
- uses: gradle/actions/setup-gradle@v6
- name: "Publish unpublished Envoy releases"
env:
ENVOY_VERSION: ${{ inputs.envoy_version }}
BUILD_NUMBER: ${{ inputs.build_number }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"

if [ -n "${ENVOY_VERSION}" ]; then
versions="${ENVOY_VERSION}"
else
versions=$(curl -sSf -X POST https://buf.build/buf.registry.module.v1.LabelService/ListLabels \
-H 'Content-Type: application/json' \
-d '{"pageSize":250,"resourceRef":{"name":{"owner":"envoyproxy","module":"envoy"}}}' \
| jq -r '.labels[].name' | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | sed 's/^v//' | sort -V)
fi

published=0
for v in ${versions}; do
if [ "${published}" -ge "${MAX_RELEASES_PER_RUN}" ]; then
echo "Published ${published}; leaving the rest for the next run"
break
fi
if [ "$(printf '%s\n%s\n' "${MIN_ENVOY_VERSION}" "${v}" | sort -V | head -1)" != "${MIN_ENVOY_VERSION}" ]; then
continue
fi
release="${v}${BUILD_NUMBER:+-${BUILD_NUMBER}}"
if git rev-parse -q --verify "refs/tags/v${release}" >/dev/null; then
continue
fi
echo "::group::Envoy ${v} as ${release}"
args=(-PenvoyVersion="${v}" --console=plain)
if [ -n "${BUILD_NUMBER}" ]; then
args+=(-PbuildNumber="${BUILD_NUMBER}")
fi
./gradlew "${args[@]}" clean publishToSonatype closeAndReleaseSonatypeStagingRepository
git tag -a "v${release}" -m "Envoy ${v}"
git push origin "v${release}"
published=$((published + 1))
echo "::endgroup::"
done
42 changes: 28 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,36 @@
# Envoy Java API

This builds a grpc library for the envoy xDS API.
Java protobuf and gRPC classes for the [Envoy](https://www.envoyproxy.io/) xDS API, published as
`net.woaf.jono.envoy:envoy-api`.

## Versioning
Major and minor version follow the envoy version against which they are built. The patch version is this library's patch version. Use the latest patch version for the envoy major.minor you run, e.g. use the latest 1.17.x for this library if you run envoy 1.17.y, regardless of what y is.

## Building
Each release is built from one Envoy release and carries its version: `1.40.0` is Envoy 1.40.0's API. A rebuild of the
same Envoy release gets a suffix, e.g. `1.40.0-1`. Use the version matching the Envoy you run, or any later one: the v3
API only grows, and older Envoys ignore fields they don't know (see Envoy's
[API versioning policy](https://github.com/envoyproxy/envoy/blob/main/api/API_VERSIONING.md)).

The `tools` directory follows https://github.com/envoyproxy/java-control-plane/commits/main/tools as closely as possible.
The classes are generated with protoc 3.25, so they run on protobuf-java 3.25+ and 4.x.

1. Grab the Commit ID of the envoy version you are going to use and update it into the `API_SHAS` file.
2. Next see its Bazel dependencices `https://github.com/envoyproxy/envoy/blob/{GITHUB_COMMIT_ID}/api/bazel/repository_locations.bzl`
3. Update the remaining SHAs and Versions in the `API_SHAS` file.
4. This is an alternate : you can also use the run `update-sha.sh MAJOR.MINOR.PATCH`, paste the end of its output to `API_SHAS`.
5. Update the proto files using `update-api.sh`. This will remove the old `src/main/proto` and fetch a new set of protos.
6. Bump the library version according to `Versioning` above in `gradle.properties`.
7. Now it should build on CI. Can try locally using `./gradlew assemble`, but see GHA workflow for specific steps.
8. You may need to add or remove protos depending on the failures and you would want to refer to the bazel dependencies file to figure out what failed, finally udpate the scripts to have the change.
## How it's built

Note: until we catch up with Envoy head version, slight adjustments might be needed for these scripts, towards matching upstream more closely.
https://github.com/envoyproxy/envoy/blob/6fe1905459ff267a43a8a26d042ae03a8aa7bc98/api/bazel/repository_locations.bzl
Envoy publishes every release to the [Buf registry](https://buf.build/envoyproxy/envoy) together with its third-party
proto dependencies (xds, udpa, protoc-gen-validate, googleapis, cel, OpenTelemetry, Prometheus), pinned by Envoy's
`api/buf.lock`. The build exports one release from there and compiles it:

```
./gradlew build -PenvoyVersion=1.40.0
```

This needs the [`buf` CLI](https://buf.build/docs/cli/installation/) on your `PATH`.

`google/api/annotations.proto`, `google/api/http.proto` and `google/rpc/status.proto` are not bundled: they come from
`com.google.api.grpc:proto-google-common-protos`, which gRPC already depends on, so the classes aren't duplicated.

## Releasing

`.github/workflows/release.yml` runs daily. It publishes every Envoy release from 1.31.0 on that has no `v<version>`
tag in this repository yet, then tags it. Run it by hand to publish one version, or a rebuild with a build number.

It does nothing until the repository variable `PUBLISH` is `true`, and needs these secrets:
`SONATYPE_USER`, `SONATYPE_PASSWORD` (a Maven Central Portal user token), `OSS_SIGNING_KEY` and `OSS_SIGNING_PASSWORD`.
Loading
Loading