update build script

This commit is contained in:
arm64v8a
2022-08-08 11:07:29 +08:00
parent fac593b803
commit 8031c68038
13 changed files with 163 additions and 104 deletions

View File

@@ -10,12 +10,35 @@ on:
description: 'Publish: If want ignore' description: 'Publish: If want ignore'
required: false required: false
jobs: jobs:
build: build-go:
runs-on: ubuntu-latest
steps:
- name: Checking out sources
uses: actions/checkout@v2
- name: Install Golang
uses: actions/setup-go@v2
with:
stable: false
go-version: 1.18.5
- name: Build golang and common parts
shell: bash
run: |
./libs/get_source.sh
GOOS=linux GOARCH=amd64 ./libs/build_go.sh
GOOS=windows GOARCH=amd64 ./libs/build_go.sh
./libs/build_asset.sh
- name: Tar files
run: tar czvf artifacts.tgz ./deployment
- name: Uploading Artifact
uses: actions/upload-artifact@master
with:
name: NekoRay-${{ github.sha }}-Common
path: artifacts.tgz
build-cpp:
strategy: strategy:
matrix: matrix:
platform: [ windows-2022, ubuntu-18.04 ] platform: [ windows-2022, ubuntu-18.04 ]
arch: [ x64 ] arch: [ x64 ]
build_type: [ Release ]
qt_version: [ 5.15.2 ] qt_version: [ 5.15.2 ]
include: include:
- platform: windows-2022 - platform: windows-2022
@@ -66,11 +89,6 @@ jobs:
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y ninja-build sudo apt-get install -y ninja-build
- name: Install Golang
uses: actions/setup-go@v2
with:
stable: false
go-version: 1.18.5
# ========================================================================================================= 编译与 Qt 无关的依赖 # ========================================================================================================= 编译与 Qt 无关的依赖
- name: Cache Download - name: Cache Download
id: cache-deps id: cache-deps
@@ -93,9 +111,7 @@ jobs:
run: | run: |
mkdir build mkdir build
cd build cd build
cmake .. -GNinja \ cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..
-DCMAKE_PREFIX_PATH=./libs/deps/built \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build . --parallel $(nproc) cmake --build . --parallel $(nproc)
cd .. cd ..
./libs/deploy_windows64.sh ./libs/deploy_windows64.sh
@@ -105,26 +121,34 @@ jobs:
run: | run: |
mkdir build mkdir build
cd build cd build
cmake .. -GNinja \ cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..
-DCMAKE_PREFIX_PATH=./libs/deps/built \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake --build . --parallel $(nproc) cmake --build . --parallel $(nproc)
cd .. cd ..
./libs/deploy_linux64.sh ./libs/deploy_linux64.sh
# ========================================================================================================= Deployments # ========================================================================================================= Deployments
- name: Tar files
shell: bash
run: tar czvf artifacts.tgz ./deployment
- name: Uploading Artifact - name: Uploading Artifact
uses: actions/upload-artifact@master uses: actions/upload-artifact@master
with: with:
name: NekoRay-${{ github.sha }}-${{ matrix.platform }}-${{ matrix.arch }} name: NekoRay-${{ github.sha }}-${{ matrix.platform }}-${{ matrix.arch }}
path: ./deployment/ path: artifacts.tgz
publish: publish:
name: Publish Release name: Publish Release
if: github.event.inputs.publish != 'y' if: github.event.inputs.publish != 'y'
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build needs:
- build-cpp
- build-go
steps: steps:
- name: Checkout - name: Checking out sources
uses: actions/checkout@v2 uses: actions/checkout@v2
- name: Donwload Artifacts
uses: actions/download-artifact@v2
with:
name: NekoRay-${{ github.sha }}-Common
path: artifacts-common
- name: Donwload Artifacts - name: Donwload Artifacts
uses: actions/download-artifact@v2 uses: actions/download-artifact@v2
with: with:
@@ -137,10 +161,21 @@ jobs:
path: artifacts-windows path: artifacts-windows
- name: Release - name: Release
run: | run: |
wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz source libs/deploy_common.sh
tar -xvf ghr.tar.gz curl -Lo - https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz | tar xzv
mv ghr*linux_amd64/ghr . mv ghr*linux_amd64/ghr .
mkdir apks tar xzvf artifacts-linux/artifacts.tgz
find artifacts-linux -name "*.tar.gz" -exec cp {} apks \; tar xzvf artifacts-windows/artifacts.tgz
find artifacts-windows -name "*.zip" -exec cp {} apks \; tar xzvf artifacts-common/artifacts.tgz
./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks cd deployment
cp -r assets/* linux64
cp -r assets/* windows64
rm -rf assets
mv linux64 nekoray
zip -r $version_standalone-linux64.zip nekoray
rm -rf nekoray
mv windows64 nekoray
zip -r $version_standalone-windows64.zip nekoray
rm -rf nekoray
cd ..
./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" deployment

View File

@@ -33,12 +33,16 @@ endif ()
# Windows # Windows
include("cmake/fuck_windows/fuck.cmake") include("cmake/fuck_windows/fuck.cmake")
# My dependencies # default prefix path
include("cmake/print.cmake") list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/libs/deps/built)
set(MY_DEPS_DIR "${CMAKE_SOURCE_DIR}/libs/deps/built") message("[CMAKE_PREFIX_PATH] ${CMAKE_PREFIX_PATH}")
list(APPEND CMAKE_PREFIX_PATH ${MY_DEPS_DIR})
# for some cross toolchain
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH})
message("[CMAKE_FIND_ROOT_PATH] ${CMAKE_FIND_ROOT_PATH}")
# NKR # NKR
include("cmake/print.cmake")
include("cmake/nkr.cmake") include("cmake/nkr.cmake")
find_package(Threads) find_package(Threads)
@@ -64,6 +68,7 @@ else ()
# QHotkey (static submodule) # QHotkey (static submodule)
set(QHOTKEY_INSTALL OFF) set(QHOTKEY_INSTALL OFF)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(3rdparty/QHotkey) add_subdirectory(3rdparty/QHotkey)
list(APPEND NKR_EXTERNAL_TARGETS qhotkey) list(APPEND NKR_EXTERNAL_TARGETS qhotkey)
endif () endif ()

View File

@@ -1,5 +1,6 @@
if (WIN32) if (WIN32)
set(PLATFORM_FUCKING_SOURCES 3rdparty/WinCommander.cpp) set(PLATFORM_FUCKING_SOURCES 3rdparty/WinCommander.cpp)
set(PLATFORM_FUCKING_LIBRARIES wininet wsock32 ws2_32 user32 rasapi32 iphlpapi)
include(cmake/fuck_windows/generate_product_version.cmake) include(cmake/fuck_windows/generate_product_version.cmake)
generate_product_version( generate_product_version(
@@ -21,7 +22,6 @@ if (WIN32)
add_compile_options("/utf-8") add_compile_options("/utf-8")
add_compile_options("/std:c++17") add_compile_options("/std:c++17")
add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_WIN32_WINNT=0x600 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS)
set(PLATFORM_FUCKING_LIBRARIES wininet wsock32 ws2_32 user32 Rasapi32 Iphlpapi)
list(APPEND PLATFORM_FUCKING_SOURCES sys/windows/MiniDump.cpp) list(APPEND PLATFORM_FUCKING_SOURCES sys/windows/MiniDump.cpp)
endif () endif ()
endif () endif ()

View File

@@ -4,7 +4,7 @@ set(PROTO_FILES
go/gen/libcore.proto go/gen/libcore.proto
) )
add_library(myproto ${PROTO_FILES}) add_library(myproto STATIC ${PROTO_FILES})
target_link_libraries(myproto target_link_libraries(myproto
PUBLIC PUBLIC
protobuf::libprotobuf protobuf::libprotobuf

2
libs/.gitignore vendored
View File

@@ -1,2 +1,2 @@
deps /deps*
downloaded downloaded

14
libs/build_asset.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/bin/bash
set -e
source libs/deploy_common.sh
DEST=$DEPLOYMENT/assets
rm -rf $DEST
mkdir -p $DEST
#### Download: geoip ####
curl -Lso $DEST/geoip.dat "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/202206042210/geoip.dat"
curl -Lso $DEST/geosite.dat "https://github.com/v2fly/domain-list-community/releases/download/20220604062951/dlc.dat"
#### copy assets ####
cp assets/* $DEST

43
libs/build_go.sh Executable file
View File

@@ -0,0 +1,43 @@
#!/bin/bash
set -e
source libs/deploy_common.sh
[ "$GOOS" == "windows" ] && [ "$GOARCH" == "amd64" ] && DEST=$DEPLOYMENT/windows64 || true
[ "$GOOS" == "linux" ] && [ "$GOARCH" == "amd64" ] && DEST=$DEPLOYMENT/linux64 || true
if [ -z $DEST ]; then
echo "Please set GOOS GOARCH"
exit
fi
rm -rf $DEST
mkdir -p $DEST
export CGO_ENABLED=0
#### Go: updater ####
pushd updater
go build -o $DEST -trimpath -ldflags "-w -s"
[ "$GOOS" == "linux" ] && mv $DEST/updater $DEST/launcher
popd
#### Go: nekoray_core ####
pushd ../v2ray-core
version_v2ray=$(git log --pretty=format:'%h' -n 1)
popd
pushd go
go build -v -o $DEST -trimpath -ldflags "-w -s -X main.version_v2ray=$version_v2ray -X main.version_standalone=$version_standalone"
popd
#### Windows only ####
if [ "$GOOS" != "windows" ]; then
exit
fi
#### Go: sing-box ####
pushd $DEST
curl -Lso sing-box.zip https://github.com/SagerNet/sing-box/archive/64dbac813837bbadfaeec1a6e0d064875a123e5e.zip
unzip sing-box.zip
pushd sing-box-*/cmd/sing-box
go build -o $DEST -trimpath -ldflags "-w -s"
popd
rm -rf sing-box.zip sing-box-*
popd

View File

@@ -1,46 +1,5 @@
#### env ####
SRC_ROOT="$PWD" SRC_ROOT="$PWD"
DEST="$PWD/deployment/nekoray" DEPLOYMENT="$SRC_ROOT/deployment"
BUILD="$SRC_ROOT/build" BUILD="$SRC_ROOT/build"
mkdir -p $DEST
mkdir -p $BUILD
export CGO_ENABLED=0
#### Go: updater ####
pushd updater
go build -o $DEST -trimpath -ldflags "-w -s"
popd
#### libcore ####
COMMIT_M=$(cat matsuri_commit.txt)
COMMIT_V=$(cat core_commit.txt)
version_standalone="nekoray-"$(cat nekoray_version.txt) version_standalone="nekoray-"$(cat nekoray_version.txt)
pushd ..
git clone --no-checkout https://github.com/MatsuriDayo/Matsuri.git
git clone --no-checkout https://github.com/MatsuriDayo/v2ray-core.git
pushd Matsuri
git checkout $COMMIT_M
popd
pushd v2ray-core
git checkout $COMMIT_V
version_v2ray=$(git log --pretty=format:'%h' -n 1)
popd
popd
#### Go: nekoray_core ####
pushd go
go build -o $DEST -trimpath -ldflags "-w -s -X main.version_v2ray=$version_v2ray -X main.version_standalone=$version_standalone"
popd
#### Download: geoip ####
curl -Lso $DEST/geoip.dat "https://github.com/Loyalsoldier/v2ray-rules-dat/releases/download/202206042210/geoip.dat"
curl -Lso $DEST/geosite.dat "https://github.com/v2fly/domain-list-community/releases/download/20220604062951/dlc.dat"
#### copy assets ####
cp assets/* $DEST

View File

@@ -2,9 +2,9 @@
set -e set -e
source libs/deploy_common.sh source libs/deploy_common.sh
DEST=$DEPLOYMENT/linux64
#### updater to launcher #### rm -rf $DEST
mv $DEST/updater $DEST/launcher mkdir -p $DEST
#### copy binary #### #### copy binary ####
cp $BUILD/nekoray $DEST cp $BUILD/nekoray $DEST
@@ -12,13 +12,5 @@ cp $BUILD/nekoray $DEST
#### Download: prebuilt runtime #### #### Download: prebuilt runtime ####
curl -Lso usr.zip https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/20220503/20220705-5.15.2-linux64.zip curl -Lso usr.zip https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/20220503/20220705-5.15.2-linux64.zip
unzip usr.zip unzip usr.zip
rm usr.zip
mv usr $DEST mv usr $DEST
#### copy runtime ####
LIB=$SRC_ROOT/libs/deps/built/lib
#cp $LIB/libZXing.so.1 $DEST/usr/lib
#### pack tar ####
chmod +x $DEST/nekoray $DEST/nekoray_core $DEST/launcher
tar cvzf $SRC_ROOT/deployment/$version_standalone-linux64.tar.gz -C $SRC_ROOT/deployment nekoray
rm -rf $DEST $BUILD

View File

@@ -2,15 +2,9 @@
set -e set -e
source libs/deploy_common.sh source libs/deploy_common.sh
DEST=$DEPLOYMENT/windows64
#### Go: sing-box #### rm -rf $DEST
pushd $BUILD mkdir -p $DEST
curl -Lso sing-box.zip https://github.com/SagerNet/sing-box/archive/64dbac813837bbadfaeec1a6e0d064875a123e5e.zip
unzip sing-box.zip
pushd sing-box-*/cmd/sing-box
go build -o $DEST -trimpath -ldflags "-w -s"
popd
popd
#### copy exe #### #### copy exe ####
cp $BUILD/nekoray.exe $DEST cp $BUILD/nekoray.exe $DEST
@@ -23,7 +17,5 @@ curl -LSsO https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/2
rm -rf translations rm -rf translations
popd popd
#### pack zip #### #### prepare deployment ####
7z a $SRC_ROOT/deployment/$version_standalone-windows64.zip $DEST cp $BUILD/*.pdb $DEPLOYMENT
cp $BUILD/*.pdb $SRC_ROOT/deployment/
rm -rf $DEST $BUILD

23
libs/get_source.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
set -e
source libs/deploy_common.sh
#### get source ####
COMMIT_M=$(cat matsuri_commit.txt)
COMMIT_V=$(cat core_commit.txt)
pushd ..
git clone --no-checkout https://github.com/MatsuriDayo/Matsuri.git
git clone --no-checkout https://github.com/MatsuriDayo/v2ray-core.git
pushd Matsuri
git checkout $COMMIT_M
popd
pushd v2ray-core
git checkout $COMMIT_V
popd
popd

View File

@@ -1 +1 @@
3dd90ce8b7dcb7001f3de42f6bcc8edf0093353a 4fdd5842f61b467f1de777aea4d0b1c23f5feb2a

View File

@@ -1,12 +1,10 @@
#ifndef __MINGW32__
#include "QvProxyConfigurator.hpp" #include "QvProxyConfigurator.hpp"
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
// //
#include <Windows.h> #include <windows.h>
// //
#include <WinInet.h> #include <wininet.h>
#include <ras.h> #include <ras.h>
#include <raserror.h> #include <raserror.h>
#include <vector> #include <vector>
@@ -480,5 +478,3 @@ namespace Qv2ray::components::proxy {
#endif #endif
} }
} // namespace Qv2ray::components::proxy } // namespace Qv2ray::components::proxy
#endif