-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide a script to update version of Ankaios (#339)
* Provide a script to update version of Ankaios Issue-Id: #337 * Improve logging Issue-Id: #337 * Fix review findings. Issue-Id: #337
- Loading branch information
1 parent
f5b7a30
commit fda0fa1
Showing
3 changed files
with
83 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/bin/bash | ||
|
||
# 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 | ||
# 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 ) | ||
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 | ||
} | ||
|
||
log_update() { | ||
echo "Updating $(realpath -e --relative-base="$(pwd)" "$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" | ||
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 | ||
# 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 | ||
|
||
|
||
|