Skip to content

Commit

Permalink
GitHub Actions implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
igor725 committed Dec 8, 2023
1 parent 38ffa59 commit 1569736
Show file tree
Hide file tree
Showing 9 changed files with 172 additions and 0 deletions.
67 changes: 67 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: build

on:
pull_request:
types: [opened, reopened]
push:
tags:
- 'v*'

jobs:
build:

name: Building library
runs-on: ubuntu-latest

steps:
- name: Checkout lua-vosk
uses: actions/checkout@v3
with:
path: luavosk

- name: Minor preparations
run: sudo apt install gcc-aarch64-linux-gnu mingw-w64

- name: Get previous tag
id: prevtag
shell: bash
run: |
echo "tag=$(GIT.EXE describe --abbrev=0 --tags ${{ github.ref_name }}^)" >> $GITHUB_OUTPUT
- name: Init LuaJIT
working-directory: luavosk/misc
run: ./init.sh

- name: Linux x64 build
working-directory: luavosk/misc
run: ./build-linux-x64.sh

- name: Linux arm64 build
working-directory: luavosk/misc
run: ./build-linux-arm64.sh

- name: Windows x64 build
working-directory: luavosk/misc
run: ./build-win-x64.sh

- name: Zip it up
working-directory: luavosk/misc/out
run: |
zip -q windows-x64.zip win-amd64/luavosk.dll
zip -q linux-arm64.zip linux-arm64/luavosk.so
zip -q linux-x64.zip linux-amd64/luavosk.so
cd ../../
zip -q -u -r ./misc/out/windows-x64.zip test/ README.md LICENSE
zip -q -u -r ./misc/out/linux-arm64.zip test/ README.md LICENSE
zip -q -u -r ./misc/out/linux-x64.zip test/ README.md LICENSE
- name: Create release
uses: softprops/action-gh-release@v1
with:
prerelease: true
name: Pre-release ${{ github.ref_name }}
body: "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${{ steps.prevtag.outputs.tag }}...${{ github.ref_name }}"
files: |
./luavosk/misc/out/windows-x64.zip
./luavosk/misc/out/linux-arm64.zip
./luavosk/misc/out/linux-x64.zip
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ test/*
test/webexample/*.dll
.vscode/settings.json
/build/
misc/out/
misc/luajit/
23 changes: 23 additions & 0 deletions misc/TC-linux-arm64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)

set(TOOLCHAIN_PREFIX aarch64-linux-gnu-)
execute_process(
COMMAND which ${TOOLCHAIN_PREFIX}gcc
OUTPUT_VARIABLE BINUTILS_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN_PREFIX}gcc)
SET(CMAKE_C_COMPILER_FORCED TRUE CACHE INTERNAL "")

set(CMAKE_MAKE_PROGRAM /usr/bin/make)

set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH})
set(CMAKE_INCLUDE_PATH /usr/${TOOLCHAIN_PREFIX}/include)
set(CMAKE_LIBRARY_PATH /usr/${TOOLCHAIN_PREFIX}/lib)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
23 changes: 23 additions & 0 deletions misc/TC-linux-x64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR amd64)

set(TOOLCHAIN_PREFIX x86_64-linux-gnu-)
execute_process(
COMMAND which ${TOOLCHAIN_PREFIX}gcc
OUTPUT_VARIABLE BINUTILS_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN_PREFIX}gcc)
SET(CMAKE_C_COMPILER_FORCED TRUE CACHE INTERNAL "")

set(CMAKE_MAKE_PROGRAM /usr/bin/make)

set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH})
set(CMAKE_INCLUDE_PATH /usr/${TOOLCHAIN_PREFIX}/include)
set(CMAKE_LIBRARY_PATH /usr/${TOOLCHAIN_PREFIX}/lib)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
23 changes: 23 additions & 0 deletions misc/TC-win-x64.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
set(CMAKE_SYSTEM_NAME Windows)
set(CMAKE_SYSTEM_PROCESSOR amd64)

set(TOOLCHAIN_PREFIX x86_64-w64-mingw32-)
execute_process(
COMMAND which ${TOOLCHAIN_PREFIX}gcc
OUTPUT_VARIABLE BINUTILS_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

set(CMAKE_C_COMPILER ${TOOLCHAIN_PREFIX}gcc)
set(CMAKE_C_COMPILER_TARGET ${TOOLCHAIN_PREFIX}gcc)
SET(CMAKE_C_COMPILER_FORCED TRUE CACHE INTERNAL "")

set(CMAKE_MAKE_PROGRAM /usr/bin/make)

set(CMAKE_FIND_ROOT_PATH ${BINUTILS_PATH})
set(CMAKE_INCLUDE_PATH /usr/include/${TOOLCHAIN_PREFIX})
set(CMAKE_LIBRARY_PATH /usr/lib/${TOOLCHAIN_PREFIX})

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
10 changes: 10 additions & 0 deletions misc/build-linux-arm64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
MAINDIR=$(dirname `readlink -f "$0"`)
cd "$MAINDIR/luajit"
make clean
make HOST_CC=gcc CROSS=aarch64-linux-gnu- TARGET_SYS=Linux -j$(nproc)
cd "$MAINDIR"
mkdir -p out/linux-arm64
cd out/linux-arm64
cmake "$MAINDIR/.." -DCMAKE_TOOLCHAIN_FILE="$MAINDIR/TC-linux-arm64.cmake" -DLUA_INCLUDE_DIR="$MAINDIR/luajit/src/" -DLUA_LIBRARIES="$MAINDIR/luajit/src/libluajit.so"
make -j$(nproc)
10 changes: 10 additions & 0 deletions misc/build-linux-x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
MAINDIR=$(dirname `readlink -f "$0"`)
cd "$MAINDIR/luajit"
make clean
make HOST_CC=gcc CROSS=x86_64-linux-gnu- TARGET_SYS=Linux -j$(nproc)
cd "$MAINDIR"
mkdir -p out/linux-amd64
cd out/linux-amd64
cmake "$MAINDIR/.." -DCMAKE_TOOLCHAIN_FILE="$MAINDIR/TC-linux-x64.cmake" -DLUA_INCLUDE_DIR="$MAINDIR/luajit/src/" -DLUA_LIBRARIES="$MAINDIR/luajit/src/libluajit.so"
make -j$(nproc)
10 changes: 10 additions & 0 deletions misc/build-win-x64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
MAINDIR=$(dirname `readlink -f "$0"`)
cd "$MAINDIR/luajit"
make clean
make HOST_CC=gcc CROSS=x86_64-w64-mingw32- TARGET_SYS=Windows -j$(nproc)
cd "$MAINDIR"
mkdir -p out/win-amd64
cd out/win-amd64
cmake "$MAINDIR/.." -DCMAKE_TOOLCHAIN_FILE="$MAINDIR/TC-win-x64.cmake" -DLUA_INCLUDE_DIR="$MAINDIR/luajit/src/" -DLUA_LIBRARIES="$MAINDIR/luajit/src/lua51.dll"
make -j$(nproc)
4 changes: 4 additions & 0 deletions misc/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
MAINDIR=$(dirname `readlink -f "$0"`)
rm -rf "$MAINDIR/out/"
git clone https://github.com/LuaJIT/LuaJIT "$MAINDIR/luajit"

0 comments on commit 1569736

Please sign in to comment.