forked from fuse-open/uno
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pack.sh
executable file
·86 lines (69 loc) · 2.81 KB
/
pack.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
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
SELF=`echo $0 | sed 's/\\\\/\\//g'`
cd "`dirname "$SELF"`/.." || exit 1
source scripts/common.sh
# Initialize
DST="release"
shopt -s dotglob
rm -rf ${DST:?}/* 2> /dev/null || :
mkdir -p $DST
# Detect version info
VERSION=`cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
BUILD_NUMBER="0"
SUFFIX="dev"
COMMIT="N/A"
if [ -n "$APPVEYOR" ]; then
BUILD_NUMBER=$APPVEYOR_BUILD_NUMBER
COMMIT=$APPVEYOR_REPO_COMMIT
# Drop prerelease-suffix on tagged commits (official releases),
# or set canary-suffix when building the master-branch,
# or set rc-suffix when building a release-branch.
if [ -n "$APPVEYOR_REPO_TAG_NAME" ]; then
SUFFIX=""
elif [ "$APPVEYOR_REPO_BRANCH" = master ]; then
SUFFIX="canary"
elif [ "$APPVEYOR_REPO_BRANCH" = release-* ]; then
SUFFIX="rc"
fi
elif [ -d .git ]; then
# Get commit SHA from local git-repo.
COMMIT=`git rev-parse HEAD 2> /dev/null || :`
fi
if [ -n "$SUFFIX" ]; then
VERSION="$VERSION-$SUFFIX"
fi
echo "Version: $VERSION (build $BUILD_NUMBER)"
echo "Commit: $COMMIT"
# Extract the X.Y.Z part of version, removing the suffix if any
VERSION_TRIPLET=`echo $VERSION | sed -n -e 's/\([^-]*\).*/\1/p'`
# Create GlobalAssemblyInfo.Override.cs
sed -e 's/\(AssemblyVersion("\)[^"]*\(")\)/\1'$VERSION_TRIPLET.$BUILD_NUMBER'\2/' \
-e 's/\(AssemblyFileVersion("\)[^"]*\(")\)/\1'$VERSION_TRIPLET.$BUILD_NUMBER'\2/' \
-e 's/\(AssemblyInformationalVersion("\)[^"]*\(")\)/\1'$VERSION'\2/' \
-e 's/\(AssemblyConfiguration("\)[^"]*\(")\)/\1'$COMMIT'\2/' \
src/GlobalAssemblyInfo.cs > src/GlobalAssemblyInfo.Override.cs
# Trigger release builds
h1 "Installing packages"
nuget restore uno.sln
h1 "Building platform tools"
CONFIGURATION=Release csharp-build uno.sln
h1 "Building core library"
uno doctor --configuration=Release --version=$VERSION lib
# Remove GlobalAssemblyInfo.Override.cs
rm -f src/GlobalAssemblyInfo.Override.cs
h1 "Preparing release"
######################
# Copy assemblies
cp src/main/Uno.CLI.Main/bin/Release/*.{dll,exe,dylib} $DST
cp -f src/testing/Uno.CompilerTestRunner/bin/Release/uno-compiler-test.exe $DST
cp -f src/testing/Uno.TestGenerator/bin/Release/uno-test-gen.exe $DST
cp -f src/testing/Uno.TestRunner.CLI/bin/Release/*.{dll,exe} $DST
# Put app loaders for macOS and Windows in subdirectories to avoid conflicts
mkdir -p $DST/apploader-mac
cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/*.{dll,exe,dylib} $DST/apploader-mac
cp -f src/runtime/Uno.AppLoader-MonoMac/bin/Release/monostub $DST/apploader-mac
mkdir -p $DST/apploader-win
cp -f src/runtime/Uno.AppLoader-WinForms/bin/Release/*.{dll,exe} $DST/apploader-win
# Generate config file
cp config/pack.unoconfig $DST/.unoconfig
echo "Packages.SearchPaths += ../lib/build" >> $DST/.unoconfig