Skip to content

Linux builds

Linux builds #54

Workflow file for this run

name: Build Linux
run-name: Linux builds
on:
push:
paths:
- "dockerfiles/**/linux/Dockerfile"
jobs:
changed_dockerfiles:
name: Get target dockerfiles
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.changed_dockerfiles.outputs.all_changed_files }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get changed files
id: changed_dockerfiles
uses: tj-actions/changed-files@v41
with:
json: true
escape_json: false
files: |
**/linux/Dockerfile
- name: Show changed dockerfiles
run: echo '${{ steps.changed_dockerfiles.outputs.all_changed_files }}'
get_nuke_sources:
name: Collect and upload Nuke sources
runs-on: ubuntu-latest
needs: [changed_dockerfiles]
outputs:
unique_name: ${{ steps.unique_name.outputs.unique_name}}
cache_key: ${{ steps.unique_name.outputs.cache_key}}
strategy:
matrix:
files: ${{ fromJSON(needs.changed_dockerfiles.outputs.matrix) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get cache name output and unique name
id: unique_name
run: |
unique_name=$(echo "${{ matrix.files }}" | sed 's/\//_/g')
echo "unique_name=${unique_name}" >> $GITHUB_OUTPUT
cache_key=${unique_name}_${{ hashFiles('**/scripts/nuke_source_from_dockerfile.bash') }}
echo "cache_key=${cache_key}" >> $GITHUB_OUTPUT
echo "Got key '$cache_key'"
- name: Get Nuke source files cache
id: cache_nuke_source
uses: actions/cache@v3
with:
path: /tmp/nuke_source_files
key: ${{ steps.unique_name.outputs.cache_key }}
- name: Collect Nuke source files
if: steps.cache_nuke_source.outputs.cache-hit != 'true'
timeout-minutes: 30
run: |
mkdir /tmp/nuke_source_files
bash "${GITHUB_WORKSPACE}/scripts/nuke_source_from_dockerfile.bash" "${{ matrix.files }}" /tmp/nuke_source_files
- name: Create artifact tar
run: tar -czvf /tmp/nuke_source_files.tar.gz -C /tmp nuke_source_files
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: nuke_source_files_${{ steps.unique_name.outputs.unique_name}}
path: /tmp/nuke_source_files.tar.gz
build:
name: Build base
runs-on: ubuntu-latest
needs: [changed_dockerfiles, get_nuke_sources]
strategy:
matrix:
files: ${{ fromJSON(needs.changed_dockerfiles.outputs.matrix) }}
fail-fast: false
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/download-artifact@v4
with:
name: nuke_source_files_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/
- name: Prepare source files
run: |
DOCKERFILE_DIRECTORY=$(dirname ${{ github.workspace }}/${{ matrix.files }})
echo "Directory set to $DOCKERFILE_DIRECTORY"
echo "dockerfile_directory=${DOCKERFILE_DIRECTORY}" >> "$GITHUB_ENV"
tar -xzf /tmp/nuke_source_files.tar.gz -C $DOCKERFILE_DIRECTORY
- name: Build and export
uses: docker/build-push-action@v5
with:
context: ${{ env.dockerfile_directory }}
file: ${{ matrix.files }}
tags: nukedockerbuild:latest
outputs: type=docker,dest=/tmp/nukedockerbuild.tar.gz
build-args: NUKE_SOURCE_FILES=nuke_source_files
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docker_image_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/nukedockerbuild.tar.gz
test_build:
name: Test base
needs: [build, get_nuke_sources]
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/download-artifact@v4
with:
name: docker_image_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/
- name: Load image
run: |
docker load --input /tmp/nukedockerbuild.tar.gz
- name: Tests
run: |
mkdir /tmp/tests/
docker run -v /tmp/tests:/nuke_build_directory nukedockerbuild:latest bash -c \
"cd /usr/local/nuke_install/tests && cmake3 . -B /nuke_build_directory && cmake3 --build /nuke_build_directory"
- name: Prepare test results for upload
run: tar -czvf /tmp/test_run.tar.gz /tmp/tests
- name: Upload tests artifacts
uses: actions/upload-artifact@v4
with:
name: tests_run_base_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/test_run.tar.gz
build_slim:
name: Build slim
needs: [test_build, get_nuke_sources]
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/download-artifact@v4
with:
name: docker_image_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/
- name: Load image
run: docker load --input /tmp/nukedockerbuild.tar.gz
- name: Setup SlimToolkit
run: |
curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | sudo -E bash -
- name: Create Slim image
run: |
slim build \
--target nukedockerbuild:latest \
--http-probe=false \
--exec "bash -c 'cd /usr/local/nuke_install/tests/ && echo $CMAKE_PREFIX_PATH $NUKE_VERSION && cmake3 . -B /nuke_build_directory && cmake3 --build /nuke_build_directory'" \
--preserve-path /opt/rh \
--preserve-path /usr/share/cmake \
--preserve-path /usr/share/cmake3 \
--preserve-path /usr/lib64 \
--preserve-path /usr/include/ \
--preserve-path /usr/local/nuke_install/
docker save nukedockerbuild.slim:latest > /tmp/nukedockerbuild_slim.tar.gz
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docker_image_slim_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/nukedockerbuild_slim.tar.gz
test_slim:
name: Test slim
needs: [build_slim, get_nuke_sources]
runs-on: ubuntu-latest
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/download-artifact@v4
with:
name: docker_image_slim_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/
- name: Load image
run: |
docker load --input /tmp/nukedockerbuild_slim.tar.gz
- name: Run tests
run: |
mkdir /tmp/tests
docker run -v /tmp/tests:/nuke_build_directory nukedockerbuild.slim:latest bash -c \
"cd /usr/local/nuke_install/tests && cmake3 . -B /nuke_build_directory && cmake3 --build /nuke_build_directory"
- name: Prepare test results for upload
run: tar -czvf /tmp/test_run.tar.gz /tmp/tests
- name: Upload tests artifacts
uses: actions/upload-artifact@v4
with:
name: tests_run_slim_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/test_run.tar.gz
deploy:
name: Deploy
needs: [test_build, test_slim, get_nuke_sources]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions: write-all
env:
PUSH_LOCATION: "ghcr.io/gillesvink/nukedockerbuild"
steps:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- uses: actions/download-artifact@v4
with:
name: docker_image_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/
- uses: actions/download-artifact@v4
with:
name: docker_image_slim_${{ needs.get_nuke_sources.outputs.unique_name }}
path: /tmp/
- name: Load image
run: |
docker load --input /tmp/nukedockerbuild.tar.gz
docker load --input /tmp/nukedockerbuild_slim.tar.gz
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set tag and push
run: |
NUKE_VERSION=$(docker inspect -f '{{index .Config.Labels "com.nukedockerbuild.nuke_version"}}' nukedockerbuild:latest)
OPERATING_SYSTEM=$(docker inspect -f '{{index .Config.Labels "com.nukedockerbuild.operating_system"}}' nukedockerbuild:latest)
VERSION=$(docker inspect -f '{{index .Config.Labels "org.opencontainers.version"}}' nukedockerbuild:latest)
TAG=${NUKE_VERSION}-${OPERATING_SYSTEM}
docker tag nukedockerbuild:latest ${PUSH_LOCATION}:${TAG}-${VERSION}
docker tag nukedockerbuild:latest ${PUSH_LOCATION}:${TAG}-latest
docker tag nukedockerbuild.slim:latest ${PUSH_LOCATION}:${TAG}-slim-${VERSION}
docker tag nukedockerbuild.slim:latest ${PUSH_LOCATION}:${TAG}-slim-latest
docker image push ${PUSH_LOCATION}:${TAG}-${VERSION}
docker image push ${PUSH_LOCATION}:${TAG}-latest
docker image push ${PUSH_LOCATION}:${TAG}-slim-${VERSION}
docker image push ${PUSH_LOCATION}:${TAG}-slim-latest