Skip to content

Commit

Permalink
chore: run generate script in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
Laupetin committed Jan 12, 2025
1 parent 6e6bfca commit d1d4752
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 45 deletions.
27 changes: 7 additions & 20 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,15 @@ on:
branches:
- "main"

env:
PREMAKE_VERSION: "5.0.0-beta4"

jobs:
build-test-linux:
env:
PREMAKE_CONFIG: gmake2
runs-on: ubuntu-latest
container: ubuntu:24.04
steps:
- name: Install g++ and multilib
run: |
apt-get update
apt-get install -y git make gcc-13 g++-13 gcc-13-multilib g++-13-multilib
apt-get install -y wget tar git make gcc-13 g++-13 gcc-13-multilib g++-13-multilib
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
update-alternatives --set gcc /usr/bin/gcc-13
Expand All @@ -32,14 +27,11 @@ jobs:
with:
submodules: recursive

- name: Setup premake
uses: abel0b/setup-premake@v2.4
with:
version: ${{ env.PREMAKE_VERSION }}

- name: Premake generate
working-directory: ${{ github.workspace }}
run: premake5 ${{ env.PREMAKE_CONFIG }}
env:
OAT_CI_NO_PROMPT: 1
run: ./generate.sh

- name: Build
working-directory: ${{ github.workspace }}
Expand All @@ -56,8 +48,6 @@ jobs:
./ZoneCommonTests
build-test-windows:
env:
PREMAKE_CONFIG: vs2022
runs-on: windows-latest
steps:
- name: Checkout repository
Expand All @@ -68,14 +58,11 @@ jobs:
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2.0.0

- name: Setup premake
uses: abel0b/setup-premake@v2.4
with:
version: ${{ env.PREMAKE_VERSION }}

- name: Premake generate
working-directory: ${{ github.workspace }}
run: premake5 ${{ env.PREMAKE_CONFIG }}
env:
OAT_CI_NO_PROMPT: 1
run: ./generate.bat

- name: Build
working-directory: ${{ github.workspace }}
Expand Down
27 changes: 7 additions & 20 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,15 @@ on:
tags:
- "v*.*.*"

env:
PREMAKE_VERSION: "5.0.0-beta4"

jobs:
build-release-linux:
env:
PREMAKE_CONFIG: gmake2
runs-on: ubuntu-latest
container: ubuntu:24.04
steps:
- name: Install g++ and multilib
run: |
apt-get update
apt-get install -y git make gcc-13 g++-13 gcc-13-multilib g++-13-multilib
apt-get install -y wget tar git make gcc-13 g++-13 gcc-13-multilib g++-13-multilib
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-13 13
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-13 13
update-alternatives --set gcc /usr/bin/gcc-13
Expand All @@ -29,14 +24,11 @@ jobs:
with:
submodules: recursive

- name: Setup premake
uses: abel0b/setup-premake@v2.4
with:
version: ${{ env.PREMAKE_VERSION }}

- name: Premake generate
working-directory: ${{ github.workspace }}
run: premake5 ${{ env.PREMAKE_CONFIG }}
env:
OAT_CI_NO_PROMPT: 1
run: ./generate.sh

- name: Build
working-directory: ${{ github.workspace }}
Expand All @@ -50,8 +42,6 @@ jobs:
${{ github.workspace }}/build/bin/Release_x86
build-release-windows:
env:
PREMAKE_CONFIG: vs2022
runs-on: windows-latest
steps:
- name: Checkout repository
Expand All @@ -62,14 +52,11 @@ jobs:
- name: Add MSBuild to PATH
uses: microsoft/setup-msbuild@v2.0.0

- name: Setup premake
uses: abel0b/setup-premake@v2.4
with:
version: ${{ env.PREMAKE_VERSION }}

- name: Premake generate
working-directory: ${{ github.workspace }}
run: premake5 ${{ env.PREMAKE_CONFIG }}
env:
OAT_CI_NO_PROMPT: 1
run: ./generate.bat

- name: Build
working-directory: ${{ github.workspace }}
Expand Down
24 changes: 20 additions & 4 deletions generate.bat
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,31 @@ goto start

if not exist "build" mkdir "build"

powershell -Command "Invoke-WebRequest %PREMAKE_URL% -OutFile build/premake.zip"
where /q "pwsh"
IF %ERRORLEVEL% EQU 0 (
set POWERSHELL_BIN="pwsh"
) else (
set POWERSHELL_BIN="powershell"
)

echo Downloading...
%POWERSHELL_BIN% -Command "Invoke-WebRequest %PREMAKE_URL% -OutFile build/premake.zip"
IF %ERRORLEVEL% NEQ 0 (
echo Download failed >&2
exit 2
)

powershell -Command "Expand-Archive -LiteralPath build/premake.zip -DestinationPath build"
echo Extracting...
%POWERSHELL_BIN% -Command "Expand-Archive -LiteralPath build/premake.zip -DestinationPath build"
IF %ERRORLEVEL% NEQ 0 (
echo Extraction failed >&2
exit 2
)

rm build/premake.zip

powershell -Command "if ((Get-FileHash -LiteralPath build/premake5.exe -Algorithm SHA256).Hash -eq \"%PREMAKE_HASH%\") { exit 0 } else { exit 1 }"
echo Verifying hash...
%POWERSHELL_BIN% -Command "if ((Get-FileHash -LiteralPath build/premake5.exe -Algorithm SHA256).Hash -eq \"%PREMAKE_HASH%\") { exit 0 } else { exit 1 }"
IF %ERRORLEVEL% NEQ 0 (
echo Hash verification failed >&2
rm build/premake5.exe
Expand All @@ -46,9 +56,15 @@ IF EXIST build/premake5.exe (
goto runpremake
)

if "%OAT_CI_NO_PROMPT%" NEQ "" (
call:downloadpremake
set PREMAKE_BIN="build/premake5.exe"
goto runpremake
)

echo Could not find premake5. You can either install it yourself or this script download it for you.
set /p choice="Do you wish to download it automatically? [y/N]> "
if /i "%choice%"=="y" (
if /i "%choice%" == "y" (
call:downloadpremake
set PREMAKE_BIN="build/premake5.exe"
goto runpremake
Expand Down
2 changes: 1 addition & 1 deletion generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ elif [[ -x "$(command -v build/premake5)" ]]; then
PREMAKE_BIN='build/premake5'
else
echo "Could not find premake5. You can either install it yourself or this script download it for you."
if [[ "$(read -e -p 'Do you wish to download it automatically? [y/N]> '; echo $REPLY)" == [Yy]* ]]; then
if [[ ! -z "$OAT_CI_NO_PROMPT" ]] || [[ "$(read -e -p 'Do you wish to download it automatically? [y/N]> '; echo $REPLY)" == [Yy]* ]]; then
echo "Installing premake"
install_premake
PREMAKE_BIN='build/premake5'
Expand Down

0 comments on commit d1d4752

Please sign in to comment.