Skip to content

Commit

Permalink
Pack containers into GitHub CI (#615)
Browse files Browse the repository at this point in the history
* Pack containers during GitHub CI release.sh

These .tar.gzs can be later used by common non-podman capable builders
(copr) to create rpms with the container images.

Signed-off-by: Miguel Angel Ajo <majopela@redhat.com>

* Address comments for Makefile
  • Loading branch information
mangelajo authored Mar 7, 2022
1 parent 27241be commit 58acf59
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
password: ${{ secrets.REGISTRY_PASSWORD }}

- name: Install required packages
run: sudo apt-get update && sudo apt install build-essential qemu-user qemu-user-static
run: sudo apt-get update && sudo apt install build-essential qemu-user qemu-user-static podman

- name: Checkout source
uses: actions/checkout@v2
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,14 @@ build-containerized-all-in-one-iptables-arm64:
+$(MAKE) _build_containerized_aio ARCH=arm64 IPTABLES=iptables
.PHONY: build-containerized-all-in-one-iptables-arm64

###############################
# container image packaging #
###############################

tar-ocp-containers:
sudo ./packaging/images/components/archive.sh
.PHONY: image-tars

###############################
# dev targets #
###############################
Expand Down
43 changes: 43 additions & 0 deletions packaging/images/components/archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
get="${SCRIPT_DIR}/../../../pkg/release/get.sh"

ARCHITECTURES=${ARCHITECTURES:-"arm64 amd64"}
BASE_VERSION=${BASE_VERSION:-$("${get}" base)}
OUTPUT_DIR=${OUTPUT_DIR:-$(pwd)/archive}

TMP_DIR=$(mktemp -d)

mkdir -p "${OUTPUT_DIR}"
chmod a+rwx "${OUTPUT_DIR}"

for arch in $ARCHITECTURES; do
images=$("${get}" images $arch)
storage="${TMP_DIR}/${arch}/containers"
mkdir -p "${storage}"
echo "Pulling images for architecture ${arch} ==================="
for image in $images; do
echo pulling $image @$arch
# some imported images are armhfp instead of arm
podman pull --arch $arch --root "${storage}" "${image}"
if [ $? -ne 0 ]; then
if [ "${arch}" == "arm" ]; then
echo "Fallback arm -> armhfp"
podman pull --arch armhfp --root "${TMP_DIR}/${arch}" "${image}" || exit 1
else
echo "Couldn't pull image ${image} for ${arch}"
exit 1
fi
fi
done

echo ""
echo "Packing tarball for architecture ${arch} =================="
pushd ${storage}
output_file="${OUTPUT_DIR}/microshift-containers-${BASE_VERSION}-${arch}.tar.bz2"
echo " > ${output_file}"
tar cfj "${OUTPUT_DIR}/microshift-containers-${BASE_VERSION}-${arch}.tar.bz2" .
chmod a+rw "${OUTPUT_DIR}/microshift-containers-${BASE_VERSION}-${arch}.tar.bz2"
popd
rm -rf ${storage}
done
3 changes: 3 additions & 0 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,9 @@ if [ $NIGHTLY -eq 1 ]; then
exit 0
fi

# create container tar.gzs for the consumed container images for non-nightly releases
ARCHITECTURES="amd64 arm64" OUTPUT_DIR="${STAGE_DIR}" sudo -E "${ROOT}/packaging/image/components/archive.sh" || exit 1

# publish binaries
UPLOAD_URL="$(git_create_release "$API_DATA" "$TOKEN")" || exit 1
git_post_artifacts "$STAGE_DIR" "$UPLOAD_URL" "$TOKEN" || exit 1

0 comments on commit 58acf59

Please sign in to comment.