Skip to content

Commit

Permalink
[script] support both 22.04 and 24.04
Browse files Browse the repository at this point in the history
  • Loading branch information
fffonion committed Jul 5, 2024
1 parent fbbd10f commit e686083
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
17 changes: 13 additions & 4 deletions build-new-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,21 @@ if [[ -z $DOCKERHUB_LOGIN || -z $DOCKERHUB_PASSWORD ]]; then
exit 1
fi

rel=${1:-22}

if [[ $rel != "22" && $rel != "24" ]]; then
echo "Only support Ubuntu 22.04 and 24.04"
exit 1
fi

echo "Using ${rel}.04"

git fetch --tags -f

if [[ $(arch) == "aarch64" ]]; then
tag=$(git tag|grep ubuntu24|sort| grep -P '\.\d+-arm64$'| tail -n1)
tag=$(git tag|grep ubuntu${rel}|sort| grep -P '\.\d+-arm64$'| tail -n1)
else
tag=$(git tag|grep ubuntu24|sort| grep -P '\.\d+$'| grep -v arm64| tail -n1)
tag=$(git tag|grep ubuntu${rel}|sort| grep -P '\.\d+$'| grep -v arm64| tail -n1)
fi

echo "Use tag $tag"
Expand All @@ -23,7 +32,7 @@ echo "Use version $version"
pushd images/ubuntu/templates
cp /usr/share/AAVMF/AAVMF_CODE.fd flash1.img || true
rm -rf output-custom_image
packer build -var dockerhub_login=$DOCKERHUB_LOGIN -var dockerhub_password=$DOCKERHUB_PASSWORD -var image_version=$version ./ubuntu-24.04.pkr.hcl
packer build -var dockerhub_login=$DOCKERHUB_LOGIN -var dockerhub_password=$DOCKERHUB_PASSWORD -var image_version=$version ./ubuntu-${rel}.04.pkr.hcl

mv output-custom_image/ubuntu-24.04 /root/ubuntu-24.04-$version
mv output-custom_image/ubuntu-${rel}.04 /root/ubuntu-${rel}.04-$version
popd
27 changes: 21 additions & 6 deletions make-new-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ if [[ "$OSTYPE" == darwin* ]]; then
GREP=ggrep
fi

urel=${1:-22}

if [[ $urel != "22" && $urel != "24" ]]; then
echo "Only support Ubuntu 22.04 and 24.04"
exit 1
fi

echo "Using ${urel}.04"


cherry() {
c=$1
git cherry-pick $c
Expand All @@ -26,16 +36,21 @@ git remote add upstream https://github.com/actions/runner-images 2>/dev/null ||
git fetch upstream --tags 2>/dev/null || true
git fetch origin 2>/dev/null || true

rel=$(gh release list -R actions/runner-images|$GREP -oP "ubuntu24/[\d\.]+"|head -n1)
last_kvm_branch=origin/$(git branch|grep kvm|grep -v arm64|grep -v $rel|sort|tail -n1|awk '{print $1}')
last_arm64_branch=origin/$(git branch|grep kvm-arm64|grep -v $rel|sort|tail -n1|awk '{print $1}')
rel=$(gh release list -R actions/runner-images|$GREP -oP "ubuntu${urel}/[\d\.]+"|head -n1)
last_kvm_branch=$(git branch -r|grep kvm|grep -v arm64|grep -v $rel|grep ubuntu${urel}|sort|tail -n1|awk '{print $1}')
last_arm64_branch=$(git branch -r|grep kvm-arm64|grep -v $rel|grep ubuntu${urel}|sort|tail -n1|awk '{print $1}')

echo "The latest upstream release tag is $rel"
echo "Cherry pick from $last_kvm_branch and $last_arm64_branch"
if [[ -z $last_kvm_branch || -z $last_arm64_branch ]]; then
echo "Cannot find last time branch to cherry pick from"
exit 0
fi

git checkout $rel

git branch -D ${rel}-kvm 2>/dev/null
git checkout -b ${rel}-kvm 2>/dev/null
git checkout --no-track -b ${rel}-kvm 2>/dev/null
git clean -f
git pull origin ${rel}-kvm --rebase 2>/dev/null
for c in $(git log --reverse -n 2 --pretty=format:"%H" $last_kvm_branch); do
Expand All @@ -47,7 +62,7 @@ push -f refs/tags/${rel}
gh release create $rel --notes "https://github.com/actions/runner-images/releases/tag/${rel//\//%2F}"

git branch -D ${rel}-kvm-arm64 2>/dev/null
git checkout -b ${rel}-kvm-arm64 2>/dev/null
git checkout --no-track -b ${rel}-kvm-arm64 2>/dev/null
git clean -f
git pull origin ${rel}-kvm-arm64 --rebase 2>/dev/null
# total of 4 commits for arm64
Expand All @@ -57,7 +72,7 @@ done

# sanity check
what=0
for f in $(grep images/ubuntu/scripts/ -rPe "(?:x86_64|amd64)"|cut -d: -f1|sort|uniq); do
for f in $($GREP images/ubuntu/scripts/ -rPe "(?:x86_64|amd64)"|cut -d: -f1|sort|uniq); do
ff=$(echo $f|cut -d/ -f3-5)
fff=$(cat images/ubuntu/templates/ubuntu-22.04.pkr.hcl | grep $ff )
if [[ ! -z "$fff" && -z $(echo $fff |grep "//") ]]; then
Expand Down

0 comments on commit e686083

Please sign in to comment.