mirror of
https://github.com/Adamcake/Bolt.git
synced 2026-04-17 15:56:53 -04:00
352 lines
12 KiB
YAML
352 lines
12 KiB
YAML
name: Build
|
|
on:
|
|
push:
|
|
branches:
|
|
- master # Automatically build on push to master
|
|
pull_request:
|
|
branches:
|
|
- master # Automatically build on pull request to master
|
|
release:
|
|
types:
|
|
- published # Automatically build on release
|
|
|
|
# Grant content write permissions so that the actions can attach artifacts to the releases
|
|
permissions:
|
|
contents: write
|
|
|
|
env:
|
|
WINDOWS_CEF_VERSION: '139.0.7258.139'
|
|
LINUX_CEF_VERSION: '139.0.7258.139'
|
|
LIBARCHIVE_VERSION: '3.7.7'
|
|
LUAJIT_VERSION: '2.1'
|
|
ENABLE_WINDOWS_RELEASES: 'true'
|
|
ENABLE_LINUX_RELEASES: 'true'
|
|
|
|
jobs:
|
|
build-windows-project:
|
|
name: Build Windows
|
|
runs-on: windows-2022
|
|
steps:
|
|
- name: Checkout Project
|
|
uses: actions/checkout@v4.2.0
|
|
with:
|
|
path: Bolt
|
|
submodules: recursive
|
|
|
|
- name: Add msbuild to PATH
|
|
uses: microsoft/setup-msbuild@v2
|
|
with:
|
|
vs-version: 17.0
|
|
|
|
- uses: ilammy/msvc-dev-cmd@v1.13.0
|
|
with:
|
|
arch: x64
|
|
|
|
- name: Setup cmake
|
|
uses: jwlawson/actions-setup-cmake@v2
|
|
with:
|
|
cmake-version: '3.30.x'
|
|
|
|
- name: Create Directories
|
|
run: |
|
|
mkdir cef
|
|
|
|
- name: Restore LuaJIT from Cache
|
|
id: restore-cache-luajit
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: LuaJIT
|
|
key: 'windows-luajit-${{ env.LUAJIT_VERSION }}'
|
|
|
|
- name: Checkout LuaJIT
|
|
if: steps.restore-cache-luajit.outputs.cache-hit != 'true'
|
|
uses: actions/checkout@v4.2.0
|
|
with:
|
|
path: LuaJIT
|
|
repository: LuaJIT/LuaJIT
|
|
ref: v${{ env.LUAJIT_VERSION }}
|
|
|
|
- name: Build LuaJIT
|
|
if: steps.restore-cache-luajit.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd LuaJIT/src
|
|
.\msvcbuild.bat
|
|
|
|
- name: Save LuaJIT to Cache
|
|
if: steps.restore-cache-luajit.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: LuaJIT
|
|
key: 'windows-luajit-${{ env.LUAJIT_VERSION }}'
|
|
|
|
- name: Checkout libarchive
|
|
uses: actions/checkout@v4.2.0
|
|
with:
|
|
path: libarchive
|
|
repository: libarchive/libarchive
|
|
ref: v${{ env.LIBARCHIVE_VERSION }}
|
|
|
|
- name: Checkout zlib
|
|
uses: actions/checkout@v4.2.0
|
|
with:
|
|
path: libarchive\zlib
|
|
repository: libarchive/zlib
|
|
ref: v1.3
|
|
|
|
- name: Checkout bzip2
|
|
uses: actions/checkout@v4.2.0
|
|
with:
|
|
path: libarchive\bzip2
|
|
repository: libarchive/bzip2
|
|
ref: 1ea1ac188ad4b9cb662e3f8314673c63df95a589
|
|
|
|
- name: Checkout xz
|
|
uses: actions/checkout@v4.2.0
|
|
with:
|
|
path: libarchive\xz
|
|
repository: libarchive/xz
|
|
ref: v5.6.3
|
|
|
|
- name: Checkout zstd
|
|
uses: actions/checkout@v4.2.0
|
|
with:
|
|
path: libarchive\zstd
|
|
repository: facebook/zstd
|
|
ref: v1.5.5
|
|
|
|
- name: Build zlib
|
|
uses: threeal/cmake-action@v2.0.0
|
|
with:
|
|
source-dir: libarchive\zlib
|
|
build-dir: libarchive\zlib\builddir
|
|
generator: Visual Studio 17
|
|
options: |
|
|
CMAKE_BUILD_TYPE=Release
|
|
CMAKE_INSTALL_PREFIX=libarchive\zlib\builddir
|
|
build-args: --config Release -j ${{ env.NUMBER_OF_PROCESSORS }}
|
|
|
|
- name: Create zlib release
|
|
run: cmake --install libarchive/zlib/builddir/
|
|
|
|
- name: Build bzip2
|
|
uses: threeal/cmake-action@v2.0.0
|
|
with:
|
|
source-dir: libarchive\bzip2
|
|
build-dir: libarchive\bzip2\builddir
|
|
generator: Visual Studio 17
|
|
options: |
|
|
CMAKE_BUILD_TYPE=Release
|
|
CMAKE_INSTALL_PREFIX=libarchive\bzip2\builddir
|
|
ENABLE_LIB_ONLY=ON
|
|
ENABLE_SHARED_LIB=OFF
|
|
ENABLE_STATIC_LIB=ON
|
|
build-args: --config Release -j ${{ env.NUMBER_OF_PROCESSORS }}
|
|
|
|
- name: Create bzip2 release
|
|
run: cmake --install libarchive/bzip2/builddir/
|
|
|
|
- name: Build xz
|
|
uses: threeal/cmake-action@v2.0.0
|
|
with:
|
|
source-dir: libarchive\xz
|
|
build-dir: libarchive\xz\builddir
|
|
generator: Visual Studio 17
|
|
options: |
|
|
CMAKE_BUILD_TYPE=Release
|
|
CMAKE_INSTALL_PREFIX=libarchive\xz\builddir
|
|
build-args: --config Release -j ${{ env.NUMBER_OF_PROCESSORS }}
|
|
|
|
- name: Create xz release
|
|
run: cmake --install libarchive/xz/builddir/
|
|
|
|
- name: Build zstd
|
|
uses: threeal/cmake-action@v2.0.0
|
|
with:
|
|
source-dir: libarchive\zstd\build\cmake
|
|
build-dir: libarchive\zstd\builddir
|
|
generator: Visual Studio 17
|
|
options: |
|
|
CMAKE_BUILD_TYPE=Release
|
|
CMAKE_INSTALL_PREFIX=libarchive\zstd\builddir
|
|
build-args: --config Release -j ${{ env.NUMBER_OF_PROCESSORS }}
|
|
|
|
- name: Create zstd release
|
|
run: cmake --install libarchive/zstd/builddir/
|
|
|
|
- name: Build libarchive
|
|
uses: threeal/cmake-action@v2.0.0
|
|
with:
|
|
source-dir: libarchive
|
|
build-dir: libarchive\builddir
|
|
generator: Visual Studio 17
|
|
options: |
|
|
CMAKE_VERBOSE_MAKEFILE=1
|
|
CMAKE_BUILD_TYPE=Release
|
|
CMAKE_INSTALL_PREFIX=libarchive\builddir
|
|
ENABLE_OPENSSL=OFF
|
|
ZLIB_LIBRARY=D:/a/Bolt/Bolt/libarchive/zlib/builddir/lib/zlibstatic.lib
|
|
ZLIB_INCLUDE_DIR=D:/a/Bolt/Bolt/libarchive/zlib/builddir/include
|
|
BZIP2_LIBRARIES=D:/a/Bolt/Bolt/libarchive/bzip2/builddir/lib/bz2_static.lib
|
|
BZIP2_INCLUDE_DIR=D:/a/Bolt/Bolt/libarchive/bzip2/builddir/include
|
|
LIBLZMA_LIBRARY=D:/a/Bolt/Bolt/libarchive/xz/builddir/lib/lzma.lib
|
|
LIBLZMA_INCLUDE_DIR=D:/a/Bolt/Bolt/libarchive/xz/builddir/include
|
|
ZSTD_LIBRARY=D:/a/Bolt/Bolt/libarchive/zstd/builddir/lib/zstd_static.lib
|
|
ZSTD_INCLUDE_DIR=D:/a/Bolt/Bolt/libarchive/zstd/builddir/include
|
|
build-args: --config Release -j ${{ env.NUMBER_OF_PROCESSORS }}
|
|
|
|
- name: Create libarchive release
|
|
run: cmake --install libarchive/builddir/
|
|
|
|
- name: Restore CEF from Cache
|
|
id: restore-cef-cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: Bolt\cef\dist
|
|
key: 'windows-cef-${{ env.WINDOWS_CEF_VERSION }}'
|
|
|
|
- name: Download CEF
|
|
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
Invoke-WebRequest -Uri 'https://adamcake.com/cef/cef-${{ env.WINDOWS_CEF_VERSION }}-windows64-minimal-ungoogled.zip' -OutFile 'cef.zip'
|
|
Expand-Archive -Path 'cef.zip' -DestinationPath 'cef'
|
|
Copy-Item -Path (Get-ChildItem -Path "cef" -Directory | Select-Object -First 1).FullName -Destination "Bolt\cef\dist" -Recurse
|
|
|
|
- name: Save CEF to Cache
|
|
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: Bolt\cef\dist
|
|
key: 'windows-cef-${{ env.WINDOWS_CEF_VERSION }}'
|
|
|
|
# At this point the file tree looks like
|
|
# C:\a\Bolt\Bolt
|
|
# - libarchive
|
|
# - <whole libarchive source>
|
|
# - bzip2/
|
|
# - xz/
|
|
# - zlib/
|
|
# - zstd/
|
|
# - LuaJIT
|
|
# - <whole luaJIT source>
|
|
# - Bolt
|
|
# - <whole Bolt source>
|
|
# - cef
|
|
# - dist
|
|
# - <CEF release distribution>
|
|
#
|
|
# The tree has many nested Bolt dirs because of how GHA works.
|
|
# The first two Bolt dirs (C:\a\Bolt\Bolt) are the workspace provided by github.
|
|
# Github always does it this way.
|
|
# Then github normally clones directly in to the workspace with a folder of the repo name.
|
|
# However for our usecase we clone multiple repos, so we have C:\a\Bolt\Bolt\{libarchive, LuaJIT, Bolt}
|
|
- name: Build Project
|
|
uses: threeal/cmake-action@v2.0.0
|
|
with:
|
|
source-dir: Bolt # The directory where CMakeLists.txt is located
|
|
build-dir: build # Makes it so that the build directory is set to Bolt/build
|
|
generator: Visual Studio 17
|
|
options: |
|
|
BOLT_LIBARCHIVE_DIR=${{ github.workspace }}\libarchive\builddir
|
|
BOLT_LUAJIT_DIR=${{ github.workspace }}\LuaJIT\src
|
|
CMAKE_BUILD_TYPE=Release
|
|
BOLT_CEF_INSTALLDIR=${{ github.workspace }}\install-location
|
|
build-args: --config Release -j ${{ env.NUMBER_OF_PROCESSORS }}
|
|
|
|
# Installs to C:\a\Bolt\Bolt\install-location\bolt-launcher\*
|
|
- name: Create Release
|
|
run: cmake --install build/
|
|
|
|
# Uploads C:\a\Bolt\Bolt\install-location as a zip
|
|
# With `bolt-launcher` as the root directory of the zip file
|
|
- name: Upload Build Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: Bolt-Windows-${{ github.sha }}
|
|
path: ${{ github.workspace }}\install-location
|
|
|
|
# Uploads the zip file to the release matching the format of the above step
|
|
# Such that build artifacts and release artifacts are the same
|
|
- name: Attach Bolt Artifact to Release
|
|
if: github.event_name == 'release' && env.ENABLE_WINDOWS_RELEASES == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
# In the script below we cd in to Bolt first, because otherwise the gh command will fail.
|
|
run: |
|
|
cd Bolt
|
|
Compress-Archive -Path ${{ github.workspace }}\install-location\bolt-launcher -DestinationPath ${{ github.workspace }}\Bolt-Windows.zip
|
|
gh release upload ${{ github.event.release.tag_name }} ${{ github.workspace }}\Bolt-Windows.zip
|
|
|
|
build-linux-project:
|
|
name: Build Linux
|
|
runs-on: ubuntu-24.04
|
|
steps:
|
|
- name: Checkout Project
|
|
uses: actions/checkout@v4.2.0
|
|
with:
|
|
submodules: recursive
|
|
|
|
- name: Install package dependencies
|
|
run: sudo apt update && sudo apt install -y libx11-dev libxcb1-dev libarchive-dev libluajit-5.1-dev clang cmake ninja-build
|
|
|
|
- name: Restore CEF from Cache
|
|
id: restore-cef-cache
|
|
uses: actions/cache/restore@v4
|
|
with:
|
|
path: cef/dist
|
|
key: 'linux-cef-${{ env.LINUX_CEF_VERSION }}'
|
|
|
|
- name: Download CEF
|
|
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
|
|
run: |
|
|
# Download cef and set up the directory structure
|
|
curl -o cef/cef.tar.xz 'https://adamcake.com/cef/cef-${{ env.LINUX_CEF_VERSION }}-linux-x86_64-minimal-ungoogled.tar.xz'
|
|
mkdir -p cef/dist
|
|
|
|
# Extract the cef tarball and copy the contents to the dist directory
|
|
tar -xf cef/cef.tar.xz --directory cef/dist
|
|
|
|
cef_content_dir=$(ls -d cef/dist/* | head -n 1)
|
|
mv "$cef_content_dir"/* cef/dist/
|
|
|
|
# Clean up the extracted directory
|
|
rm -rf "$cef_content_dir"
|
|
|
|
- name: Save CEF to Cache
|
|
if: steps.restore-cef-cache.outputs.cache-hit != 'true'
|
|
uses: actions/cache/save@v4
|
|
with:
|
|
path: cef/dist
|
|
key: 'linux-cef-${{ env.LINUX_CEF_VERSION }}'
|
|
|
|
- name: Build Project
|
|
uses: threeal/cmake-action@v2.0.0
|
|
with:
|
|
build-dir: build # Makes it so that the build directory is set to ./build
|
|
generator: Ninja
|
|
options: |
|
|
CMAKE_BUILD_TYPE=Release
|
|
build-args: --config Release -j ${{ env.NUMBER_OF_PROCESSORS }}
|
|
|
|
- name: Create Release
|
|
run: |
|
|
cmake --install build/ --prefix install
|
|
chmod +x install/opt/bolt-launcher/bolt
|
|
|
|
- name: Upload Build Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: Bolt-Linux-${{ github.sha }}
|
|
path: install/opt/
|
|
|
|
# Uploads the zip file to the release matching the format of the above step
|
|
# Such that build artifacts and release artifacts are the same
|
|
- name: Attach Bolt Artifact to Release
|
|
if: github.event_name == 'release' && env.ENABLE_LINUX_RELEASES == 'true'
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
cd install/opt
|
|
zip -r ../../Bolt-Linux.zip .
|
|
cd ../../
|
|
gh release upload ${{ github.event.release.tag_name }} Bolt-Linux.zip
|