From 73b51be43f186fa6a9bcf9483352a1008ac961cd Mon Sep 17 00:00:00 2001 From: TheBrokenRail Date: Fri, 24 Nov 2023 18:37:08 -0500 Subject: [PATCH] Try Fancy CI --- .gitea/workflows/build.yml | 70 +++++++++++++++++++++++++++------ scripts/build.sh | 4 +- scripts/install-dependencies.sh | 2 +- scripts/package-all.sh | 14 ------- scripts/package.sh | 26 ++++++------ scripts/setup.sh | 17 ++++---- 6 files changed, 83 insertions(+), 50 deletions(-) delete mode 100755 scripts/package-all.sh diff --git a/.gitea/workflows/build.yml b/.gitea/workflows/build.yml index 3f92b5d04..8b52da95c 100644 --- a/.gitea/workflows/build.yml +++ b/.gitea/workflows/build.yml @@ -9,39 +9,83 @@ on: - '!flatpak' jobs: + # Build Project build: + strategy: + fail-fast: false + matrix: + mode: + - Client + - Server + arch: + - AMD64 + - ARM64 + - ARMHF + name: ${{ matrix.mode }} (${{ matrix.arch }}) runs-on: ubuntu-latest container: node:16-buster steps: - name: Checkout Repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: true - # Dependencies - - name: Install Go - uses: actions/setup-go@v4 - with: - go-version: '>=1.20.1' + # Dependencies - name: Install CMake run: | echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/backports.list apt-get update apt-get install --no-install-recommends -y -t buster-backports cmake - name: Install Dependencies - run: ./scripts/install-dependencies.sh amd64 armhf arm64 - # Build + run: ./scripts/install-dependencies.sh ${{ matrix.arch }} + # Build - name: Build - run: ./scripts/package-all.sh - - name: Test - run: ./scripts/test.sh + run: ./scripts/package.sh ${{ matrix.mode }} ${{ matrix.arch }} - name: Upload Artifacts uses: actions/upload-artifact@v3 with: + name: ${{ matrix.mode }}-${{ matrix.arch }} path: ./out/*.AppImage* - # Create Release + # Test Project + test: + name: Test + runs-on: ubuntu-latest + container: node:16-buster + steps: + - name: Checkout Repository + uses: actions/checkout@v4 + with: + submodules: true + # Dependencies + - name: Install CMake + run: | + echo 'deb http://deb.debian.org/debian buster-backports main' > /etc/apt/sources.list.d/backports.list + apt-get update + apt-get install --no-install-recommends -y -t buster-backports cmake + - name: Install Dependencies + run: ./scripts/install-dependencies.sh + # Test + - name: Test + run: ./scripts/test.sh + # Create Release + release: + if: startsWith(github.ref, 'refs/tags/') + needs: build + name: Release + runs-on: ubuntu-latest + container: node:16-buster + steps: + # Dependencies + - name: Install Go + uses: actions/setup-go@v4 + with: + go-version: '>=1.20.1' + # Download Artifacts + - uses: actions/download-artifact@v3 + with: + path: out + # Create Release - name: Create Release uses: https://gitea.com/actions/release-action@main - if: startsWith(github.ref, 'refs/tags/') with: files: ./out/*.AppImage* api_key: ${{ secrets.RELEASE_TOKEN }} diff --git a/scripts/build.sh b/scripts/build.sh index f40fde61f..888860b5b 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -34,8 +34,8 @@ build() { } # Variables -MODE="$1" -ARCH="$2" +MODE="$(echo "$1" | tr '[:upper:]' '[:lower:]')" +ARCH="$(echo "$2" | tr '[:upper:]' '[:lower:]')" shift 2 # Build diff --git a/scripts/install-dependencies.sh b/scripts/install-dependencies.sh index 006b70a0a..3825314e5 100755 --- a/scripts/install-dependencies.sh +++ b/scripts/install-dependencies.sh @@ -82,7 +82,7 @@ run() { libglib2.0-dev:$1 } for arch in "$@"; do - architecture_specific_pkg "${arch}" + architecture_specific_pkg "$(echo "${arch}" | tr '[:upper:]' '[:lower:]')" done # AppStream Verification diff --git a/scripts/package-all.sh b/scripts/package-all.sh deleted file mode 100755 index a0ae95db6..000000000 --- a/scripts/package-all.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh - -set -e - -# Clean Prefix -rm -rf out - -# Build -./scripts/package.sh client amd64 -./scripts/package.sh server amd64 -./scripts/package.sh client arm64 -./scripts/package.sh server arm64 -./scripts/package.sh client armhf -./scripts/package.sh server armhf diff --git a/scripts/package.sh b/scripts/package.sh index be0ee9956..21cb1cf3e 100755 --- a/scripts/package.sh +++ b/scripts/package.sh @@ -4,37 +4,39 @@ set -e # Prepare NAME='minecraft-pi-reborn' +MODE="$(echo "$1" | tr '[:upper:]' '[:lower:]')" +ARCH="$(echo "$2" | tr '[:upper:]' '[:lower:]')" # Build -./scripts/setup.sh "$1" "$2" -DMCPI_IS_APPIMAGE_BUILD=ON -./scripts/build.sh "$1" "$2" +./scripts/setup.sh "${MODE}" "${ARCH}" -DMCPI_IS_APPIMAGE_BUILD=ON +./scripts/build.sh "${MODE}" "${ARCH}" # Download Runtime mkdir -p build/appimage -if [ ! -f "build/appimage/runtime-$2" ]; then - case "$2" in +if [ ! -f "build/appimage/runtime-${ARCH}" ]; then + case "${ARCH}" in 'armhf') RUNTIME_ARCH='armhf';; 'arm64') RUNTIME_ARCH='aarch64';; 'i386') RUNTIME_ARCH='i686';; 'amd64') RUNTIME_ARCH='x86_64';; esac - wget -O "build/appimage/runtime-$2" "https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-${RUNTIME_ARCH}" + wget -O "build/appimage/runtime-${ARCH}" "https://github.com/AppImage/AppImageKit/releases/download/continuous/runtime-${RUNTIME_ARCH}" fi # Package -case "$2" in +case "${ARCH}" in 'armhf') APPIMAGE_ARCH='arm';; 'arm64') APPIMAGE_ARCH='arm_aarch64';; 'i386') APPIMAGE_ARCH='i686';; 'amd64') APPIMAGE_ARCH='x86_64';; esac ARCH="${APPIMAGE_ARCH}" appimagetool \ - --updateinformation "zsync|https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/releases/download/latest/${NAME}-latest-$2.AppImage.zsync" \ - --runtime-file "build/appimage/runtime-$2" \ + --updateinformation "zsync|https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/releases/download/latest/${NAME}-latest-${ARCH}.AppImage.zsync" \ + --runtime-file "build/appimage/runtime-${ARCH}" \ --comp xz \ - "./out/$1-$2" \ - "./out/${NAME}-$1-$(cat VERSION)-$2.AppImage" + "./out/${MODE}-${ARCH}" \ + "./out/${NAME}-${MODE}-$(cat VERSION)-${ARCH}.AppImage" # Move ZSync -rm -f "./out/${NAME}-$1-latest-$2.AppImage.zsync" -mv "./${NAME}-$1-$(cat VERSION)-$2.AppImage.zsync" "./out/${NAME}-$1-latest-$2.AppImage.zsync" +rm -f "./out/${NAME}-${MODE}-latest-${ARCH}.AppImage.zsync" +mv "./${NAME}-${MODE}-$(cat VERSION)-${ARCH}.AppImage.zsync" "./out/${NAME}-${MODE}-latest-${ARCH}.AppImage.zsync" diff --git a/scripts/setup.sh b/scripts/setup.sh index 3b85bcc04..4d8a0112e 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -8,7 +8,7 @@ ARM_TOOLCHAIN_FILE="$(pwd)/cmake/toolchain/armhf-toolchain.cmake" # Setup setup() { # Find Toolchain - local toolchain_file="$(pwd)/cmake/toolchain/${ARCH}-toolchain.cmake" + toolchain_file="$(pwd)/cmake/toolchain/${ARCH}-toolchain.cmake" if [ ! -f "${toolchain_file}" ]; then echo "Invalid Architecture: ${ARCH}" > /dev/stderr exit 1 @@ -20,27 +20,28 @@ setup() { cd "build/${MODE}-${ARCH}" # Server Build - local server_mode='OFF' + server_mode='OFF' if [ "${MODE}" = "server" ]; then server_mode='ON' fi - # Mixed Build - local mixed_build='ON' + mixed_build='ON' if [ "${ARCH}" = "armhf" ]; then mixed_build='OFF' fi + # Extra Flags + extra_flags="-DMCPI_IS_MIXED_BUILD=${mixed_build} -DMCPI_SERVER_MODE=${server_mode}" # Build ARM Components mkdir arm cd arm - cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="${ARM_TOOLCHAIN_FILE}" -DMCPI_BUILD_MODE=arm -DMCPI_IS_MIXED_BUILD="${mixed_build}" -DMCPI_SERVER_MODE="${server_mode}" "$@" ../../.. + cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="${ARM_TOOLCHAIN_FILE}" -DMCPI_BUILD_MODE=arm ${extra_flags} "$@" ../../.. cd ../ # Build Native Components mkdir native cd native - cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DMCPI_BUILD_MODE=native -DMCPI_IS_MIXED_BUILD="${mixed_build}" -DMCPI_SERVER_MODE="${server_mode}" "$@" ../../.. + cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE="${toolchain_file}" -DMCPI_BUILD_MODE=native ${extra_flags} "$@" ../../.. cd ../ # Exit @@ -48,8 +49,8 @@ setup() { } # Variables -MODE="$1" -ARCH="$2" +MODE="$(echo "$1" | tr '[:upper:]' '[:lower:]')" +ARCH="$(echo "$2" | tr '[:upper:]' '[:lower:]')" shift 2 # Verify Mode