Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a script to update version of Ankaios #339

Merged
merged 4 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions tools/ankaios-docker/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ services:
ank-server:
build:
context: ./server
args:
- VERSION=v0.4.0
ports:
- "25551:25551"
ank-agent:
build:
context: ./agent
args:
- VERSION=v0.4.0
privileged: true
82 changes: 82 additions & 0 deletions tools/update_version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
#!/bin/bash

# Copyright (c) 2023 Elektrobit Automotive GmbH
windsource marked this conversation as resolved.
Show resolved Hide resolved
#
# 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")
inf17101 marked this conversation as resolved.
Show resolved Hide resolved

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