From 645eeba47283bbbb0513e9f56553e81325826753 Mon Sep 17 00:00:00 2001 From: Christofer Dutz Date: Wed, 13 Mar 2024 18:45:29 +0100 Subject: [PATCH] build: Continued fine-tuning the reproducible build release-scripts. --- build-reproducible.sh | 2 +- tools/NOTES.md | 22 +++++ tools/docker-compose.yaml | 2 +- tools/release-0-update-generated-code.sh | 5 +- tools/release-1-create-branch.sh | 2 +- tools/release-2-prepare-release.sh | 2 +- tools/release-3-perform-release.sh | 3 +- tools/release-abort.sh | 2 +- tools/validate-release.sh | 107 +++++++++++++++++++++++ 9 files changed, 139 insertions(+), 8 deletions(-) create mode 100644 tools/NOTES.md create mode 100755 tools/validate-release.sh diff --git a/build-reproducible.sh b/build-reproducible.sh index 0b7f99813f2..252f2972044 100644 --- a/build-reproducible.sh +++ b/build-reproducible.sh @@ -68,7 +68,7 @@ function renameArtifacts() { pwd } -# Package the remaiing files into one tgz archive +# Package the remaining files into one tgz archive function packageDirectory() { echo "Packaging ..." tar -cvf reproducible-build-candidate.tgz local-snapshots-dir/ diff --git a/tools/NOTES.md b/tools/NOTES.md new file mode 100644 index 00000000000..09e2e7bfbf4 --- /dev/null +++ b/tools/NOTES.md @@ -0,0 +1,22 @@ + + +# Compare the local version with the staged one + +./mvnw -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox verify artifact:compare -Dreference.repo=https://repository.apache.org/content/repositories/staging/ -Dbuildinfo.reproducible diff --git a/tools/docker-compose.yaml b/tools/docker-compose.yaml index af8a112cb97..ab97dbcdf39 100644 --- a/tools/docker-compose.yaml +++ b/tools/docker-compose.yaml @@ -22,7 +22,7 @@ services: releaser: build: context: .. - dockerfile: Dockerfile + dockerfile: ./Dockerfile # Builds all modules and uses an alternate maven local repo and deploys artifacts to a local directory. command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "-DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-snapshots-dir", "clean", "deploy"] volumes: diff --git a/tools/release-0-update-generated-code.sh b/tools/release-0-update-generated-code.sh index 515ef711e8b..1a6c562a74d 100755 --- a/tools/release-0-update-generated-code.sh +++ b/tools/release-0-update-generated-code.sh @@ -46,14 +46,15 @@ rm -r "$DIRECTORY/plc4c/generated-sources" # TODO: Possibly check, if the year in the NOTICE is outdated # 3. Run the maven build for all modules with "update-generated-code" enabled (Docker container) -docker compose run --rm releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository clean package -DskipTests +docker compose build +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository clean package -DskipTests if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 fi # 4. Make sure the generated driver documentation is up-to-date. -docker compose run --rm releaser bash /ws/mvnw -e -P with-java -Dmaven.repo.local=/ws/out/.repository clean site -pl :plc4j-driver-all +docker compose run releaser bash /ws/mvnw -e -P with-java -Dmaven.repo.local=/ws/out/.repository clean site -pl :plc4j-driver-all if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-1-create-branch.sh b/tools/release-1-create-branch.sh index 0845478a987..06be75e0342 100755 --- a/tools/release-1-create-branch.sh +++ b/tools/release-1-create-branch.sh @@ -51,7 +51,7 @@ case $yn in esac # 3. Do a simple maven branch command with pushChanges=false -../mvnw -f ../pom.xml -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=$DIRECTORY/../out/.repository release:branch -DautoVersionSubmodules=true -DpushChanges=false -DdevelopmentVersion="$NEW_VERSION" -DbranchName="$BRANCH_NAME" +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository release:branch -DautoVersionSubmodules=true -DpushChanges=false -DdevelopmentVersion="$NEW_VERSION" -DbranchName="$BRANCH_NAME" if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-2-prepare-release.sh b/tools/release-2-prepare-release.sh index 5f1dafe8117..31c30edef35 100755 --- a/tools/release-2-prepare-release.sh +++ b/tools/release-2-prepare-release.sh @@ -34,7 +34,7 @@ IFS='.' read -ra VERSION_SEGMENTS <<< "$RELEASE_VERSION" NEW_VERSION="${VERSION_SEGMENTS[0]}.${VERSION_SEGMENTS[1]}.$((VERSION_SEGMENTS[2] + 1))-SNAPSHOT" # 1. Do a simple release-prepare command -../mvnw -f ../pom.xml -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=$DIRECTORY/../out/.repository release:prepare -DautoVersionSubmodules=true -DreleaseVersion="$RELEASE_VERSION" -DdevelopmentVersion="$NEW_VERSION" -Dtag="v$RELEASE_VERSION" +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository release:prepare -DautoVersionSubmodules=true -DreleaseVersion="$RELEASE_VERSION" -DdevelopmentVersion="$NEW_VERSION" -Dtag="v$RELEASE_VERSION" if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-3-perform-release.sh b/tools/release-3-perform-release.sh index d557e9a048a..dd60b86b33c 100755 --- a/tools/release-3-perform-release.sh +++ b/tools/release-3-perform-release.sh @@ -23,7 +23,8 @@ # 1. Do a simple release-perform command skip signing of artifacts and deploy to local directory (inside the Docker container) echo "Performing Release:" -docker compose run --rm releaser bash /ws/mvnw -e -Dmaven.repo.local=/ws/out/.repository -DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-artifacts-dir release:perform +docker compose build +docker compose run releaser bash /ws/mvnw -e -Dmaven.repo.local=/ws/out/.repository -DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-artifacts-dir release:perform if [ $? -ne 0 ]; then echo "Got non-0 exit code from docker compose, aborting." exit 1 diff --git a/tools/release-abort.sh b/tools/release-abort.sh index e31190015db..f694898160a 100755 --- a/tools/release-abort.sh +++ b/tools/release-abort.sh @@ -42,7 +42,7 @@ DIRECTORY=$(pwd) PRE_RELEASE_VERSION=0.12.0-SNAPSHOT # Set the local development version back to the initial one. -../mvnw -f ../pom.xml -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,update-generated-code -Dmaven.repo.local="$DIRECTORY/../out/.repository" versions:set -DnewVersion="$PRE_RELEASE_VERSION" +docker compose run releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,update-generated-code -Dmaven.repo.local=/ws/out/.repository versions:set -DnewVersion="$PRE_RELEASE_VERSION" # Delete left-over files from the last attempt. find .. -type f -name 'release.properties' -delete diff --git a/tools/validate-release.sh b/tools/validate-release.sh new file mode 100755 index 00000000000..18992aede26 --- /dev/null +++ b/tools/validate-release.sh @@ -0,0 +1,107 @@ +#!/usr/bin/env bash + +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# 0. Check if the release properties file exists. + +# 1. Do a simple release-perform command skip signing of artifacts and deploy to local directory (inside the Docker container) +echo "Validate Release:" +docker compose build +if ! docker compose run releaser bash /ws/mvnw -e -Dmaven.repo.local=/ws/out/.repository -Dreference.repo=https://repository.apache.org/content/repositories/staging/ -Dbuildinfo.reproducible verify artifact:compare; +then + echo "Got non-0 exit code from docker compose, aborting." + exit 1 +fi