-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sh
executable file
·76 lines (58 loc) · 2.53 KB
/
build.sh
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
#!/bin/bash
## uncomment line below if you want target netf ASF version
build_netf=1
################################################################################
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:$HOME/bin
export PATH
################################################################################
_PROGN_=`basename $0`
_INSTDIR_=`dirname $0`
[[ $_INSTDIR_ = . ]] && _INSTDIR_=`pwd`
################################################################################
## getting current directory name from '$_INSTDIR_' variable
plugin_name=$(echo $_INSTDIR_ | sed 's|.*/||')
# download submodule
if [[ ! -d ArchiSteamFarm/ArchiSteamFarm ]]; then
git submodule update --init
fi
if [[ $# -gt 1 ]]; then
echo "Too many arguments. Exiting."
exit 1
elif [[ $# -eq 1 ]]; then
## update submodule to required tag as specified in '$1'
git submodule foreach "git fetch origin; git checkout $1;"
else
## otherwise update submodule to latest tag
git submodule foreach "git fetch origin; git checkout $(git rev-list --tags --max-count=1);"
fi
## print what version we are building for
git submodule foreach "git describe --tags;"
if [[ -d ./out ]]; then
rm -rf ./out
fi
## hacks to allow building netf
if [[ $build_netf -eq 1 ]]; then
sed -i 's|<ItemGroup>|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net6.0'\''"><!--hacks-->|' $plugin_name/$plugin_name.csproj
fi
## release generic version
dotnet restore
sync
dotnet publish -c "Release" -f net6.0 -o "out/generic" "/p:LinkDuringPublish=false"
mkdir ./out/$plugin_name
cp ./out/generic/$plugin_name.dll ./out/$plugin_name
7z a -tzip -mx7 ./out/$plugin_name.zip ./out/$plugin_name
rm -rf out/$plugin_name
## hacks to allow building netf
if [[ $build_netf -eq 1 ]]; then
sed -i 's|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net6.0'\''"><!--hacks-->|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net48'\''"><!--hacks-->|' $plugin_name/$plugin_name.csproj
fi
## release generic-netf version
if [[ $build_netf -eq 1 ]]; then
dotnet msbuild /m /r /t:Publish /p:Configuration=Release /p:TargetFramework=net48 /p:PublishDir=out/generic-netf /p:ASFNetFramework=true
mkdir ./out/$plugin_name
cp ./$plugin_name/out/generic-netf/$plugin_name.dll ./out/$plugin_name
7z a -tzip -mx7 ./out/$plugin_name-netf.zip ./out/$plugin_name
rm -rf out/$plugin_name
## hacks to allow building netf
sed -i 's|<ItemGroup Condition="'\''$(TargetFramework)'\'' == '\''net48'\''"><!--hacks-->|<ItemGroup>|' $plugin_name/$plugin_name.csproj
fi