@@ -3,32 +3,57 @@ set -ev
3
3
4
4
TAG=$1
5
5
NUGET_API_KEY=$2
6
- VERSION=` echo ${TAG} | cut -b 2-`
6
+ VERSION=$( echo ${TAG} | cut -b 2-)
7
7
8
- src_path=src
9
- contract_path=contract
10
- build_output=/tmp/aelf-build
8
+ # Define paths and directories
9
+ src_path=" src"
10
+ contract_path=" contract"
11
+ build_output=" /tmp/aelf-build"
11
12
13
+ # Clean up the temporary build directory if it exists
12
14
if [[ -d ${build_output} ]]; then
13
15
rm -rf ${build_output}
14
16
fi
15
17
18
+ # Restore project dependencies
16
19
dotnet restore AElf.All.sln
17
20
18
- for path in ${src_path} ${contract_path} ;
19
- do
21
+ # ---- Phase 1: Build all projects ----
22
+ echo " === Starting build phase ==="
23
+ for path in ${src_path} ${contract_path} ; do
20
24
cd ${path}
21
- echo ' ---- build ' ${path}
22
-
23
- for name in ` ls -lh | grep ^d | grep AElf | grep -v Tests | awk ' {print $NF}' ` ;
24
- do
25
- if [[ -f ${name} /${name} .csproj ]] && [[ 1 -eq $( grep -c " GeneratePackageOnBuild" ${name} /${name} .csproj) ]]; then
26
- echo ${name} /${name} .csproj
27
- dotnet build ${name} /${name} .csproj /clp:ErrorsOnly --configuration Release -P:Version=${VERSION} -P:Authors=AElf -o ${build_output}
25
+ echo " ---- Building projects in path: ${path} ----"
26
+ for name in $( ls -lh | grep ^d | grep AElf | grep -v Tests | awk ' {print $NF}' ) ; do
27
+ # Check if the project has a .csproj file and if it is configured to generate NuGet packages
28
+ if [[ -f ${name} /${name} .csproj ]] && [[ $( grep -c " GeneratePackageOnBuild" ${name} /${name} .csproj) -eq 1 ]]; then
29
+ echo " Building project: ${name} /${name} .csproj"
30
+ dotnet build ${name} /${name} .csproj --configuration Release \
31
+ -P:Version=${VERSION} -P:Authors=AElf -o ${build_output} /clp:ErrorsOnly
32
+ fi
33
+ done
34
+ cd ../
35
+ done
28
36
29
- echo ` ls ${build_output} /${name} .${VERSION} .nupkg`
30
- dotnet nuget push ${build_output} /${name} .${VERSION} .nupkg -k ${NUGET_API_KEY} -s https://api.nuget.org/v3/index.json --skip-duplicate
37
+ # ---- Phase 2: Push NuGet packages ----
38
+ echo " === Starting push phase ==="
39
+ for path in ${src_path} ${contract_path} ; do
40
+ cd ${path}
41
+ echo " ---- Pushing NuGet packages in path: ${path} ----"
42
+ for name in $( ls -lh | grep ^d | grep AElf | grep -v Tests | awk ' {print $NF}' ) ; do
43
+ # Check if the .nupkg file exists and push it to NuGet if it does
44
+ if [[ -f ${name} /${name} .csproj ]] && [[ $( grep -c " GeneratePackageOnBuild" ${name} /${name} .csproj) -eq 1 ]]; then
45
+ PACKAGE_PATH=" ${build_output} /${name} .${VERSION} .nupkg"
46
+ if [[ -f ${PACKAGE_PATH} ]]; then
47
+ echo " Pushing package: ${PACKAGE_PATH} "
48
+ dotnet nuget push ${PACKAGE_PATH} -k ${NUGET_API_KEY} \
49
+ -s https://api.nuget.org/v3/index.json --skip-duplicate
50
+ else
51
+ echo " Error: Package not found at ${PACKAGE_PATH} "
52
+ exit 1
53
+ fi
31
54
fi
32
55
done
33
56
cd ../
34
- done
57
+ done
58
+
59
+ echo " === All tasks completed successfully! ==="
0 commit comments