Merge branch 'master' of https://github.com/topvisor/v8js #43
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-v8 | |
on: | |
schedule: | |
# запуск ежегодно (в 00:00, 15-го января, независимо от дня недели) | |
- cron: "0 0 15 1 *" | |
push: | |
# запуск только при пуше в мастер | |
branches: | |
- "master" | |
# запуск, если изменился код пайплайна | |
paths: | |
- ".github/workflows/**/*" | |
jobs: | |
build-v8: | |
runs-on: ubuntu-latest | |
timeout-minutes: 140 | |
steps: | |
- uses: actions/checkout@v3 | |
# писалось с опорой на гайд https://v8.dev/docs/build | |
- name: install gclient | |
run: | | |
git clone --depth 1 https://chromium.googlesource.com/chromium/tools/depot_tools.git | |
# обновление PATH нужно, чтобы все утилиты из depot_tools вызывались из любого места через gclient | |
PATH=$GITHUB_WORKSPACE/depot_tools:$PATH | |
gclient | |
- name: download v8 | |
run: | | |
mkdir v8-src && cd v8-src | |
PATH=$GITHUB_WORKSPACE/depot_tools:$PATH | |
fetch v8 | |
- name: sync v8 | |
run: | | |
cd v8-src/v8 | |
PATH=$GITHUB_WORKSPACE/depot_tools:$PATH | |
gclient sync | |
- name: build v8 | |
run: | | |
PATH=$GITHUB_WORKSPACE/depot_tools:$PATH | |
cd v8-src/v8 | |
# отключить использование snapshot_blob.bin | |
echo "v8_use_external_startup_data = false" > ./build/args/tv-args.gn | |
mkdir -p ./out/x64.release | |
echo 'import("//build/args/tv-args.gn")' > ./out/x64.release/args.gn | |
gn gen out/x64.release | |
# установить дополнительные зависимости | |
./build/install-build-deps.sh | |
# собрать и протестировать | |
./tools/dev/gm.py x64.release.check | |
- name: get needed files for debian package | |
run: | | |
cd ./v8-src/v8/out/x64.release | |
mkdir -p "$GITHUB_WORKSPACE/v8js/topvisor/v8js" | |
# без этих файлов d8 работать не будет | |
cp \ | |
d8 \ | |
libchrome_zlib.so \ | |
libchrome_zlib.so.TOC \ | |
libc++.so \ | |
libicuuc.so \ | |
libicuuc.so.TOC \ | |
libthird_party_abseil-cpp_absl.so \ | |
libthird_party_abseil-cpp_absl.so.TOC \ | |
libthird_party_icu_icui18n.so \ | |
libthird_party_icu_icui18n.so.TOC \ | |
libv8_libbase.so \ | |
libv8_libbase.so.TOC \ | |
libv8_libplatform.so \ | |
libv8_libplatform.so.TOC \ | |
libv8.so \ | |
libv8.so.TOC \ | |
v8_build_config.json \ | |
--target-directory "$GITHUB_WORKSPACE/v8js/topvisor/v8js" | |
- name: define v8 version | |
id: definingV8Version | |
run: | | |
v8Version="$($GITHUB_WORKSPACE/v8js/topvisor/v8js/d8 <<< "console.log('hi');" | head -n 1 | awk '{ print $3 }' | awk -F'.' '{ print $1,$2 }' | tr ' ' '.')" | |
arch="$(awk '{ if ($1 ~ "Architecture:") { print $2 } }' "$GITHUB_WORKSPACE/v8js/DEBIAN/control")" | |
echo "v8Version=$v8Version" >> $GITHUB_OUTPUT | |
echo "arch=$arch" >> $GITHUB_OUTPUT | |
- name: build debian package | |
run: | | |
v8Version=${{ steps.definingV8Version.outputs.v8Version }} | |
arch=${{ steps.definingV8Version.outputs.arch }} | |
# добавить версию пакета | |
echo "Version: $v8Version" >> "$GITHUB_WORKSPACE/v8js/DEBIAN/control" | |
dpkg-deb --build v8js | |
mv v8js.deb v8js.$v8Version.$arch.deb | |
- name: upload artifacts to release | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
v8Version=${{ steps.definingV8Version.outputs.v8Version }} | |
arch=${{ steps.definingV8Version.outputs.arch }} | |
# скачать список тегов | |
git fetch --tags origin | |
revlist="$(git rev-list --tags --max-count=1)" | |
# взять последний тег | |
if [[ -z "$revlist" || $(git describe --tags $revlist | grep -o '[0-9]*\.[0-9]*') != "$v8Version" ]]; then | |
latestVersion="v$v8Version-0" | |
else | |
latestVersion="$(git describe --tags "$revlist")" | |
fi | |
# вычислить новый тег | |
latestVersionPrefix="$(awk -F'-' '{ $NF=""; print }' <<< "$latestVersion" | tr " " "-")" | |
latestMinorVersion="$(sed "s/$latestVersionPrefix//g" <<< "$latestVersion")" | |
newMinorVersion=$(( $latestMinorVersion + 1 )) | |
newVersion="$latestVersionPrefix$newMinorVersion" | |
# выпустить релиз с указанными ресурсами (assets) | |
gh release create "$newVersion" ./v8js.$v8Version.$arch.deb |