Skip to content

Build Engine (Docker) #485

Build Engine (Docker)

Build Engine (Docker) #485

Workflow file for this run

name: Build Engine (Docker)
on:
workflow_dispatch:
inputs:
strip-symbols:
description: Strip Debug Symbols
required: true
default: 'true'
use-caches:
description: Use Caches (Docker/ccache)
required: true
default: 'true'
archtune-flags:
description: Arch/Tune Flags
required: false
default: ''
buildtype:
type: choice
description: Build Type
required: false
options:
- RELWITHDEBINFO
- DEBUG
- RELEASE
- PROFILE
default: 'RELWITHDEBINFO'
buildtype-flags:
description: Build Type Compilation Flags Override
required: false
default: ''
compilation-flags:
description: Extra Compilation Flags
required: false
default: ''
clean-ccache:
description: Reset ccache before build
required: false
default: 'false'
debug-tmate:
description: Debug with tmate (either "pre" or "post" Docker run)
required: false
default: 'false'
debug-ccache:
description: Generate ccache Debug Artifacts
required: false
default: 'false'
docker-image:
description: 'Docker Image to use (Docker Hub name or "*" to used embedded image)'
required: false
default: '*'
#default: 'verybadsoldier/springrts-build:dbg'
jobs:
build_engine:
name: ${{ matrix.config.os }}
runs-on: ${{ matrix.config.runs-on }}
strategy:
fail-fast: true
matrix:
config:
- {
os: 'windows-64',
runs-on: 'ubuntu-latest'
}
- {
os: 'linux-64',
runs-on: 'ubuntu-latest'
}
steps:
- name: Extract Branch Name
#https://stackoverflow.com/questions/58033366/how-to-get-current-branch-within-github-actions/58034787
id: extract-branch
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
shell: bash
- name: Print Build Info
run: |
echo "Build info:"
echo "Git commit hash: ${{ github.sha }}"
echo "Repository: ${{ github.repository }}"
shell: bash
- name: Checkout Source Repository
uses: actions/checkout@v2
- name: Get Random Number
id: get-random-number
run: |
number=$(head /dev/random -c 32 | sha1sum | awk '{ print $1 }')
echo "Generated random number: $number"
echo "::set-output name=number::$number"
shell: bash
- name: Download ccache Data
if: github.event.inputs.use-caches == 'true'
id: cache-dl
uses: actions/cache@v2
with:
path: /tmp/ccache_archive
key: ccache-${{ matrix.config.os }}-${{ steps.get-random-number.outputs.number }}
restore-keys: |
ccache-${{ matrix.config.os }}-
- name: Check and unpack ccache Data
id: cache
run: |
CACHE_FILENAME="/tmp/ccache_archive/${{ matrix.config.os }}.tgz"
echo "::set-output name=cache-filename::${CACHE_FILENAME}"
if [ -f "${CACHE_FILENAME}" ]; then
echo "Found build ccache: ${CACHE_FILENAME}"
if [ "${{ github.event.inputs.clean-ccache }}" == "true" ]; then
echo "Deleting ccache: ${CACHE_FILENAME}"
rm -rf "${CACHE_FILENAME}"
else
echo "::set-output name=cache-hit::true"
echo "Extracting..."
mkdir -p /tmp/ccache
tar -I pigz -xf "${CACHE_FILENAME}" -C /tmp/ccache
fi
else
echo "Not found ccache data"
echo "::set-output name=cache-hit::false"
fi
shell: bash
- name: Build engine via docker
uses: ./docker-build
id: run-docker-build
with:
archtune-flags: "${{ github.event.inputs.archtune-flags }}"
buildtype: "${{ github.event.inputs.buildtype }}"
buildtype-flags: "${{ github.event.inputs.buildtype-flags }}"
compilation-flags: "${{ github.event.inputs.compilation-flags }}"
use-cache: "${{ github.event.inputs.use-caches }}"
platform: "${{ matrix.config.os }}"
branch: "${{ env.BRANCH_NAME }}"
repository-url: "https://github.com/${{ github.repository }}"
debug-tmate: "${{ github.event.inputs.debug-tmate }}"
debug-ccache: "${{ github.event.inputs.debug-ccache }}"
docker-image: "${{ github.event.inputs.docker-image }}"
- name: Upload Bin as Artifact
uses: actions/upload-artifact@v2
with:
name: ${{ steps.run-docker-build.outputs.bin_name }}
path: ${{ github.workspace }}/artifacts/${{ steps.run-docker-build.outputs.bin_name }}
- name: Upload Dbg Artifacts
if: github.event.inputs.strip-symbols == 'true'
uses: actions/upload-artifact@v2
with:
name: ${{ steps.run-docker-build.outputs.dbg_name }}
path: ${{ github.workspace }}/artifacts/${{ steps.run-docker-build.outputs.dbg_name }}
- name: Upload Build Options Artifact
uses: actions/upload-artifact@v2
with:
name: buildoptions_${{ matrix.config.os }}.txt
path: ${{ github.workspace }}/artifacts/buildoptions_${{ matrix.config.os }}.txt
- name: Pack ccache Data
if: github.event.inputs.use-caches == 'true'
run: |
CACHE_FILENAME="${{ steps.cache.outputs.cache-filename }}"
echo "Creating cache file: ${CACHE_FILENAME}"
mkdir -p /tmp/ccache_archive
rm -rf /tmp/ccache_archive/*
tar cvf - -C /tmp/ccache . 2> /dev/null | pigz -1 > "${CACHE_FILENAME}"
echo "Raw ccache size: $(du -sch /tmp/ccache | tail -n1 | cut -f1)"
echo "Archived ccache size: $(du -h "${CACHE_FILENAME}" | cut -f1)"
- name: Upload ccache Debug Data
uses: actions/upload-artifact@v2
if: github.event.inputs.debug-ccache == 'true'
with:
name: ccache_debug_${{ matrix.config.os }}.tgz
path: ${{ github.workspace }}/artifacts/${{ steps.run-docker-build.outputs.ccache_dbg }}