mirror of
https://github.com/Astatin3/meteorbot-old.git
synced 2026-06-09 00:28:06 -06:00
Initial commit
This commit is contained in:
@@ -0,0 +1,325 @@
|
||||
name: Botcraft build
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
inputs:
|
||||
os:
|
||||
description: OS we want to build for
|
||||
required: true
|
||||
type: string
|
||||
version:
|
||||
description: Minecraft version
|
||||
required: false
|
||||
default: latest
|
||||
type: string
|
||||
issue:
|
||||
description: URL of the issue requesting this build
|
||||
required: false
|
||||
type: string
|
||||
default: ""
|
||||
|
||||
env:
|
||||
BUILD_TYPE: Release
|
||||
CMAKE_GENERATOR: ${{ inputs.os == 'windows-latest' && 'Visual Studio 17 2022' || 'Unix Makefiles' }}
|
||||
|
||||
jobs:
|
||||
# Make sure dependencies are in cache
|
||||
pre_configure:
|
||||
runs-on: ${{ inputs.os }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install Linux deps
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y xorg-dev
|
||||
|
||||
- name: Create build folder
|
||||
run: cmake -E make_directory ${{ runner.workspace }}/build
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
${{ runner.workspace }}/build/3rdparty/catch2/install
|
||||
${{ runner.workspace }}/build/3rdparty/glad/install
|
||||
${{ runner.workspace }}/build/3rdparty/glfw/install
|
||||
${{ runner.workspace }}/build/3rdparty/openssl/install
|
||||
${{ runner.workspace }}/build/3rdparty/zlib/install
|
||||
key: ${{ runner.os }}-deps
|
||||
|
||||
- name: Configure cmake
|
||||
shell: bash
|
||||
working-directory: ${{ runner.workspace }}/build
|
||||
run: >
|
||||
cmake -G "$CMAKE_GENERATOR"
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DBOTCRAFT_GAME_VERSION=${{ inputs.version }}
|
||||
-DBOTCRAFT_USE_OPENGL_GUI=ON
|
||||
-DBOTCRAFT_USE_IMGUI=ON
|
||||
-DBOTCRAFT_COMPRESSION=ON
|
||||
-DBOTCRAFT_ENCRYPTION=ON
|
||||
-DBOTCRAFT_BUILD_EXAMPLES=OFF
|
||||
-DBOTCRAFT_BUILD_TESTS=ON
|
||||
-DBOTCRAFT_BUILD_TESTS_ONLINE=OFF
|
||||
-DBOTCRAFT_WINDOWS_BETTER_SLEEP=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_ZLIB=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_OPENSSL=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_GLFW=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_GLAD=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_CATCH=ON
|
||||
-DBOTCRAFT_INSTALL_MC_ASSETS=OFF
|
||||
-DBOTCRAFT_USE_PRECOMPILED_HEADERS=ON
|
||||
-DBOTCRAFT_BUILD_DOC=OFF
|
||||
-DBOTCRAFT_OUTPUT_DIR=output
|
||||
-DCMAKE_INSTALL_PREFIX=install/botcraft
|
||||
-S $GITHUB_WORKSPACE
|
||||
-B .
|
||||
|
||||
- name: Upload version artifact
|
||||
if: runner.os == 'Linux'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: MC-version
|
||||
path: ${{ runner.workspace }}/build/version.txt
|
||||
retention-days: 1
|
||||
|
||||
build_doc:
|
||||
runs-on: ${{ inputs.os }}
|
||||
if: inputs.os == 'ubuntu-latest'
|
||||
needs:
|
||||
- pre_configure
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install deps
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y xorg-dev
|
||||
wget https://github.com/doxygen/doxygen/releases/download/Release_1_9_8/doxygen-1.9.8.linux.bin.tar.gz
|
||||
tar xzvf doxygen-1.9.8.linux.bin.tar.gz
|
||||
cd doxygen-1.9.8
|
||||
sudo make install
|
||||
|
||||
- name: Create build folder
|
||||
run: cmake -E make_directory ${{ runner.workspace }}/build
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
${{ runner.workspace }}/build/3rdparty/catch2/install
|
||||
${{ runner.workspace }}/build/3rdparty/glad/install
|
||||
${{ runner.workspace }}/build/3rdparty/glfw/install
|
||||
${{ runner.workspace }}/build/3rdparty/openssl/install
|
||||
${{ runner.workspace }}/build/3rdparty/zlib/install
|
||||
key: Linux-deps
|
||||
|
||||
- name: Configure cmake
|
||||
shell: bash
|
||||
working-directory: ${{ runner.workspace }}/build
|
||||
run: >
|
||||
cmake -G "Unix Makefiles"
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DBOTCRAFT_GAME_VERSION=latest
|
||||
-DBOTCRAFT_USE_OPENGL_GUI=ON
|
||||
-DBOTCRAFT_USE_IMGUI=ON
|
||||
-DBOTCRAFT_COMPRESSION=ON
|
||||
-DBOTCRAFT_ENCRYPTION=ON
|
||||
-DBOTCRAFT_BUILD_EXAMPLES=OFF
|
||||
-DBOTCRAFT_BUILD_TESTS=OFF
|
||||
-DBOTCRAFT_BUILD_TESTS_ONLINE=OFF
|
||||
-DBOTCRAFT_WINDOWS_BETTER_SLEEP=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_ZLIB=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_OPENSSL=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_GLFW=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_GLAD=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_CATCH=ON
|
||||
-DBOTCRAFT_INSTALL_MC_ASSETS=OFF
|
||||
-DBOTCRAFT_USE_PRECOMPILED_HEADERS=ON
|
||||
-DBOTCRAFT_BUILD_DOC=ON
|
||||
-DBOTCRAFT_OUTPUT_DIR=output
|
||||
-DCMAKE_INSTALL_PREFIX=install/botcraft
|
||||
-S $GITHUB_WORKSPACE
|
||||
-B .
|
||||
|
||||
- name: Generate doc
|
||||
working-directory: ${{ runner.workspace }}/build
|
||||
run: cmake --build . --target doc_doxygen
|
||||
|
||||
- name: Create doc archive
|
||||
working-directory: ${{ runner.workspace }}/build/output/doc
|
||||
run: cmake -E tar "cf" "doc.zip" --format=zip $(cat ${{ runner.workspace }}/build/version.txt)/
|
||||
|
||||
- name: Upload doc as zip
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: botcraft-doc
|
||||
path: ${{ runner.workspace }}/build/output/doc/doc.zip
|
||||
retention-days: 1
|
||||
|
||||
build:
|
||||
runs-on: ${{ inputs.os }}
|
||||
needs:
|
||||
- pre_configure
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install Linux deps
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y xorg-dev
|
||||
|
||||
- name: Create build folder
|
||||
run: cmake -E make_directory ${{ runner.workspace }}/build
|
||||
|
||||
- name: Cache dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: |
|
||||
${{ runner.workspace }}/build/3rdparty/catch2/install
|
||||
${{ runner.workspace }}/build/3rdparty/glad/install
|
||||
${{ runner.workspace }}/build/3rdparty/glfw/install
|
||||
${{ runner.workspace }}/build/3rdparty/openssl/install
|
||||
${{ runner.workspace }}/build/3rdparty/zlib/install
|
||||
key: ${{ runner.os }}-deps
|
||||
|
||||
- name: Configure cmake
|
||||
shell: bash
|
||||
working-directory: ${{ runner.workspace }}/build
|
||||
run: >
|
||||
cmake -G "$CMAKE_GENERATOR"
|
||||
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
|
||||
-DBOTCRAFT_GAME_VERSION=${{ inputs.version }}
|
||||
-DBOTCRAFT_USE_OPENGL_GUI=ON
|
||||
-DBOTCRAFT_USE_IMGUI=ON
|
||||
-DBOTCRAFT_COMPRESSION=ON
|
||||
-DBOTCRAFT_ENCRYPTION=ON
|
||||
-DBOTCRAFT_BUILD_EXAMPLES=ON
|
||||
-DBOTCRAFT_BUILD_TESTS=ON
|
||||
-DBOTCRAFT_BUILD_TESTS_ONLINE=ON
|
||||
-DBOTCRAFT_WINDOWS_BETTER_SLEEP=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_ZLIB=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_OPENSSL=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_GLFW=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_GLAD=ON
|
||||
-DBOTCRAFT_FORCE_LOCAL_CATCH=ON
|
||||
-DBOTCRAFT_INSTALL_MC_ASSETS=OFF
|
||||
-DBOTCRAFT_USE_PRECOMPILED_HEADERS=ON
|
||||
-DBOTCRAFT_BUILD_DOC=OFF
|
||||
-DBOTCRAFT_OUTPUT_DIR=output
|
||||
-DCMAKE_INSTALL_PREFIX=install/botcraft
|
||||
-S $GITHUB_WORKSPACE
|
||||
-B .
|
||||
|
||||
- name: Build all
|
||||
shell: bash
|
||||
id: build
|
||||
working-directory: ${{ runner.workspace }}/build
|
||||
run: cmake --build . --config $BUILD_TYPE --parallel 2
|
||||
|
||||
- name: Notify issue if build failed
|
||||
if: failure() && steps.build.conclusion == 'failure' && inputs.issue
|
||||
shell: bash
|
||||
run: |
|
||||
echo "${{ runner.os }} build failed. Logs can be found [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})." > body.txt
|
||||
echo -en '\n' >> body.txt
|
||||
echo -en '\n' >> body.txt
|
||||
echo @${{ github.repository_owner }} you might want to take a look. >> body.txt
|
||||
gh issue comment ${{ inputs.issue }} --repo ${{ github.repository }} --body-file body.txt
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Create install
|
||||
shell: bash
|
||||
working-directory: ${{ runner.workspace }}/build
|
||||
run: cmake --build . --config $BUILD_TYPE --parallel 2 --target install
|
||||
|
||||
- name: Create artifact archive
|
||||
working-directory: ${{ runner.workspace }}/build/install
|
||||
run: cmake -E tar "cf" "botcraft.zip" --format=zip botcraft/
|
||||
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: botcraft-${{ runner.os }}
|
||||
path: ${{ runner.workspace }}/build/install/botcraft.zip
|
||||
retention-days: 1
|
||||
|
||||
- name: Cache build directory
|
||||
uses: actions/cache/save@v3
|
||||
with:
|
||||
path: ${{ runner.workspace }}/build
|
||||
key: build_cache_${{ runner.os }}_${{ inputs.version }}_${{ github.run_id }}
|
||||
|
||||
test:
|
||||
runs-on: ${{ inputs.os }}
|
||||
needs:
|
||||
- build
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
java-package: jre
|
||||
|
||||
- name: Install Linux deps
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y xorg-dev
|
||||
|
||||
- name: Create build folder
|
||||
run: cmake -E make_directory ${{ runner.workspace }}/build
|
||||
|
||||
- name: Restore build folder
|
||||
uses: actions/cache/restore@v3
|
||||
with:
|
||||
path: ${{ runner.workspace }}/build
|
||||
key: build_cache_${{ runner.os }}_${{ inputs.version }}_${{ github.run_id }}
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
id: test
|
||||
working-directory: ${{ runner.workspace }}/build
|
||||
run: ctest -C $BUILD_TYPE -VV
|
||||
|
||||
- name: Notify issue if tests failed
|
||||
if: failure() && steps.test.conclusion == 'failure' && inputs.issue
|
||||
shell: bash
|
||||
run: |
|
||||
echo "${{ runner.os }} tests failed. See [this run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) for logs." > body.txt
|
||||
echo -en '\n' >> body.txt
|
||||
echo -en '\n' >> body.txt
|
||||
echo @${{ github.repository_owner }} you might want to take a look. >> body.txt
|
||||
gh issue comment ${{ github.event.inputs.issue }} --repo ${{ github.repository }} --body-file body.txt
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
|
||||
- name: Prepare test server world download
|
||||
if: success() || steps.test.conclusion == 'failure'
|
||||
shell: bash
|
||||
working-directory: ${{ runner.workspace }}/build
|
||||
run: cmake -E rm -rf -- output/bin/test_servers/$(cat version.txt)/libraries output/bin/test_servers/$(cat version.txt)/versions
|
||||
|
||||
- name: Upload test server
|
||||
if: success() || steps.test.conclusion == 'failure'
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: test_server_${{runner.os }}
|
||||
path: ${{ runner.workspace }}/build/output/bin/test_servers
|
||||
Reference in New Issue
Block a user