1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
name: Build Linux Packages
on:
# Run when called from other workflows only
workflow_call:
inputs:
package_complete_version:
description: 'The output of the complete_version of the "determine_version" job from the build_and_release.yml workflow'
required: true
type: string
release_id:
description: 'The output of the "create_release" job from the build_and_release.yml workflow'
required: true
type: string
env:
REGISTRY: ghcr.io
REPO_NAME: ${{ github.repository_owner }}
jobs:
# Decide if we need to build the containers on this run
determine_docker_version:
name: Determine whether to build the containers or not
runs-on: ubuntu-latest
outputs:
build_docker_containers: ${{ steps.version.outputs.build_docker_containers }}
build_debian_containers: ${{ steps.version.outputs.build_debian_containers }}
build_ubuntu_containers: ${{ steps.version.outputs.build_ubuntu_containers }}
build_fedora_containers: ${{ steps.version.outputs.build_fedora_containers }}
steps:
- name: Checkout
id: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Determine version
id: version
run: |
# Only run the container builds when something in the docker folder or
# this workflow has changed from master, or if it was cron triggered
if [[ '${{ github.event_name }}' == 'push' ]]; then
base_version='${{ github.event.before }}'
else
base_version='origin/master'
fi
DIFF_YML=$((git rev-parse HEAD:.github/workflows/linux.yml && git diff --merge-base ${base_version} --exit-code -- .github/workflows/linux.yml) > /dev/null 2>&1 ; echo $?)
if [[ $DIFF_YML != 0 || '${{ github.event_name }}' == 'schedule' ]]; then
echo "Refresh all containers: TRUE"
echo "build_docker_containers=true" >> $GITHUB_OUTPUT
else
echo "Refresh all containers: FALSE"
echo "build_docker_containers=false" >> $GITHUB_OUTPUT
fi
DIFF_UBUNTU=$((git rev-parse HEAD:docker/Dockerfile.ubuntu HEAD:docker/build_performous.sh && git diff --merge-base ${base_version} --exit-code -- docker/Dockerfile.ubuntu docker/build_performous.sh) > /dev/null 2>&1 ; echo $?)
DIFF_DEBIAN=$((git rev-parse HEAD:docker/Dockerfile.debian HEAD:docker/build_performous.sh && git diff --merge-base ${base_version} --exit-code -- docker/Dockerfile.debian docker/build_performous.sh) > /dev/null 2>&1 ; echo $?)
DIFF_FEDORA=$((git rev-parse HEAD:docker/Dockerfile.fedora HEAD:docker/build_performous.sh && git diff --merge-base ${base_version} --exit-code -- docker/Dockerfile.fedora docker/build_performous.sh) > /dev/null 2>&1 ; echo $?)
if [[ $DIFF_UBUNTU != 0 ]]; then
echo "Refresh Ubuntu containers: TRUE"
echo "build_ubuntu_containers=true" >> $GITHUB_OUTPUT
else
echo "Refresh Ubuntu containers: FALSE"
echo "build_ubuntu_containers=false" >> $GITHUB_OUTPUT
fi
if [[ $DIFF_FEDORA != 0 ]]; then
echo "Refresh FEDORA containers: TRUE"
echo "build_fedora_containers=true" >> $GITHUB_OUTPUT
else
echo "Refresh FEDORA containers: FALSE"
echo "build_fedora_containers=false" >> $GITHUB_OUTPUT
fi
if [[ $DIFF_DEBIAN != 0 ]]; then
echo "Refresh DEBIAN containers: TRUE"
echo "build_debian_containers=true" >> $GITHUB_OUTPUT
else
echo "Refresh DEBIAN containers: FALSE"
echo "build_debian_containers=false" >> $GITHUB_OUTPUT
fi
build_packages:
name: Build the Linux packages
runs-on: ubuntu-latest
needs:
- determine_docker_version
strategy:
matrix:
include:
- os: ubuntu
version: 20.04
- os: ubuntu
version: 22.04
- os: debian
version: 10
- os: debian
version: 11
- os: debian
version: 12
- os: fedora
version: 35
- os: fedora
version: 36
- os: fedora
version: 37
- os: fedora
version: 38
- os: fedora
version: 39
steps:
- name: Container name
run: |
# Figure out the container name we'll use for the build
BUILD_CONTAINER=${{ env.REGISTRY }}/${{ env.REPO_NAME }}/deps:${{ matrix.os }}-${{ matrix.version }}
echo "CONTAINER_NAME=${BUILD_CONTAINER}" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v3
- name: Login to the container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.REPO_NAME }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build ${{ matrix.os }} ${{ matrix.version }} Container
if: needs.determine_docker_version.outputs[format('build_{0}_containers', matrix.os)] == 'true' || needs.determine_docker_version.outputs['build_docker_containers'] == 'true'
uses: docker/build-push-action@v3
with:
context: docker/
file: ./docker/Dockerfile.${{ matrix.os }}
load: true
tags: ${{ env.CONTAINER_NAME }}
build-args: OS_VERSION=${{ matrix.version }}
- name: Build package
run: |
# Pull in our common build functions
. .github/workflows/build_functions.sh
# Set the correct version in cmake
PACKAGE_VERSION=${{ inputs.package_complete_version }}
EXTRA_CMAKE_ARGS="-DPERFORMOUS_VERSION=${PACKAGE_VERSION}"
PERFORMOUS_RELEASE_TYPE="RelWithDebInfo"
# Only pull the container if it wasn't built locally
if [ '${{ needs.determine_docker_version.outputs.build_docker_containers }}' = 'false' ]; then
docker pull ${{ env.CONTAINER_NAME }}
fi
# Run the build inside the docker containers using the
# build script that was pulled inside during the build
docker run --env EXTRA_CMAKE_ARGS --rm -v $(pwd):/github_actions_build/ ${{ env.CONTAINER_NAME }} ./build_performous.sh -g -D /github_actions_build/ -E ${EXTRA_CMAKE_ARGS} -R ${PERFORMOUS_RELEASE_TYPE}
# Provided by the common build functions
package_name "$(pwd)/build" "Performous*-Linux.*" "${PACKAGE_VERSION}" "${{ matrix.os }}" "${{ matrix.version }}"
- name: Run unit tests
run: |
# Run the containers with the script for each testing suite
docker run --rm -v $(pwd):/github_actions_build/ ${{ env.CONTAINER_NAME }} ./run_tests.sh
# Upload artifacts during pull-requests
- name: Upload artifact
uses: actions/upload-artifact@v3
if: ${{ github.event_name == 'pull_request' }}
with:
name: ${{ env.ARTIFACT_NAME }}
path: ${{ env.ARTIFACT_PATH }}
# Upload artifacts on master
- name: Upload artifact with unified name
if: ${{ github.ref == 'refs/heads/master' }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.MASTER_ARTIFACT_NAME }}
path: ${{ env.MASTER_ARTIFACT_PATH }}
# Upload artifacts to releases only during Release events
- name: Upload artifacts to tagged release
id: upload_assets
if: ${{ github.event_name != 'pull_request' && github.ref_type == 'tag' }}
uses: xresloader/upload-to-github-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ inputs.release_id }}
file: ${{ env.ARTIFACT_PATH }}
- name: Push container
uses: docker/build-push-action@v3
# Containers can't be pushed during PRs because of the way permissions
# are delegated to secrets.GITHUB_TOKEN
if: ${{ needs.determine_docker_version.outputs.build_docker_containers == 'true' && github.event_name != 'pull_request' }}
with:
context: docker/
file: ./docker/Dockerfile.${{ matrix.os }}
push: true
tags: ${{ env.CONTAINER_NAME }}
build-args: OS_VERSION=${{ matrix.version }}
|