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'
required: false
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:
matrix:
platform: [ windows-2022, ubuntu-18.04 ]
arch: [ x64 ]
build_type: [ Release ]
qt_version: [ 5.15.2 ]
include:
- platform: windows-2022
@@ -66,11 +89,6 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y ninja-build
- name: Install Golang
uses: actions/setup-go@v2
with:
stable: false
go-version: 1.18.5
# ========================================================================================================= 编译与 Qt 无关的依赖
- name: Cache Download
id: cache-deps
@@ -93,9 +111,7 @@ jobs:
run: |
mkdir build
cd build
cmake .. -GNinja \
-DCMAKE_PREFIX_PATH=./libs/deps/built \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --parallel $(nproc)
cd ..
./libs/deploy_windows64.sh
@@ -105,26 +121,34 @@ jobs:
run: |
mkdir build
cd build
cmake .. -GNinja \
-DCMAKE_PREFIX_PATH=./libs/deps/built \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
cmake -GNinja -DCMAKE_BUILD_TYPE=Release ..
cmake --build . --parallel $(nproc)
cd ..
./libs/deploy_linux64.sh
# ========================================================================================================= Deployments
- name: Tar files
shell: bash
run: tar czvf artifacts.tgz ./deployment
- name: Uploading Artifact
uses: actions/upload-artifact@master
with:
name: NekoRay-${{ github.sha }}-${{ matrix.platform }}-${{ matrix.arch }}
path: ./deployment/
path: artifacts.tgz
publish:
name: Publish Release
if: github.event.inputs.publish != 'y'
runs-on: ubuntu-latest
needs: build
needs:
- build-cpp
- build-go
steps:
- name: Checkout
- name: Checking out sources
uses: actions/checkout@v2
- name: Donwload Artifacts
uses: actions/download-artifact@v2
with:
name: NekoRay-${{ github.sha }}-Common
path: artifacts-common
- name: Donwload Artifacts
uses: actions/download-artifact@v2
with:
@@ -137,10 +161,21 @@ jobs:
path: artifacts-windows
- name: Release
run: |
wget -O ghr.tar.gz https://github.com/tcnksm/ghr/releases/download/v0.13.0/ghr_v0.13.0_linux_amd64.tar.gz
tar -xvf ghr.tar.gz
source libs/deploy_common.sh
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 .
mkdir apks
find artifacts-linux -name "*.tar.gz" -exec cp {} apks \;
find artifacts-windows -name "*.zip" -exec cp {} apks \;
./ghr -delete -t "${{ github.token }}" -n "${{ github.event.inputs.tag }}" "${{ github.event.inputs.tag }}" apks
tar xzvf artifacts-linux/artifacts.tgz
tar xzvf artifacts-windows/artifacts.tgz
tar xzvf artifacts-common/artifacts.tgz
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
include("cmake/fuck_windows/fuck.cmake")
# My dependencies
include("cmake/print.cmake")
set(MY_DEPS_DIR "${CMAKE_SOURCE_DIR}/libs/deps/built")
list(APPEND CMAKE_PREFIX_PATH ${MY_DEPS_DIR})
# default prefix path
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/libs/deps/built)
message("[CMAKE_PREFIX_PATH] ${CMAKE_PREFIX_PATH}")
# for some cross toolchain
list(APPEND CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH})
message("[CMAKE_FIND_ROOT_PATH] ${CMAKE_FIND_ROOT_PATH}")
# NKR
include("cmake/print.cmake")
include("cmake/nkr.cmake")
find_package(Threads)
@@ -64,6 +68,7 @@ else ()
# QHotkey (static submodule)
set(QHOTKEY_INSTALL OFF)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(3rdparty/QHotkey)
list(APPEND NKR_EXTERNAL_TARGETS qhotkey)
endif ()

View File

@@ -1,5 +1,6 @@
if (WIN32)
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)
generate_product_version(
@@ -21,7 +22,6 @@ if (WIN32)
add_compile_options("/utf-8")
add_compile_options("/std:c++17")
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)
endif ()
endif ()

View File

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

2
libs/.gitignore vendored
View File

@@ -1,2 +1,2 @@
deps
/deps*
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"
DEST="$PWD/deployment/nekoray"
DEPLOYMENT="$SRC_ROOT/deployment"
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)
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
source libs/deploy_common.sh
#### updater to launcher ####
mv $DEST/updater $DEST/launcher
DEST=$DEPLOYMENT/linux64
rm -rf $DEST
mkdir -p $DEST
#### copy binary ####
cp $BUILD/nekoray $DEST
@@ -12,13 +12,5 @@ cp $BUILD/nekoray $DEST
#### Download: prebuilt runtime ####
curl -Lso usr.zip https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/20220503/20220705-5.15.2-linux64.zip
unzip usr.zip
rm usr.zip
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
source libs/deploy_common.sh
#### Go: sing-box ####
pushd $BUILD
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
DEST=$DEPLOYMENT/windows64
rm -rf $DEST
mkdir -p $DEST
#### copy exe ####
cp $BUILD/nekoray.exe $DEST
@@ -23,7 +17,5 @@ curl -LSsO https://github.com/MatsuriDayo/nekoray_qt_runtime/releases/download/2
rm -rf translations
popd
#### pack zip ####
7z a $SRC_ROOT/deployment/$version_standalone-windows64.zip $DEST
cp $BUILD/*.pdb $SRC_ROOT/deployment/
rm -rf $DEST $BUILD
#### prepare deployment ####
cp $BUILD/*.pdb $DEPLOYMENT

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"
#ifdef Q_OS_WIN
//
#include <Windows.h>
#include <windows.h>
//
#include <WinInet.h>
#include <wininet.h>
#include <ras.h>
#include <raserror.h>
#include <vector>
@@ -480,5 +478,3 @@ namespace Qv2ray::components::proxy {
#endif
}
} // namespace Qv2ray::components::proxy
#endif