diff --git a/.github/workflows/test_java.yml b/.github/workflows/test_java.yml index e1705a30d8..da1680c9ad 100644 --- a/.github/workflows/test_java.yml +++ b/.github/workflows/test_java.yml @@ -73,3 +73,52 @@ jobs: run: curl -v -O "https://storage.googleapis.com/cloud-opensource-java-linkage-monitor/linkage-monitor-latest-all-deps.jar" - name: Fails if there's new linkage errors compared with baseline run: java -Xmx2048m -jar linkage-monitor-latest-all-deps.jar com.google.cloud:libraries-bom + + protobuf-bom: + name: Protobuf Maven BOM + runs-on: ubuntu-latest + steps: + - name: Checkout pending changes + uses: actions/checkout@ac593985615ec2ede58e132d2e21d2b1cbd6127c # v3.3.0 + with: + ref: ${{ inputs.safe-checkout }} + - name: Build protoc + id: build-protoc + uses: protocolbuffers/protobuf-ci/cross-compile-protoc@v1 + with: + image: us-docker.pkg.dev/protobuf-build/containers/common/linux/bazel:5.1.1-6361b3a6e5c97e9951d03a4de28542fc45f1adab + credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} + architecture: linux-x86_64 + - name: Move protoc into place and clean up + run: | + mv ${{ steps.build-protoc.outputs.protoc }} protoc + sudo rm -rf _build + - name: Install snapshot version locally (not using generated pom.xml) + run: | + mvn -e -B -Dhttps.protocols=TLSv1.2 install -Dmaven.test.skip=true + working-directory: java + - name: Generate pom.xml files from the template + uses: protocolbuffers/protobuf-ci/bazel-docker@v1 + with: + image: us-docker.pkg.dev/protobuf-build/containers/test/linux/java:11-03a376b5d6ef66f827fc307716e3b841cc26b709 + credentials: ${{ secrets.GAR_SERVICE_ACCOUNT }} + bazel-cache: java_linux/11 + # protobuf-java and protobuf-java-util are the member of the BOM + bash: | + bazel build //java/core:core_mvn-pom //java/util:util_mvn-pom + cp bazel-bin/java/core/core_mvn-pom.xml . + cp bazel-bin/java/util/util_mvn-pom.xml . + - name: Copy the generated pom.xml files to the local Maven repository + shell: bash + run: | + LOCAL_MAVEN_GROUP_DIR="${HOME}/.m2/repository/com/google/protobuf" + VERSION=$(grep 'Bundle-Version:' ./java/core/target/classes/META-INF/MANIFEST.MF |awk '{print $2}' |tr -d '\r') + cp core_mvn-pom.xml ${LOCAL_MAVEN_GROUP_DIR}/protobuf-java/${VERSION}/protobuf-java-${VERSION}.pom + cp util_mvn-pom.xml ${LOCAL_MAVEN_GROUP_DIR}/protobuf-java-util/${VERSION}/protobuf-java-util-${VERSION}.pom + - name: Clean up + run: | + sudo rm -rf _build + - name: Validate Protobuf BOM + uses: googleapis/java-cloud-bom/tests/validate-bom@v26.13.0 + with: + bom-path: java/bom/pom.xml