This repository has been archived by the owner on Jun 1, 2023. It is now read-only.
forked from 6get-xiaofan/WonderLab
-
Notifications
You must be signed in to change notification settings - Fork 1
/
autoMake
executable file
·96 lines (75 loc) · 2.03 KB
/
autoMake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#!/usr/bin/env bash
set -e
function log()
{
echo "[$(date "+%Y-%m-%d %H:%M:%S")] $*"
}
function die()
{
local _retValue="${1:-1}"
local _msg="${2:-未知原因}"
log "已退出:${_msg}"
exit "${_retValue}"
}
if [ ! -f "${PWD}/autoMake" ]; then
die 114 "请在项目根目录下运行!并使用./autoMake运行。"
fi
readonly DEBUG="${DEBUG:-false}"
readonly SINGLEFILE="${SINGLEFILE:-true}"
BUILDTYPE="Unknown"
if [ "${DEBUG}" == "true" ]; then
BUILDTYPE="Debug"
else
BUILDTYPE="Release"
fi
readonly BUILDTYPE
if [ $# -ge 2 ]; then
Ver=$2
else
Ver=1.0.0
fi
readonly ROOTDIR="${PWD}"
readonly BINDIR="${ROOTDIR}/WonderLab/bin/${BUILDTYPE}/net6.0"
function build()
{
log "开始编译"
cd "${ROOTDIR}" || die 2 "无法变更目录到 ${ROOTDIR}"
dotnet build -c "${BUILDTYPE}"
dotnet deb install
dotnet rpm install
log "编译结束"
}
function package()
{
log "开始打包"
cd "${ROOTDIR}" || die 2 "无法变更目录到 ${ROOTDIR}"
# 初始化输出目录
local _finalDir="${ROOTDIR}/bin"
rm -rf "${_finalDir}"
mkdir -vp "${_finalDir}"
local _targetRuntime="linux-x64"
dotnet publish WonderLab -c Release -r "${_targetRuntime}" \
--self-contained true \
-p:PublishSingleFile="${SINGLEFILE}" \
-p:PublishReadyToRun=true \
-t:CreateDeb -t:CreateRpm
local _publishDir="${BINDIR}/${_targetRuntime}/publish"
# 移动deb和rpm包到输出目录中
local _archiveName="${BINDIR}/${_targetRuntime}/WonderLab.$Ver.${_targetRuntime}"
mv "${_archiveName}.deb" "${_finalDir}/linux-x86_64.deb"
mv "${_archiveName}.rpm" "${_finalDir}/linux-x86_64.rpm"
cd "${_publishDir}" || die 2 "无法变更目录到 ${_publishDir}"
tar -zcvf "${_finalDir}/linux-x86_64.tar.gz" ./*
log "打包完成!在bin目录下!"
exit 0
}
if [ "$1" == "build" ]; then
build
elif [ "$1" == "package" ]; then
package
else
log "帮助:"
log "build 只编译软件"
log "package 打包软件"
exit 1919
fi