diff --git a/.github/workflows/cleanup_container_tags.yml b/.github/workflows/cleanup_container_tags.yml index 68a30b88e..7a0c15282 100644 --- a/.github/workflows/cleanup_container_tags.yml +++ b/.github/workflows/cleanup_container_tags.yml @@ -3,13 +3,27 @@ name: Cleanup container tags on: delete jobs: + organization_containers: + name: Get all containers in the organization + runs-on: ubuntu-latest + outputs: + packages: ${{ steps.organization_containers.outputs.packages }} + steps: + - name: Organization containers + id: organization_containers + uses: tue-robotics/tue-env/ci/organization-packages@master + with: + package-type: container + token: ${{ secrets.READ_PACKAGES_TOKEN }} + delete_container_tag: name: Delete container tag runs-on: ubuntu-latest + needs: organization_containers strategy: fail-fast: false matrix: - package_name: ["tue-env-ros-noetic", "tue-env-ros-galactic", "tue-env-ros-humble"] + package_name: ${{ fromJson(needs.organization_containers.outputs.packages) }} steps: - name: Generate tag id: generate-tag diff --git a/.github/workflows/cleanup_untagged_containers.yml b/.github/workflows/cleanup_untagged_containers.yml index 968f11687..4badcf0fc 100644 --- a/.github/workflows/cleanup_untagged_containers.yml +++ b/.github/workflows/cleanup_untagged_containers.yml @@ -6,13 +6,27 @@ on: workflow_dispatch: jobs: + organization_containers: + name: Get all containers in the organization + runs-on: ubuntu-latest + outputs: + packages: ${{ steps.organization_containers.outputs.packages }} + steps: + - name: Organization containers + id: organization_containers + uses: tue-robotics/tue-env/ci/organization-packages@master + with: + package-type: container + token: ${{ secrets.READ_PACKAGES_TOKEN }} + delete_untagged_containers: name: Delete untagged containers runs-on: ubuntu-latest + needs: organization_containers strategy: fail-fast: false matrix: - package_name: ["tue-env-ros-noetic", "tue-env-ros-galactic", "tue-env-ros-humble"] + package_name: ${{ fromJson(needs.organization_containers.outputs.packages) }} steps: - uses: actions/delete-package-versions@v4 with: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4cb0b4b99..f1ecdd46f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -37,13 +37,15 @@ jobs: - ros-distro: noetic ros-version: 1 platform: "amd64" - - ros-distro: galactic + base-image: "ubuntu:20.04" + - ros-distro: humble ros-version: 2 platform: "amd64" - - ros-distro: humble + - ros-distro: rolling ros-version: 2 platform: "amd64" base-image: "ubuntu:22.04" + flavor: u22 outputs: key: ${{ steps.artifacts.outputs.key }} tag: ${{ steps.script.outputs.tag }} diff --git a/VERSION b/VERSION index f8f4f03b3..feaae22ba 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.12.1 +1.13.0 diff --git a/ci/build-docker-image.sh b/ci/build-docker-image.sh index 699d64454..afe39c71c 100755 --- a/ci/build-docker-image.sh +++ b/ci/build-docker-image.sh @@ -102,7 +102,7 @@ echo -e "\e[35;1mCI_TARGETS_REPO = ${CI_TARGETS_REPO}\e[0m" [[ -z "$CI_DOCKER_LOGIN" ]] && CI_DOCKER_LOGIN="false" echo -e "\e[35;1mCI_DOCKER_LOGIN = ${CI_DOCKER_LOGIN}\e[0m" -[[ -z "$CI_DOCKER_BASE_IMAGE" ]] && CI_DOCKER_BASE_IMAGE="ubuntu:20.04" +[[ -z "$CI_DOCKER_BASE_IMAGE" ]] && CI_DOCKER_BASE_IMAGE="ubuntu:22.04" echo -e "\e[35;1mCI_DOCKER_BASE_IMAGE = ${CI_DOCKER_BASE_IMAGE}\e[0m" echo -e "\e[35;1mCI_DOCKER_REGISTRY = ${CI_DOCKER_REGISTRY}\e[0m" diff --git a/ci/organization-packages.sh b/ci/organization-packages.sh new file mode 100644 index 000000000..0e93ce865 --- /dev/null +++ b/ci/organization-packages.sh @@ -0,0 +1,45 @@ +#! /usr/bin/env bash + +for i in "$@" +do + case $i in + -o=* | --organization=* ) + ORGANIZATION="${i#*=}" + ;; + -t=* | --type=* ) + PACKAGE_TYPE="${i#*=}" + ;; + --token=* ) + TOKEN="${i#*=}" + ;; + * ) + # unknown option + if [[ -n "${i}" ]] # Ignore empty arguments + then + echo -e "\e[35m\e[1mUnknown input argument '${i}'. Check CI .yml file\e[0m" + exit 1 + fi + ;; + esac + shift +done + +echo -e "\e[35m\e[1mORGANIZATION = ${ORGANIZATION}\e[0m" +echo -e "\e[35m\e[1mPACKAGE_TYPE = ${PACKAGE_TYPE}\e[0m" +echo -e "\e[35m\e[1mTOKEN length = ${#TOKEN}\e[0m" + +echo "::group::curl -L -H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer \${TOKEN}\" -H \"X-GitHub-Api-Version: 2022-11-28\" \"https://api.github.com/orgs/${ORGANIZATION}/packages?package_type=${PACKAGE_TYPE}&per_page=100&page=1\"" +echo -e "\e[1mcurl -L -H \"Accept: application/vnd.github+json\" -H \"Authorization: Bearer \${TOKEN}\" -H \"X-GitHub-Api-Version: 2022-11-28\" \"https://api.github.com/orgs/${ORGANIZATION}/packages?package_type=${PACKAGE_TYPE}&per_page=100&page=1\"" +output=$(curl -L -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${TOKEN}" -H "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/orgs/${ORGANIZATION}/packages?package_type=${PACKAGE_TYPE}&per_page=100&page=1") +echo -e "${output}" | jq -C +echo "::endgroup::" + +echo -e "\e[1mjq -r '.[].name'\e[0m" +packages=$(jq -r '.[].name' <<< "${output}") +echo -e "\e[35m\e[1mpackages:\e[0m" +for pkg in ${packages} +do + echo -e "\e[35m\e[1m ${pkg}\e[0m" + packages_list="${packages_list:+$packages_list, }'${pkg}'" +done +packages_list="[${packages_list}]" diff --git a/ci/organization-packages/action.yaml b/ci/organization-packages/action.yaml new file mode 100644 index 000000000..889c35aad --- /dev/null +++ b/ci/organization-packages/action.yaml @@ -0,0 +1,32 @@ +name: 'Organization packages' +description: 'Get the names of the packages in an organization' +inputs: + package-type: + description: 'Type of the packages' + required: true + type: string + default: 'container' + organization: + description: 'Name of the organization' + required: true + type: string + default: ${{ github.repository_owner }} + token: + description: 'GitHub token' + required: true + type: string + default: ${{ github.token }} +outputs: + packages: + description: 'Package names' + value: ${{ steps.packages.outputs.packages }} +runs: + using: "composite" + steps: + - name: Organization packages + id: packages + run: | + source ${{ github.action_path }}/../organization-packages.sh --organization=${{ inputs.organization }} --type=${{ inputs.package-type }} --token=${{ inputs.token }} + echo -e "\e[35m\e[1mpackages=${packages_list} >> \${GITHUB_OUTPUT}\e[0m" + echo "packages=${packages_list}" >> ${GITHUB_OUTPUT} + shell: bash --noprofile --norc -o pipefail {0} diff --git a/dockerfiles/tue-env.Dockerfile b/dockerfiles/tue-env.Dockerfile index 5d761c1cc..5f123aa27 100644 --- a/dockerfiles/tue-env.Dockerfile +++ b/dockerfiles/tue-env.Dockerfile @@ -3,8 +3,8 @@ # Dockerfile to build working Ubuntu image with tue-env # ---------------------------------------------------------------- -# Set default base image to Ubuntu 20.04 -ARG BASE_IMAGE=ubuntu:20.04 +# Set default base image to Ubuntu 22.04 +ARG BASE_IMAGE=ubuntu:22.04 FROM $BASE_IMAGE as base # ---------------------------------------------------------------- diff --git a/installer/bootstrap.bash b/installer/bootstrap.bash index e364be820..6d7d902e2 100755 --- a/installer/bootstrap.bash +++ b/installer/bootstrap.bash @@ -49,6 +49,9 @@ case $DISTRIB_RELEASE in elif [[ "${ros_distro}" == "galactic" ]] then TUE_ROS_DISTRO=galactic + elif [[ "${ros_distro}" == "rolling" ]] + then + TUE_ROS_DISTRO=rolling elif [[ -n "${ros_distro}" ]] then echo "[tue-env](bootstrap) Error! ROS ${ros_distro} is unsupported with tue-env." @@ -72,8 +75,27 @@ case $DISTRIB_RELEASE in fi ;; "22.04") - TUE_ROS_DISTRO=humble + if [[ -n "${ros_version}" ]] && [[ "${ros_version}" -ne 2 ]] + then + echo "[tue-env](bootstrap) Error! Only ROS version 2 is supported with ubuntu 22.04 and newer" + exit 1 + fi TUE_ROS_VERSION=2 + + if [[ "${ros_distro}" == "humble" ]] + then + TUE_ROS_DISTRO=humble + elif [[ "${ros_distro}" == "rolling" ]] + then + TUE_ROS_DISTRO=rolling + elif [[ -n "${ros_distro}" ]] + then + echo "[tue-env](bootstrap) Error! ROS ${ros_distro} is unsupported with tue-env." + exit 1 + else + TUE_ROS_DISTRO=humble + echo "[tue-env](bootstrap) Using default ROS_DISTRO '${TUE_ROS_DISTRO}' with ROS_VERSION '${TUE_ROS_VERSION}'" + fi ;; *) echo "[tue-env](bootstrap) Ubuntu $DISTRIB_RELEASE is unsupported. Please use one of Ubuntu 20.04 or 22.04." diff --git a/setup/generate_setup_file.py b/setup/generate_setup_file.py index d66c04f04..98172410a 100755 --- a/setup/generate_setup_file.py +++ b/setup/generate_setup_file.py @@ -1,6 +1,6 @@ #! /usr/bin/env python3 -from typing import IO, List +from typing import List import os import sys @@ -59,7 +59,8 @@ def _generate_setup_file_rec(self, target: str) -> List[str]: target_setup_file = os.path.join(self._tue_env_targets_dir, target, "setup") if os.path.isfile(target_setup_file): - lines.append(f"source {target_setup_file}\n") + rel_target_setup_file = os.path.relpath(target_setup_file, self._tue_env_dir) + lines.append(f"source ${{TUE_ENV_DIR}}/{rel_target_setup_file}\n") return lines