PrismLauncher/.github/workflows/build.yml

258 lines
8.8 KiB
YAML
Raw Normal View History

name: Build
2022-02-02 06:28:00 +00:00
on:
workflow_call:
inputs:
build_type:
description: Type of build (Debug, Release, RelWithDebInfo, MinSizeRel)
type: string
default: Debug
2022-02-02 06:28:00 +00:00
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
2022-02-19 19:46:43 +00:00
- os: ubuntu-20.04
2022-02-02 06:28:00 +00:00
- os: windows-2022
2022-03-17 15:55:45 +00:00
name: "Windows-i686"
msystem: mingw32
- os: windows-2022
name: "Windows-x86_64"
msystem: mingw64
2022-03-21 18:11:55 +00:00
2022-02-02 06:28:00 +00:00
- os: macos-11
macosx_deployment_target: 10.13
2022-02-02 06:28:00 +00:00
runs-on: ${{ matrix.os }}
env:
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
INSTALL_DIR: "install"
INSTALL_PORTABLE_DIR: "install-portable"
INSTALL_APPIMAGE_DIR: "install-appdir"
BUILD_DIR: "build"
2022-02-02 06:28:00 +00:00
steps:
##
# PREPARE
##
2022-02-12 04:30:13 +00:00
- name: Checkout
uses: actions/checkout@v3
2022-02-12 04:30:13 +00:00
with:
submodules: 'true'
2022-03-17 15:55:45 +00:00
- name: 'Setup MSYS2'
2022-02-10 15:28:31 +00:00
if: runner.os == 'Windows'
2022-03-17 15:55:45 +00:00
uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: true
install: >-
git
pacboy: >-
toolchain:p
cmake:p
ninja:p
qt5:p
2022-03-18 21:28:52 +00:00
- name: Set short version
shell: bash
run: |
ver_short=`git rev-parse --short HEAD`
echo "VERSION=$ver_short" >> $GITHUB_ENV
2022-02-02 06:28:00 +00:00
- name: Install OpenJDK
2022-03-17 22:32:44 +00:00
uses: actions/setup-java@v3
2022-02-02 06:28:00 +00:00
with:
2022-03-17 22:32:44 +00:00
distribution: 'temurin'
java-version: '17'
2022-02-02 06:28:00 +00:00
- name: Install Qt (macOS)
if: runner.os == 'macOS'
run: |
brew update
brew install qt@5
2022-02-02 06:28:00 +00:00
- name: Install Qt (Linux)
if: runner.os == 'Linux'
2022-02-22 14:41:17 +00:00
run: |
2022-03-10 08:08:16 +00:00
sudo apt-get -y update
2022-02-22 14:41:17 +00:00
sudo apt-get -y install qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libqt5core5a libqt5network5 libqt5gui5
2022-02-02 06:28:00 +00:00
- name: Install Ninja
2022-03-17 15:55:45 +00:00
if: runner.os != 'Windows'
2022-02-02 06:28:00 +00:00
uses: urkle/action-get-ninja@v1
- name: Prepare AppImage (Linux)
if: runner.os == 'Linux'
2022-02-07 12:19:58 +00:00
run: |
wget "https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage"
wget "https://github.com/linuxdeploy/linuxdeploy-plugin-appimage/releases/download/continuous/linuxdeploy-plugin-appimage-x86_64.AppImage"
wget "https://github.com/linuxdeploy/linuxdeploy-plugin-qt/releases/download/continuous/linuxdeploy-plugin-qt-x86_64.AppImage"
${{ github.workspace }}/.github/scripts/prepare_JREs.sh
##
# CONFIGURE
##
- name: Configure CMake (macOS)
if: runner.os == 'macOS'
2022-03-17 15:55:45 +00:00
run: |
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DQt5_DIR=/usr/local/opt/qt@5 -DCMAKE_PREFIX_PATH=/usr/local/opt/qt@5 -DLauncher_BUILD_PLATFORM=macOS -G Ninja
2022-03-17 15:55:45 +00:00
- name: Configure CMake (Windows)
if: runner.os == 'Windows'
2022-03-17 15:55:45 +00:00
shell: msys2 {0}
run: |
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=${{ env.INSTALL_DIR }} -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=${{ matrix.name }} -G Ninja
2022-03-21 18:29:33 +00:00
- name: Configure CMake (Linux)
if: runner.os == 'Linux'
2022-03-21 18:29:33 +00:00
run: |
cmake -S . -B ${{ env.BUILD_DIR }} -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=${{ inputs.build_type }} -DENABLE_LTO=ON -DLauncher_BUILD_PLATFORM=Linux -G Ninja
##
# BUILD
##
2022-03-25 12:13:50 +00:00
2022-02-02 06:28:00 +00:00
- name: Build
2022-03-17 15:55:45 +00:00
if: runner.os != 'Windows'
run: |
cmake --build ${{ env.BUILD_DIR }}
- name: Build (Windows)
2022-03-21 18:29:33 +00:00
if: runner.os == 'Windows'
2022-03-17 15:55:45 +00:00
shell: msys2 {0}
2022-02-02 06:28:00 +00:00
run: |
cmake --build ${{ env.BUILD_DIR }}
2022-02-02 06:28:00 +00:00
##
# PACKAGE BUILDS
##
- name: Package (macOS)
if: runner.os == 'macOS'
2022-03-17 15:55:45 +00:00
run: |
cmake --install ${{ env.BUILD_DIR }}
cd ${{ env.INSTALL_DIR }}
chmod +x "PolyMC.app/Contents/MacOS/polymc"
sudo codesign --sign - --deep --force --entitlements "../program_info/App.entitlements" --options runtime "PolyMC.app/Contents/MacOS/polymc"
tar -czf ../PolyMC.tar.gz *
- name: Package (Windows)
2022-03-17 15:55:45 +00:00
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
cmake --install ${{ env.BUILD_DIR }}
cd ${{ env.INSTALL_DIR }}
if [ "${{ matrix.msystem }}" == "mingw32" ]; then
cp /mingw32/bin/libcrypto-1_1.dll /mingw32/bin/libssl-1_1.dll ./
elif [ "${{ matrix.msystem }}" == "mingw64" ]; then
cp /mingw64/bin/libcrypto-1_1-x64.dll /mingw64/bin/libssl-1_1-x64.dll ./
fi
- name: Package (Windows, portable)
if: runner.os == 'Windows'
shell: msys2 {0}
2022-02-02 06:28:00 +00:00
run: |
cp -r ${{ env.INSTALL_DIR }} ${{ env.INSTALL_PORTABLE_DIR }} # cmake install on Windows is slow, let's just copy instead
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable
- name: Package (Linux)
if: runner.os == 'Linux'
2022-03-25 12:13:50 +00:00
run: |
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_DIR }}
cd ${{ env.INSTALL_DIR }}
tar --owner root --group root -czf ../PolyMC.tar.gz *
- name: Package (Linux, portable)
if: runner.os == 'Linux'
run: |
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }}
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_PORTABLE_DIR }} --component portable
cd ${{ env.INSTALL_PORTABLE_DIR }}
tar -czf ../PolyMC-portable.tar.gz *
2022-03-25 12:13:50 +00:00
- name: Package AppImage (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
cmake --install ${{ env.BUILD_DIR }} --prefix ${{ env.INSTALL_APPIMAGE_DIR }}/usr
export OUTPUT="PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage"
2022-02-07 13:11:42 +00:00
chmod +x linuxdeploy-*.AppImage
2022-02-07 13:11:42 +00:00
mkdir -p ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-{8,17}-openjdk
2022-02-07 13:11:42 +00:00
cp -r ${{ github.workspace }}/JREs/jre8/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk
2022-02-07 13:11:42 +00:00
cp -r ${{ github.workspace }}/JREs/jre17/* ${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk
2022-02-07 13:11:42 +00:00
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib"
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64/server"
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-8-openjdk/lib/amd64"
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk/lib/server"
LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${{ env.INSTALL_APPIMAGE_DIR }}/usr/lib/jvm/java-17-openjdk/lib"
export LD_LIBRARY_PATH
./linuxdeploy-x86_64.AppImage --appdir ${{ env.INSTALL_APPIMAGE_DIR }} --output appimage --plugin qt -i ${{ env.INSTALL_APPIMAGE_DIR }}/usr/share/icons/hicolor/scalable/apps/org.polymc.PolyMC.svg
2022-02-02 06:28:00 +00:00
##
# UPLOAD BUILDS
##
2022-02-02 06:28:00 +00:00
- name: Upload binary tarball (macOS)
2022-02-02 06:28:00 +00:00
if: runner.os == 'macOS'
uses: actions/upload-artifact@v3
with:
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
path: PolyMC.tar.gz
2022-02-02 06:28:00 +00:00
- name: Upload binary zip (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: PolyMC-${{ matrix.name }}-${{ env.VERSION }}-${{ inputs.build_type }}
path: ${{ env.INSTALL_DIR }}/**
2022-02-19 19:46:43 +00:00
- name: Upload binary zip (Windows, portable)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: PolyMC-${{ matrix.name }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
path: ${{ env.INSTALL_PORTABLE_DIR }}/**
2022-03-25 12:13:50 +00:00
- name: Upload binary tarball (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
2022-02-19 19:46:43 +00:00
with:
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}
path: PolyMC.tar.gz
- name: Upload binary tarball (Linux, portable)
if: runner.os == 'Linux'
2022-03-25 12:13:50 +00:00
uses: actions/upload-artifact@v3
with:
name: PolyMC-${{ runner.os }}-Portable-${{ env.VERSION }}-${{ inputs.build_type }}
path: PolyMC-portable.tar.gz
- name: Upload AppImage (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
path: PolyMC-${{ runner.os }}-${{ env.VERSION }}-${{ inputs.build_type }}-x86_64.AppImage
2022-03-17 15:55:45 +00:00