Initial commit

This commit is contained in:
Astatin3
2024-04-30 22:07:50 -06:00
commit 8565caa62a
8463 changed files with 4915934 additions and 0 deletions
@@ -0,0 +1,160 @@
name: Automatic Release
on:
push:
branches:
- master
paths-ignore:
- 'README.md'
- '.github/ISSUE_TEMPLATE/'
- 'Assets/'
- 'Visuals/'
- '.gitignore'
- 'LICENSE'
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: write
pages: write
id-token: write
jobs:
build_os_matrix:
name: ${{ matrix.config.name }}
strategy:
fail-fast: false
matrix:
config:
- {
name: Windows,
os: windows-latest
}
- {
name: Linux,
os: ubuntu-latest
}
uses: ./.github/workflows/botcraft_build.yml
with:
os: ${{ matrix.config.os }}
release:
runs-on: ubuntu-latest
needs:
- build_os_matrix
steps:
- uses: actions/checkout@v4
with:
# Fetch depth 0 to get all tags and commits to generate release note changelog
fetch-depth: 0
- name: Download Windows artifact
uses: actions/download-artifact@v3
with:
name: botcraft-Windows
path: windows
- name: Download Linux artifact
uses: actions/download-artifact@v3
with:
name: botcraft-Linux
path: linux
- name: Download doc artifact
uses: actions/download-artifact@v3
with:
name: botcraft-doc
path: doc
- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: MC-version
path: version
- name: Retrieve MC game version
id: mc-version
run: echo "version=$(cat version/version.txt)" >> $GITHUB_OUTPUT
- name: Create release note
run: |
echo Automatically built library with the latest version of the code for Minecraft ${{ steps.mc-version.outputs.version }} and all options enabled. Examples are in \`\`bin\`\` folder. If you want to run any example other than 0_HelloWorld and 3_SimpleAFKExample, you first need to run the provided \`\`download_mc_assets\`\` script to automatically populate the \`\`Assets\`\` folder by downloading and extracting the official Minecraft client. > release_note.txt
echo -en '\n' >> release_note.txt
echo "If you are on Windows < 10, the script won't work and you'll have to do it manually as curl and tar commands have only been added recently." >> release_note.txt
echo Linux version is compiled using Ubuntu with all dependencies included and should work on other distributions. You might have to install the unzip command to run the script though. >> release_note.txt
echo -en '\n' >> release_note.txt
echo "💡 If you need binaries for a previous version of Minecraft, you can open [an issue using this link](https://github.com/${{ github.repository }}/issues/new?assignees=&labels=version+request&template=version-request.yml&title=%5BVersion+request%5D) and it will be automagically generated for you." >> release_note.txt
echo -en '\n' >> release_note.txt
echo **Changes:** >> release_note.txt
- name: Append git commits
run: git log latest..HEAD --oneline --no-merges >> release_note.txt
- name: Rename artifacts
run: |
mv linux/botcraft.zip botcraft-linux-${{ steps.mc-version.outputs.version }}.zip
mv windows/botcraft.zip botcraft-windows-${{ steps.mc-version.outputs.version }}.zip
mv doc/doc.zip botcraft-doc-${{ steps.mc-version.outputs.version }}.zip
- name: Remove old latest release
run: gh release delete latest --repo ${{ github.repository }} --cleanup-tag -y
env:
GH_TOKEN: ${{ github.token }}
- name: Create new latest release
run: >
gh release create latest
botcraft-linux-${{ steps.mc-version.outputs.version }}.zip
botcraft-windows-${{ steps.mc-version.outputs.version }}.zip
botcraft-doc-${{ steps.mc-version.outputs.version }}.zip
--repo ${{ github.repository }}
--latest
-F release_note.txt
-t Latest
env:
GH_TOKEN: ${{ github.token }}
deploy_doc:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs:
- build_os_matrix
# Only deploy the doc if a release was successfully created
- release
steps:
- name: Download doc artifact
uses: actions/download-artifact@v3
with:
name: botcraft-doc
path: doc
- name: Download version artifact
uses: actions/download-artifact@v3
with:
name: MC-version
path: version
- name: Unzip doc
working-directory: doc
run: cmake -E tar "xzf" "doc.zip"
- name: Rename version folder
run: mv doc/$(cat version/version.txt) doc/doc
- name: Upload raw doc files for pages
uses: actions/upload-pages-artifact@v1
with:
path: doc/doc
- name: Deploy to GitHub Pages
id: deployment
# Will automatically fetch the artifact "github-pages" uploaded using actions/upload-pages-artifact@v1
uses: actions/deploy-pages@v2
@@ -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
@@ -0,0 +1,130 @@
name: Build version on issue request
on:
issues:
types: [opened, reopened]
jobs:
check_if_build_needed:
runs-on: ubuntu-latest
outputs:
is_valid_request: ${{ steps.check.outputs.is_valid_request }}
version: ${{ steps.retrieve.outputs.version }}
value: ${{ steps.exist.outputs.value }}
steps:
- id: check
name: Check if issue is a request
run: echo "is_valid_request=${{ startsWith(github.event.issue.title, '[Version request]') }}" >> $GITHUB_OUTPUT
- id: retrieve
name: Retrieve the version from body
if: ${{ steps.check.outputs.is_valid_request == 'true' }}
run: echo "version="$(echo "${{ github.event.issue.body }}" | tail -n1) >> $GITHUB_OUTPUT
- id: exist
name: Check if version already exists in release
if: ${{ steps.check.outputs.is_valid_request == 'true' }}
run: echo "value="$(gh release view latest --repo ${{ github.repository }} --json assets -q "[.assets.[].name | select(endswith(\"${{ steps.retrieve.outputs.version }}.zip\"))] | length") >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ github.token }}
os_matrix:
needs: check_if_build_needed
name: ${{ matrix.config.name }}
if: ${{ needs.check_if_build_needed.outputs.is_valid_request == 'true' && needs.check_if_build_needed.outputs.value == 0 }}
secrets: inherit
strategy:
fail-fast: false
matrix:
config:
- {
name: Windows,
os: windows-latest
}
- {
name: Linux,
os: ubuntu-latest
}
uses: ./.github/workflows/botcraft_build.yml
with:
os: ${{ matrix.config.os }}
version: ${{ needs.check_if_build_needed.outputs.version }}
issue: ${{ github.event.issue.html_url }}
notify_build_started:
runs-on: ubuntu-latest
needs: check_if_build_needed
if: ${{ needs.check_if_build_needed.outputs.is_valid_request == 'true' && needs.check_if_build_needed.outputs.value == 0 }}
steps:
- name: Notify issue
run: gh issue comment ${{ github.event.issue.html_url }} --repo ${{ github.repository }} -b "Build process started. You can follow the build progress [here](https://github.com/${{ github.repository }}/actions) or subscribe to this issue to be notified when binaries are ready."
env:
GH_TOKEN: ${{ github.token }}
notify_already_exists:
runs-on: ubuntu-latest
needs: check_if_build_needed
if: ${{ needs.check_if_build_needed.outputs.is_valid_request == 'true' && needs.check_if_build_needed.outputs.value != 0 }}
steps:
- name: Notify issue
run: |
echo "Binaries for ${{ needs.check_if_build_needed.outputs.version }} are already available in the [latest release](https://github.com/${{ github.repository }}/releases/tag/latest)." > body.txt
echo -en '\n' >> body.txt
echo You can close this issue. If you need an updated build for the same Minecraft version in the future, you can reopen this issue to trigger a new build instead of creating a new one. >> body.txt
gh issue comment ${{ github.event.issue.html_url }} --repo ${{ github.repository }} --body-file body.txt
env:
GH_TOKEN: ${{ github.token }}
update_release:
runs-on: ubuntu-latest
needs:
- os_matrix
- notify_build_started
- check_if_build_needed
steps:
- name: Download Linux artifact
uses: actions/download-artifact@v3
with:
name: botcraft-Linux
path: linux
- name: Download Windows artifact
uses: actions/download-artifact@v3
with:
name: botcraft-Windows
path: windows
- name: Download doc artifact
uses: actions/download-artifact@v3
with:
name: botcraft-doc
path: doc
- name: Rename artifacts
run: |
mv linux/botcraft.zip botcraft-linux-${{ needs.check_if_build_needed.outputs.version }}.zip
mv windows/botcraft.zip botcraft-windows-${{ needs.check_if_build_needed.outputs.version }}.zip
mv doc/doc.zip botcraft-doc-${{ needs.check_if_build_needed.outputs.version }}.zip
- name: Upload files to release
run: >
gh release upload latest
botcraft-linux-${{ needs.check_if_build_needed.outputs.version }}.zip
botcraft-windows-${{ needs.check_if_build_needed.outputs.version }}.zip
botcraft-doc-${{ needs.check_if_build_needed.outputs.version }}.zip
--repo ${{ github.repository }}
env:
GH_TOKEN: ${{ github.token }}
- name: Comment on associated issue
run: |
echo "New binaries available in the [latest release](https://github.com/${{ github.repository }}/releases/tag/latest) for version ${{ needs.check_if_build_needed.outputs.version }}" > body.txt
echo -en '\n' >> body.txt
echo You can now close this issue. If you need an updated build for the same Minecraft version in the future, you can reopen this issue to trigger a new build instead of creating a new issue. >> body.txt
gh issue comment ${{ github.event.issue.html_url }} --repo ${{ github.repository }} --body-file body.txt
env:
GH_TOKEN: ${{ github.token }}