-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
image: build dev and release image for all arch
Fixed: #1521 Signed-off-by: Qi Feng Huo <[email protected]>
- Loading branch information
Qi Feng Huo
committed
Oct 19, 2023
1 parent
d8669ae
commit c3d838b
Showing
3 changed files
with
115 additions
and
16 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,72 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o errexit | ||
set -o pipefail | ||
set -o nounset | ||
|
||
script_dir=$(dirname "$(readlink -f "$0")") | ||
|
||
registry="${registry:-quay.io/confidential-containers}" | ||
name="cloud-api-adaptor" | ||
commit=${COMMIT:-unknown} | ||
commits_file="./commits.txt" | ||
read_commit_hash="" | ||
|
||
if [[ "$commit" = unknown ]]; then | ||
commit=$(git rev-parse HEAD) | ||
[[ -n "$(git status --porcelain --untracked-files=no)" ]] && commit+='-dirty' | ||
fi | ||
|
||
function generate_commit_hash_file() { | ||
echo "generate_commit_hash_file" | ||
pushd "${script_dir}/.." | ||
echo "commit="$commit > $commits_file | ||
popd | ||
} | ||
|
||
function get_commit_from_file() { | ||
echo "get_commit_from_file" | ||
pushd "${script_dir}/.." | ||
if [[ -f $commits_file ]]; then | ||
COMMIT_HASH_STR=$(cat $commits_file | grep commit) | ||
read_commit_hash=${COMMIT_HASH_STR#"commit="} | ||
else | ||
echo "Did not find file: $commits_file" | ||
popd | ||
exit 99 | ||
fi | ||
popd | ||
} | ||
|
||
function pull_images() { | ||
release_tag_string="${registry}/${name}:${read_commit_hash}" | ||
dev_tag_string="${registry}/${name}:dev-${read_commit_hash}" | ||
} | ||
|
||
function build_push_image_manifest() { | ||
get_commit_from_file | ||
if [[ -z $read_commit_hash ]]; then | ||
echo "empty variale: read_commit_hash" | ||
exit 99 | ||
fi | ||
|
||
pull_images | ||
} | ||
|
||
# Get the options | ||
while getopts ":rwm" option; do | ||
case $option in | ||
r) # read commit hash | ||
get_commit_from_file | ||
exit;; | ||
w) # write commit hash | ||
generate_commit_hash_file | ||
exit;; | ||
m) # generate image manifest | ||
build_push_image_manifest | ||
exit;; | ||
\?) # Invalid option | ||
echo "Error: Invalid option" | ||
esac | ||
done | ||
|