diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd6f69bd1..ab19ea9a4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -38,7 +38,6 @@ env: ANAX_CSS_VERSION: ${{ github.event.inputs.ANAX_CSS_VERSION }} ANAX_ESS_VERSION: ${{ github.event.inputs.ANAX_ESS_VERSION }} # Space delimited arrays used in shell scripts, specifying what images should be promoted to what tags in Dockerhub - DOCKERHUB_REGISTRY_RELEASE_TAGS: "latest" AGBOT_VERSION_IMAGES: "amd64_agbot" ANAX_VERSION_IMAGES: "amd64_anax arm64_anax ppc64el_anax s390x_anax" ANAX_K8S_VERSION_IMAGES: "amd64_anax_k8s amd64_auto-upgrade-cronjob_k8s arm64_anax_k8s arm64_auto-upgrade-cronjob_k8s ppc64el_anax_k8s ppc64el_auto-upgrade-cronjob_k8s s390x_anax_k8s s390x_auto-upgrade-cronjob_k8s" @@ -115,7 +114,7 @@ jobs: username: ${{ secrets.DOCKER_USER }} password: ${{ secrets.DOCKER_TOKEN }} - # Get the images for agbot based on the inputted version, + # Get the images based on the inputted version - name: Get and Promote ${{ matrix.image-version }} Images run: | IMAGE_LIST=$${{ matrix.image-version }}_IMAGES @@ -124,16 +123,180 @@ jobs: IMAGES_TO_LOAD=($IMAGE_LIST) RELEASE_TAGS=($DOCKERHUB_REGISTRY_RELEASE_TAGS) for image in "${IMAGES_TO_LOAD[@]}"; do - gh run download -n anax-linux-${image}-image-v${IMAGE_VERSION} - cat ${image}.tar.gz | docker load - for tag in "${RELEASE_TAGS[@]}"; do - docker push ${DOCKERHUB_REGISTRY}/${image}:${IMAGE_VERSION} - - docker tag ${DOCKERHUB_REGISTRY}/${image}:${IMAGE_VERSION} ${DOCKERHUB_REGISTRY}/${image}:${tag} - docker push ${DOCKERHUB_REGISTRY}/${image}:${tag} - done + + if gh run download -n anax-linux-${image}-image-v${IMAGE_VERSION}; then + echo "::debug::Using artifact from build-push.yml run" + cat ${image}.tar.gz | docker load + elif docker pull ${DOCKERHUB_REGISTRY}/${image}:${IMAGE_VERSION}; then + echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." + else + echo "::error::Artifact anax-linux-${image}-image-v${IMAGE_VERSION} not found in build-push.yml artifacts and Docker image ${image}:${IMAGE_VERSION} not found in Dockerhub" + exit 1 + fi + + docker push ${DOCKERHUB_REGISTRY}/${image}:${IMAGE_VERSION} + + if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + docker tag ${DOCKERHUB_REGISTRY}/${image}:${IMAGE_VERSION} ${DOCKERHUB_REGISTRY}/${image}:latest + docker push ${DOCKERHUB_REGISTRY}/${image}:latest + fi + done + shell: bash + + - name: Get and Promote Package Artifacts to Dockerhub + if: matrix.image-version == 'AGBOT_VERSION' + run: | + mkdir -p $RUNNER_TEMP/artifact_promotion_dir && cd $RUNNER_TEMP/artifact_promotion_dir + + DEB_PACKAGES_TO_LOAD=("amd64" "arm64" "armhf" "ppc64el" "s390x") + RPM_PACKAGES_TO_LOAD=("ppc64el" "amd64" "s390x") + MAC_PACKAGES_TO_LOAD=("amd64" "arm64") + + ################################# BACKUP DEB PACKAGES ################################# + touch Dockerfile.debs.tarball + echo "FROM alpine:latest" >> Dockerfile.debs.tarball + echo "ADD ./debs.tar.gz ." >> Dockerfile.debs.tarball + + for arch_name in "${DEB_PACKAGES_TO_LOAD[@]}"; do + mkdir -p ./debs + # If the packages exist as artifacts we want to download them and make sure that we push the version number to dockerhub for fallback purposes + if gh run download -n anax-linux-${arch_name}-deb-package-v${AGBOT_VERSION} -D ./debs; then + echo "::debug::Using artifact from build-push.yml run" + tar -czvf debs.tar.gz debs/*.deb + + docker build \ + --no-cache \ + -t ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} \ + -f Dockerfile.debs.tarball \ + . + + rm -rf ./debs.tar.gz + + docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} + + if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:latest + docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:latest + fi + + # If the packages do not exist as artifacts we want to simply fallback to dockerhub and if we are on master then tie the latest release to that package + elif docker pull ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION}; then + echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." + if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:latest + docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:latest + fi + else + echo "::error::Artifact anax-linux-${arch_name}-deb-package-v${AGBOT_VERSION} not found in build-push.yml artifacts and Docker image ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} not found in Dockerhub" + exit 1 + fi + rm -rf ./debs + done + + ################################# BACKUP RPM PACKAGES ################################# + touch Dockerfile.rpm.tarball + echo "FROM alpine:latest" >> Dockerfile.rpm.tarball + echo "ADD ./rpm.tar.gz ." >> Dockerfile.rpm.tarball + + for arch_name in "${RPM_PACKAGES_TO_LOAD[@]}"; do + mkdir -p ./RPMS + # If the packages exist as artifacts we want to download them and make sure that we push the version number to dockerhub for fallback purposes + if gh run download -n anax-linux-${arch_name}-rpm-package-v${AGBOT_VERSION} -D ./RPMS; then + echo "::debug::Using artifact from build-push.yml run" + tar -czvf rpm.tar.gz RPMS/*.rpm + + docker build \ + --no-cache \ + -t ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} \ + -f Dockerfile.rpm.tarball \ + . + + rm -rf ./rpm.tar.gz + + docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} + + if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:latest + docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:latest + fi + + # If the packages do not exist as artifacts we want to simply fallback to dockerhub and if we are on master then tie the latest release to that package + elif docker pull ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION}; then + echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." + if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:latest + docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:latest + fi + else + echo "::error::Artifact anax-linux-${arch_name}-rpm-package-v${AGBOT_VERSION} not found in build-push.yml artifacts and Docker image ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} not found in Dockerhub" + exit 1 + fi + rm -rf ./RPMS done + ################################# BACKUP MAC PACKAGES ################################# + touch Dockerfile.macpkg.tarball + echo "FROM alpine:latest" >> Dockerfile.macpkg.tarball + echo "ADD ./macpkg.tar.gz ." >> Dockerfile.macpkg.tarball + + for arch_name in "${MAC_PACKAGES_TO_LOAD[@]}"; do + mkdir -p ./macs + if gh run download -n anax-mac-${arch_name}-mac-package-v${AGBOT_VERSION} -D ./macs; then + echo "::debug::Using artifact from build-push.yml run" + tar -czvf macpkg.tar.gz macs + + docker build \ + --no-cache \ + -t ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} \ + -f Dockerfile.macpkg.tarball \ + . + + rm -rf ./macpkg.tar.gz + + docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} + + if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:latest + docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:latest + fi + + elif docker pull ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION}; then + echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." + if [[ "$GITHUB_REF" == 'refs/heads/master' ]]; then + docker tag ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:latest + docker push ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:latest + fi + else + echo "::error::Artifact anax-mac-${arch_name}-mac-package-v${AGBOT_VERSION} not found in build-push.yml artifacts and Docker image ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} not found in Dockerhub" + exit 1 + fi + rm -rf ./macs + done + + + ################################ BACKUP AGENT PACKAGES ################################ + touch Dockerfile.agent.tarball + echo "FROM alpine:latest" >> Dockerfile.agent.tarball + echo "ADD ./agent.tar.gz ." >> Dockerfile.agent.tarball + + mkdir -p ./agents + if gh run download -n anax-agent-files-v${AGBOT_VERSION} -D ./agents; then + echo "::debug::Using artifact from build-push.yml run" + tar -czvf agents.tar.gz agents + + docker build \ + --no-cache \ + -t ${DOCKERHUB_REGISTRY}/anax_agent_files:${AGBOT_VERSION} \ + -f Dockerfile.agent.tarball \ + . + + rm -rf ./agents.tar.gz + + docker push ${DOCKERHUB_REGISTRY}/anax_agent_files:${AGBOT_VERSION} + fi + rm -rf ./agents + shell: bash + create-release: needs: promote-images @@ -145,38 +308,85 @@ jobs: run: | mkdir -p $RUNNER_TEMP/release_files/upload && cd $RUNNER_TEMP/release_files - # Debian Packages - gh run download -n anax-linux-amd64-deb-package-v${AGBOT_VERSION} - tar -czvf upload/horizon-agent-linux-deb-amd64.tar.gz *.deb - rm -rf *.deb - gh run download -n anax-linux-arm64-deb-package-v${AGBOT_VERSION} - tar -czvf upload/horizon-agent-linux-deb-arm64.tar.gz *.deb - rm -rf *.deb - gh run download -n anax-linux-armhf-deb-package-v${AGBOT_VERSION} - tar -czvf upload/horizon-agent-linux-deb-armhf.tar.gz *.deb - rm -rf *.deb - gh run download -n anax-linux-ppc64el-deb-package-v${AGBOT_VERSION} - tar -czvf upload/horizon-agent-linux-deb-ppc64el.tar.gz *.deb - rm -rf *.deb - gh run download -n anax-linux-s390x-deb-package-v${AGBOT_VERSION} - tar -czvf upload/horizon-agent-linux-deb-s390x.tar.gz *.deb - rm -rf *.deb - - # RPM Packages - gh run download -n anax-linux-ppc64el-rpm-package-v${AGBOT_VERSION} - tar -czvf upload/horizon-agent-linux-rpm-ppc64le.tar.gz *.rpm - rm -rf *.rpm - gh run download -n anax-linux-amd64-rpm-package-v${AGBOT_VERSION} - tar -czvf upload/horizon-agent-linux-rpm-x86_64.tar.gz *.rpm - rm -rf *.rpm - gh run download -n anax-linux-s390x-rpm-package-v${AGBOT_VERSION} - tar -czvf upload/horizon-agent-linux-rpm-s390x.tar.gz *.rpm - rm -rf *.rpm - - # MacOS Packages ??ARM?? - gh run download -n anax-mac-amd64-mac-package-v${AGBOT_VERSION} - tar -czvf upload/horizon-agent-macos-pkg-x86_64.tar.gz horizon* - rm -rf horizon* + DEB_PACKAGES_TO_LOAD=("amd64" "arm64" "armhf" "ppc64el" "s390x") + RPM_PACKAGES_TO_LOAD=("ppc64el" "amd64" "s390x") + MAC_PACKAGES_TO_LOAD=("amd64" "arm64") + + for arch_name in "${DEB_PACKAGES_TO_LOAD[@]}"; do + if gh run download -n anax-linux-${arch_name}-deb-package-v${AGBOT_VERSION}; then + echo "::debug::Using artifact from build-push.yml run" + tar -czvf upload/horizon-agent-linux-deb-${arch_name}.tar.gz *.deb + rm -rf *.deb + elif docker pull ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION}; then + echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." + id=$(docker create --name temp_image_grab ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION}) + docker cp ${id}:debs . && cd debs + tar -czvf upload/horizon-agent-linux-deb-${arch_name}.tar.gz *.deb + cd .. + rm -rf ./debs + docker container rm ${id} + docker image rm ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} + else + echo "::error::Artifact anax-linux-${arch_name}-deb-package-v${AGBOT_VERSION} not found in build-push.yml artifacts and Docker image ${DOCKERHUB_REGISTRY}/${arch_name}_anax_debian:${AGBOT_VERSION} not found in Dockerhub" + exit 1 + fi + done + + for arch_name in "${RPM_PACKAGES_TO_LOAD[@]}"; do + + if [[ ${arch_name} == 'ppc64el' ]]; then + publish_name='ppc64le' + elif [[ ${arch_name} == 'amd64' ]]; then + publish_name='x86_64' + else + publish_name=$arch_name + fi + + if gh run download -n anax-linux-${arch_name}-rpm-package-v${AGBOT_VERSION}; then + echo "::debug::Using artifact from build-push.yml run" + tar -czvf upload/horizon-agent-linux-rpm-${publish_name}.tar.gz *.rpm + rm -rf *.rpm + elif docker pull ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION}; then + echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." + id=$(docker create --name temp_image_grab ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION}) + docker cp ${id}:RPMS . && cd RPMS + tar -czvf upload/horizon-agent-linux-rpm-${publish_name}.tar.gz *.rpm + cd .. + rm -rf ./RPMS + docker container rm ${id} + docker image rm ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} + else + echo "::error::Artifact anax-linux-${arch_name}-rpm-package-v${AGBOT_VERSION} not found in build-push.yml artifacts and Docker image ${DOCKERHUB_REGISTRY}/${arch_name}_anax_rpm:${AGBOT_VERSION} not found in Dockerhub" + exit 1 + fi + done + + for arch_name in "${MAC_PACKAGES_TO_LOAD[@]}"; do + + if [[ ${arch_name} == 'amd64' ]]; then + publish_name='x86_64' + else + publish_name=$arch_name + fi + + if gh run download -n anax-mac-${arch_name}-mac-package-v${AGBOT_VERSION}; then + echo "::debug::Using artifact from build-push.yml run" + tar -czvf upload/horizon-agent-macos-pkg-${publish_name}.tar.gz horizon* + rm -rf horizon* + elif docker pull ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION}; then + echo "::warning::Artifact not found in build-push.yml workflow, using docker image instead." + id=$(docker create --name temp_image_grab ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION}) + docker cp ${id}:macs . && cd macs + tar -czvf upload/horizon-agent-macos-pkg-${publish_name}.tar.gz horizon* + cd .. + rm -rf ./macs + docker container rm ${id} + docker image rm ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} + else + echo "::error::Artifact anax-mac-${arch_name}-mac-package-v${AGBOT_VERSION} not found in build-push.yml artifacts and Docker image ${DOCKERHUB_REGISTRY}/${arch_name}_anax_macpkg:${AGBOT_VERSION} not found in Dockerhub" + exit 1 + fi + done # Agent Files cd ./upload