Install Packages

This action installs dependencies from multiple package managers for a workflow. This is usually the next step in your workflow after setting up a C++ compiler with Setup C++.

The action currently supports installing packages with apt-get and vcpkg. A number of auxiliary options are available to customize the behavior of both apt-get and vcpkg.

If vcpkg dependencies are required, vcpkg will be installed and related paths are returned from the action. Both vcpkg and its compiled dependencies are cached.

When your library depends on vcpkg for dependencies, it’s important to run the Setup C++ action before this step because vcpkg packages are built from source and this allows us to use the compiler set up in the previous step.

Next steps

After setting up the dependencies for your C++ project, the next step in your workflow should usually be CMake Workflow.

Alternatively, if your libraries depends on Boost, the next step in your workflow should usually be Boost Clone, which allows the workflow to only download the required subset of Boost libraries required by the project.

Example

steps:
- name: Install packages
  uses: alandefreitas/cpp-actions/package-install@v1.8.7
  id: package-install
  with:
    vcpkg: ${{ matrix.vcpkg-packages }}
    vcpkg-triplet: ${{ matrix.triplet }}
    apt-get: ${{ matrix.install }}
    apt-get-ignore-missing: ${{ matrix.is-container }}
    cc: ${{ steps.setup-cpp.outputs.cc }}
    ccflags: ${{ matrix.ccflags }}
    cxx: ${{ steps.setup-cpp.outputs.cxx }}
    cxxflags: ${{ matrix.cxxflags }}

Input Parameters

Parameter

Description

Default

vcpkg

List of packages we should install with vcpkg.

If any package is included in this list, vcpkg will be installed and the vcpkg toolchain file will be returned.

Individual packages can define a custom triplet by appending :<triplet> to the package name.

apt-get

List of packages we should install with apt-get.

Additional options are provided to customize the behavior of apt-get.

cxx

C++ compiler to be used by vcpkg. If the compiler is not specified, the value will be retrieved from the environment variable CXX.

Setting the compiler is particularly important when the compiler being tested is different from the default compiler used by vcpkg.

cxxflags

C++ flags used by vcpkg. If the flags are not specified, the value will be retrieved from the environment variable CXXFLAGS.

cc

C compiler used by vcpkg. If the compiler is not specified, the value will be retrieved from the environment variable CC.

ccflags

C flags used by vcpkg. If the flags are not specified, the value will be retrieved from the environment variable CFLAGS.

vcpkg-triplet

The triplet used by vcpkg to install packages.

If no triplet is specified, a default triplet will be inferred from the platform.

Individual packages can override this value by specifying a triplet in the package name.

vcpkg-dir

The directory where vcpkg should be cloned and installed.

If the directory is unspecified, the runner tool cache is used.

vcpkg-branch

vcpkg branch we should use. This is usually the master branch.

master

vcpkg-cache

Whether we should cache vcpkg and its built dependencies.

This is useful when you want to speed up your workflow by caching vcpkg and its built dependencies for next workflows.

You can disable this option when you want to always build vcpkg and its dependencies from scratch or want to save cache storage.

true

vcpkg-force-install

Whether we should force install vcpkg and even when no vcpkg packages are listed.

This is useful when you want to use vcpkg in manifest mode.

false

apt-get-retries

Number of times we should retry when apt-get fails.

This option is useful when apt-get fails due to a temporary network issue.

When calling apt-get to install packages, this passes the -o Acquire::Retries option to apt-get.

For other commands, the command will be called multiple times until it succeeds or the number of retries is exhausted. Each retry will be separated by a delay with an exponential backoff.

5

apt-get-sources

List of sources for apt-get.

Sources are installed with apt-add-repository.

apt-get-source-keys

List of source keys for apt-get.

Source keys are installed with apt-key.

apt-get-ignore-missing

Whether apt-get should ignore missing packages.

This attempts to install packages one by one and passes the --ignore-missing option to apt-get.

false

apt-get-add-architecture

Argument to pass to dpkg to add an architecture.

This is useful when installing packages that require a different architecture than the default one.

If this string is not empty, it will be passed to dpkg with the --add-architecture flag.

Common values for this parameter are: amd64 (64-bit x86), i386 (32-bit x86), armhf (ARM Hard Float), arm64 (ARM 64-bit), and ppc64el (PowerPC 64-bit Little Endian).

This parameter can also be a list of architectures.

apt-get-bulk-install

This option determines if we should call apt-get once for each package (false) or if we should call apt-get once for all packages (true).

This option is useful when installing a large number of packages, since it can speed up the installation process.

However, installing libraries individually provides more better information in the logs, which can be useful for debugging.

false

trace-commands

Trace commands executed by the action.

false

Outputs

Output

Description

vcpkg-toolchain

vcpkg toolchain file

This output value can be used to configure CMake to use vcpkg.

vcpkg-executable

vcpkg executable file