From 4d9bbe1456841b9ce6d9812d55c5532ce30df421 Mon Sep 17 00:00:00 2001 From: Holger Dormann Date: Mon, 5 Aug 2024 15:05:25 +0000 Subject: [PATCH 1/3] Provide a script to update version of Ankaios Issue-Id: #337 --- tools/ankaios-docker/compose.yaml | 4 --- tools/update_version.sh | 60 +++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 4 deletions(-) create mode 100755 tools/update_version.sh diff --git a/tools/ankaios-docker/compose.yaml b/tools/ankaios-docker/compose.yaml index 4401e1680..74ad2851a 100644 --- a/tools/ankaios-docker/compose.yaml +++ b/tools/ankaios-docker/compose.yaml @@ -2,16 +2,12 @@ services: ank-server: build: context: ./server - args: - - VERSION=v0.4.0-rc1 ports: - "25551:25551" ank-agent: build: context: ./agent - args: - - VERSION=v0.4.0-rc1 privileged: true diff --git a/tools/update_version.sh b/tools/update_version.sh new file mode 100755 index 000000000..3ab0837db --- /dev/null +++ b/tools/update_version.sh @@ -0,0 +1,60 @@ +#!/bin/bash +set -e + +script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +base_dir="$script_dir/.." +workspace_config="$base_dir/Cargo.toml" + +usage() { + echo "Usage: $0 [--release] VERSION" + echo "Update Ankaios files to VERSION." + echo " --release Official release with assets for download." + exit 1 +} + +# Initialize variables +release=0 +version="" + +# Parse arguments +while [[ "$#" -gt 0 ]]; do + case $1 in + --release) release=1; shift ;; + -h|--help) usage ;; + *) + if [[ -z "$version" ]]; then + version="$1" + else + echo "Error: Unknown parameter passed: $1" + usage + fi + shift + ;; + esac +done + +# Check if VERSION is set +if [[ -z "$version" ]]; then + echo "Error: VERSION is a mandatory argument." + usage +fi + +# Extract all packages from the workspace file +packages=$(awk '/members *= *\[/{flag=1; next} /\]/{flag=0} flag {gsub(/[" ,]/, ""); print}' "$workspace_config") + +for pkg in $packages; do + package_config="$base_dir/$pkg/Cargo.toml" + echo "Updating $package_config" + # Update version in Cargo.toml for a specific package + sed -i "/\[package\]/,/\[/{s/version = \"[^\"]*\"/version = \"$version\"/}" "$package_config" +done + +# Some versions must only be updated for official releases as only those provide assets for download +if [ "$release" = "1" ]; then + # Update ankaios-docker + sed -i "s/^ARG VERSION=.*/ARG VERSION=${version}/" "$base_dir/tools/ankaios-docker/agent/Dockerfile" + sed -i "s/^ARG VERSION=.*/ARG VERSION=${version}/" "$base_dir/tools/ankaios-docker/server/Dockerfile" +fi + + + From db5c63d2a8a0b829678244e1c774ebfb856c7c5d Mon Sep 17 00:00:00 2001 From: Holger Dormann Date: Tue, 6 Aug 2024 13:00:15 +0000 Subject: [PATCH 2/3] Improve logging Issue-Id: #337 --- tools/update_version.sh | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tools/update_version.sh b/tools/update_version.sh index 3ab0837db..54c7285ea 100755 --- a/tools/update_version.sh +++ b/tools/update_version.sh @@ -1,4 +1,19 @@ #!/bin/bash + +# Copyright (c) 2023 Elektrobit Automotive GmbH +# +# This program and the accompanying materials are made available under the +# terms of the Apache License, Version 2.0 which is available 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. +# +# SPDX-License-Identifier: Apache-2.0 + set -e script_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) @@ -12,6 +27,10 @@ usage() { exit 1 } +log_update() { + echo "Updating $(realpath -e --relative-base="$(pwd)" "$1")" +} + # Initialize variables release=0 version="" @@ -44,16 +63,19 @@ packages=$(awk '/members *= *\[/{flag=1; next} /\]/{flag=0} flag {gsub(/[" ,]/, for pkg in $packages; do package_config="$base_dir/$pkg/Cargo.toml" - echo "Updating $package_config" + log_update "$package_config" # Update version in Cargo.toml for a specific package sed -i "/\[package\]/,/\[/{s/version = \"[^\"]*\"/version = \"$version\"/}" "$package_config" done # Some versions must only be updated for official releases as only those provide assets for download if [ "$release" = "1" ]; then - # Update ankaios-docker - sed -i "s/^ARG VERSION=.*/ARG VERSION=${version}/" "$base_dir/tools/ankaios-docker/agent/Dockerfile" - sed -i "s/^ARG VERSION=.*/ARG VERSION=${version}/" "$base_dir/tools/ankaios-docker/server/Dockerfile" + # ankaios-docker + for f in server agent; do + dockerfile="$base_dir/tools/ankaios-docker/$f/Dockerfile" + log_update "$dockerfile" + sed -i "s/^ARG VERSION=.*/ARG VERSION=${version}/" "$dockerfile" + done fi From 123383c451999c4313ef47a6cf29214262fd1fd9 Mon Sep 17 00:00:00 2001 From: Holger Dormann Date: Mon, 19 Aug 2024 08:02:56 +0000 Subject: [PATCH 3/3] Fix review findings. Issue-Id: #337 --- doc/docs/development/ci-cd-release.md | 2 +- tools/update_version.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/docs/development/ci-cd-release.md b/doc/docs/development/ci-cd-release.md index 209d2c20e..9cf3953ae 100644 --- a/doc/docs/development/ci-cd-release.md +++ b/doc/docs/development/ci-cd-release.md @@ -117,7 +117,7 @@ The procedure uses the filters for pull request labels configured inside `.githu The following steps shall be done before the actual release build is triggered. 1. Create an isssue containing tasks for getting the main branch ready: - 1. Update the versions in the project packages (Cargo.toml files) to the new version. + 1. Update the versions in the project packages (Cargo.toml files) to the new version (use `tools/update_version.sh --release `). 2. Execute tests on the supported targets. 3. Make sure there are no security warnings of Github dependabot. 2. Finish all tasks inside the issue. diff --git a/tools/update_version.sh b/tools/update_version.sh index 54c7285ea..27b2e8ad8 100755 --- a/tools/update_version.sh +++ b/tools/update_version.sh @@ -1,6 +1,6 @@ #!/bin/bash -# Copyright (c) 2023 Elektrobit Automotive GmbH +# Copyright (c) 2024 Elektrobit Automotive GmbH # # This program and the accompanying materials are made available under the # terms of the Apache License, Version 2.0 which is available at