Skip to content

Commit

Permalink
ci: make package updates a separate workflow step
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Noonan <steven@valvesoftware.com>
  • Loading branch information
Steven Noonan committed Feb 6, 2021
1 parent b7f2279 commit b9f3cea
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 38 deletions.
28 changes: 28 additions & 0 deletions .github/action.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

set -e
set -o pipefail

ACTION="$(basename "$0")"
ACTION="${ACTION%.sh}"

SCRIPT_CANDIDATES=(
"$PWD/.github/${ACTION}/${IMAGE//\//-}.sh"
"$PWD/.github/${ACTION}/${IMAGE%/*}.sh"
)

for SCRIPT in "${SCRIPT_CANDIDATES[@]}"; do
if [[ -f "${SCRIPT}" ]]; then
bash "${SCRIPT}" | cat
exit $?
fi
done

echo "Could not find script in any of these paths:"
for SCRIPT in "${SCRIPT_CANDIDATES[@]}"; do
echo " ${SCRIPT}"
done
echo ""
echo "Don't know how to do step '${ACTION}' for ${IMAGE}!"
echo ""
exit 1
1 change: 0 additions & 1 deletion .github/install-debian.sh

This file was deleted.

25 changes: 0 additions & 25 deletions .github/install.sh

This file was deleted.

1 change: 1 addition & 0 deletions .github/install.sh
2 changes: 0 additions & 2 deletions .github/install-alpine.sh → .github/install/alpine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
#
set -ex

apk update

# Base build packages
PACKAGES=(
clang
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ PACKAGES+=(protobuf)
PACKAGES+=(openssl)
PACKAGES+=(libsodium)

pacman --noconfirm -Syu
pacman --noconfirm -Sy "${PACKAGES[@]}"

exit 0
1 change: 1 addition & 0 deletions .github/install/debian.sh
6 changes: 0 additions & 6 deletions .github/install-fedora.sh → .github/install/fedora.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ PACKAGES+=(protobuf-compiler protobuf-devel)
PACKAGES+=(openssl-devel)
PACKAGES+=(libsodium-devel)

if ! grep '^fastestmirror' /etc/dnf/dnf.conf; then
echo 'fastestmirror=1' >> /etc/dnf/dnf.conf
fi

dnf clean all
dnf update -y
dnf install -y "${PACKAGES[@]}"

exit 0
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ PACKAGES+=(protobuf-devel)
PACKAGES+=(libopenssl-devel)
PACKAGES+=(libsodium-devel)

zypper update -y
zypper install -y "${PACKAGES[@]}"

exit 0
2 changes: 0 additions & 2 deletions .github/install-ubuntu.sh → .github/install/ubuntu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ APT_FLAGS=(-q -oDpkg::Use-Pty=0)

export DEBIAN_FRONTEND=noninteractive

apt-get ${APT_FLAGS[@]} update
apt-get ${APT_FLAGS[@]} dist-upgrade -y
apt-get ${APT_FLAGS[@]} install -y locales
locale-gen en_US.UTF-8

Expand Down
1 change: 1 addition & 0 deletions .github/update-packages.sh
9 changes: 9 additions & 0 deletions .github/update-packages/alpine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
#
# This is an install script for Alpine-specific package updates.
#
set -ex

apk update

exit 0
9 changes: 9 additions & 0 deletions .github/update-packages/archlinux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
#
# This is an install script for Arch Linux-specific package updates.
#
set -ex

pacman --noconfirm -Syu

exit 0
1 change: 1 addition & 0 deletions .github/update-packages/debian.sh
14 changes: 14 additions & 0 deletions .github/update-packages/fedora.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
#
# This is an install script for Fedora-specific package updates.
#
set -ex

if ! grep '^fastestmirror' /etc/dnf/dnf.conf; then
echo 'fastestmirror=1' >> /etc/dnf/dnf.conf
fi

dnf clean all
dnf update -y

exit 0
9 changes: 9 additions & 0 deletions .github/update-packages/opensuse.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
#
# This is an install script for OpenSuSE-specific package updates.
#
set -ex

zypper update -y

exit 0
14 changes: 14 additions & 0 deletions .github/update-packages/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash
#
# This is an install script for Debian/Ubuntu-specific package updates.
#
set -ex

APT_FLAGS=(-q -oDpkg::Use-Pty=0)

export DEBIAN_FRONTEND=noninteractive

apt-get ${APT_FLAGS[@]} update
apt-get ${APT_FLAGS[@]} dist-upgrade -y

exit 0
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ jobs:
docker run -d --rm --name github-docker-builder -e LC_ALL="C" -e LANG="C" -v ${{ github.workspace }}:/build -w /build ${{ matrix.docker_image }}:${{ matrix.docker_tag }} tail -f /dev/null
docker ps
docker exec -e CI_BUILD=1 -e IMAGE=${{ matrix.docker_image }} -e IMAGE_TAG=${{ matrix.docker_tag }} -t github-docker-builder sh .github/preinstall.sh
- name: Update packages
run: |
docker exec -e CI_BUILD=1 -e IMAGE=${{ matrix.docker_image }} -e IMAGE_TAG=${{ matrix.docker_tag }} -t github-docker-builder bash .github/update-packages.sh
- name: Install dependencies
run: |
docker exec -e CI_BUILD=1 -e IMAGE=${{ matrix.docker_image }} -e IMAGE_TAG=${{ matrix.docker_tag }} -t github-docker-builder bash .github/install.sh
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ before_install:
- docker run -d --rm --cap-add SYS_PTRACE --name $CONTAINER_NAME -e LC_ALL="C" -e LANG="C" -v $(pwd):/build -w /build $IMAGE_PREFIX$IMAGE:$IMAGE_TAG tail -f /dev/null
- docker ps
- docker exec -e CI_BUILD=1 -e IMAGE=$IMAGE -e IMAGE_TAG=$IMAGE_TAG -t $CONTAINER_NAME sh .github/preinstall.sh
- docker exec -e CI_BUILD=1 -e IMAGE=$IMAGE -e IMAGE_TAG=$IMAGE_TAG -t $CONTAINER_NAME bash .github/update-packages.sh

install:
- docker exec -e CI_BUILD=1 -e IMAGE=$IMAGE -e IMAGE_TAG=$IMAGE_TAG -t $CONTAINER_NAME bash .github/install.sh
Expand Down

0 comments on commit b9f3cea

Please sign in to comment.