Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 70 additions & 4 deletions .github/workflows/release_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,35 @@ jobs:
with:
version: ${{ matrix.bazel }}

# The Ubuntu mirror is slow when many matrix jobs download at once, so we
# cache the downloaded .deb packages.
#
# actions/cache never overwrites an existing key, so we include the month in
# the key to pick up package updates. The OS image name (e.g., ubuntu24)
# keeps ubuntu-latest from restoring packages from an older release.
- name: Get apt Cache Key (Linux)
id: apt-cache-key
if: startsWith(matrix.os, 'ubuntu')
run: |
PREFIX="apt-${ImageOS}-${{ matrix.compiler }}-${{ matrix.version }}-"
echo "prefix=${PREFIX}" >> $GITHUB_OUTPUT
echo "key=${PREFIX}$(date +%Y-%m)" >> $GITHUB_OUTPUT

- name: Cache apt Packages (Linux)
if: startsWith(matrix.os, 'ubuntu')
uses: actions/cache@v4
Comment thread
adamshapiro0 marked this conversation as resolved.
Resolved
with:
path: ~/apt-cache
key: ${{ steps.apt-cache-key.outputs.key }}
restore-keys: ${{ steps.apt-cache-key.outputs.prefix }}

- name: Setup Environment (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
# Use a cache directory that persists across runs (see above).
mkdir -p ~/apt-cache/partial
APT_CACHE_ARGS="-o Dir::Cache::Archives=$HOME/apt-cache -o APT::Keep-Downloaded-Packages=true"

# Just for Github action builds set USE_BAZEL_VERSION to override the
# .bazelversion file so we can test different Bazel versions even though
# the recommended Bazel version will be in the .bazelversion file.
Expand All @@ -129,21 +155,28 @@ jobs:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
fi

sudo apt install gcc-${{ matrix.version }} g++-${{ matrix.version }}
sudo apt install --no-install-recommends ${APT_CACHE_ARGS} gcc-${{ matrix.version }} g++-${{ matrix.version }}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.version }} 100 \
--slave /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.version }} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ matrix.version }}
sudo update-alternatives --set gcc /usr/bin/gcc-${{ matrix.version }}

echo "CC=/usr/bin/g++-${{ matrix.version }}" >> $GITHUB_ENV
else
sudo apt install clang-${{ matrix.version }}
sudo apt install --no-install-recommends ${APT_CACHE_ARGS} clang-${{ matrix.version }}
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ matrix.version }} 100
sudo update-alternatives --set clang /usr/bin/clang-${{ matrix.version }}

echo "CC=/usr/bin/clang++-${{ matrix.version }}" >> $GITHUB_ENV
fi

# Remove outdated packages restored from a previous month's cache.
sudo apt-get autoclean ${APT_CACHE_ARGS}

# apt leaves root-owned files (e.g., its lock file) in the cache
# directory, which actions/cache can't read when saving.
sudo chown -R "$USER" ~/apt-cache

- name: Set C++ Standard
run: |
if [[ -n "${{ matrix.cppstd }}" ]]; then
Expand Down Expand Up @@ -225,9 +258,35 @@ jobs:
run: |
echo "EXT=.exe" >> $GITHUB_ENV

# The Ubuntu mirror is slow when many matrix jobs download at once, so we
# cache the downloaded .deb packages.
#
# actions/cache never overwrites an existing key, so we include the month in
# the key to pick up package updates. The OS image name (e.g., ubuntu24)
# keeps ubuntu-latest from restoring packages from an older release.
- name: Get apt Cache Key (Linux)
id: apt-cache-key
if: startsWith(matrix.os, 'ubuntu')
run: |
PREFIX="apt-${ImageOS}-${{ matrix.compiler }}-${{ matrix.version }}-"
echo "prefix=${PREFIX}" >> $GITHUB_OUTPUT
echo "key=${PREFIX}$(date +%Y-%m)" >> $GITHUB_OUTPUT

- name: Cache apt Packages (Linux)
if: startsWith(matrix.os, 'ubuntu')
uses: actions/cache@v4
with:
path: ~/apt-cache
key: ${{ steps.apt-cache-key.outputs.key }}
restore-keys: ${{ steps.apt-cache-key.outputs.prefix }}

- name: Setup Environment (Linux)
if: startsWith(matrix.os, 'ubuntu')
run: |
# Use a cache directory that persists across runs (see above).
mkdir -p ~/apt-cache/partial
APT_CACHE_ARGS="-o Dir::Cache::Archives=$HOME/apt-cache -o APT::Keep-Downloaded-Packages=true"

if [[ "${{ matrix.compiler }}" == "gcc" ]]; then
# Some time between 2/9/2026 and 2/16/2026, the apt packages for
# backported versions of GCC earlier than the version included in
Expand All @@ -245,7 +304,7 @@ jobs:
sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
fi

sudo apt install gcc-${{ matrix.version }} g++-${{ matrix.version }}
sudo apt install --no-install-recommends ${APT_CACHE_ARGS} gcc-${{ matrix.version }} g++-${{ matrix.version }}
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ matrix.version }} 100 \
--slave /usr/bin/g++ g++ /usr/bin/g++-${{ matrix.version }} \
--slave /usr/bin/gcov gcov /usr/bin/gcov-${{ matrix.version }}
Expand All @@ -254,14 +313,21 @@ jobs:
echo "CC=/usr/bin/gcc-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=/usr/bin/g++-${{ matrix.version }}" >> $GITHUB_ENV
else
sudo apt install clang-${{ matrix.version }}
sudo apt install --no-install-recommends ${APT_CACHE_ARGS} clang-${{ matrix.version }}
sudo update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${{ matrix.version }} 100
sudo update-alternatives --set clang /usr/bin/clang-${{ matrix.version }}

echo "CC=/usr/bin/clang-${{ matrix.version }}" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++-${{ matrix.version }}" >> $GITHUB_ENV
fi

# Remove outdated packages restored from a previous month's cache.
sudo apt-get autoclean ${APT_CACHE_ARGS}

# apt leaves root-owned files (e.g., its lock file) in the cache
# directory, which actions/cache can't read when saving.
sudo chown -R "$USER" ~/apt-cache

echo "EXT=" >> $GITHUB_ENV

- name: Setup Build
Expand Down
Loading