-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.sh
executable file
·165 lines (140 loc) · 4.46 KB
/
release.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
PROJECT_NAME=gchange
REPO="duniter-gchange/gchange-client"
REPO_PUBLIC_URL="https://github.com/${REPO}"
NODEJS_VERSION=10
TAG="$1"
TAG_NAME="v$1"
ARCH=`uname -m`
# Folders
ROOT=`pwd`
DOWNLOADS="$ROOT/downloads"
mkdir -p "$DOWNLOADS"
# Check that the tag exists remotely
if [[ -z $TAG ]]; then
echo "Wrong call to the command, syntax is:"
echo ""
echo " release.sh <tag>"
echo ""
echo "Examples:"
echo ""
echo " release.sh 1.2.3"
echo " release.sh 1.4.0"
echo " release.sh 1.4.1"
echo ""
exit 1
fi
# Force nodejs version to 10
if [[ -d "${NVM_DIR}" ]]; then
. ${NVM_DIR}/nvm.sh
nvm use ${NODEJS_VERSION}
if [[ $? -ne 0 ]]; then
nvm install ${NODEJS_VERSION}
if [[ $? -ne 0 ]]; then
exit 1;
fi
fi
else
echo "nvm (Node version manager) not found (directory NVM_DIR not defined). Please install nvm, and retry"
exit 1
fi
# install dep if not already done
if [[ ! -d "node_modules" ]]; then
yarn
fi
# Check that the tag exists remotely
echo "Checking that $TAG has been pushed to 'origin'..."
REMOTE_TAG=`node scripts/exists-tag.js "$TAG_NAME" | grep -Fo "$TAG_NAME"`
if [[ -z ${REMOTE_TAG} ]]; then
echo "The '$TAG' tag does not exist on 'origin' repository. Use command ./release.sh to create a new version and use 'git push origin --tags' to share the tag."
exit 2
fi
echo "Remote tag: $REMOTE_TAG"
echo "Creating the pre-release if it does not exist..."
ASSETS=`node ./scripts/create-release.js $REMOTE_TAG create`
# Downloading web assets (once)
ZIP_BASENAME="${PROJECT_NAME}-${REMOTE_TAG}-web"
if [[ ! -f "${DOWNLOADS}/${ZIP_BASENAME}.zip" ]]; then
echo "Downloading ${PROJECT_NAME} web release..."
mkdir -p ${DOWNLOADS} && cd ${DOWNLOADS} || exit 1
wget "${REPO_PUBLIC_URL}/releases/download/${REMOTE_TAG}/${ZIP_BASENAME}.zip" || exit 1
if [[ $? -ne 0 ]]; then
exit 2
fi
cd ${ROOT}
fi
if [[ "_$EXPECTED_ASSETS" == "_" ]]; then
EXPECTED_ASSETS="${PROJECT_NAME}-desktop-$REMOTE_TAG-linux-x64.deb
${PROJECT_NAME}-desktop-$REMOTE_TAG-linux-x64.tar.gz"
#${PROJECT_NAME}-desktop-$REMOTE_TAG-windows-x64.exe" # FIXME
fi
# Remove old vagrant virtual machines
echo "Removing old Vagrant VM... TODO: optimize this !"
rm -rf ~/.vagrant.d/*
echo "Assets: $EXPECTED_ASSETS"
for asset in $EXPECTED_ASSETS; do
if [[ -z `echo $ASSETS | grep -F "$asset"` ]]; then
echo "Missing asset: $asset"
# Debian
if [[ $asset == *"linux-x64.deb" ]] || [[ $asset == *"linux-x64.tar.gz" ]]; then
if [[ $ARCH == "x86_64" ]]; then
echo "Starting Debian build..."
./scripts/build.sh make linux $TAG
DEB_PATH="$PWD/arch/linux/$asset"
if [[ $? -eq 0 ]] && [[ -f "${DEB_PATH}" ]]; then
node ./scripts/upload-release.js ${REMOTE_TAG} ${DEB_PATH}
fi
else
echo "This computer cannot build this asset, required architecture is 'x86_64'. Skipping."
fi
fi
# Windows
if [[ $asset == *".exe" ]]; then
if [[ $ARCH == "x86_64" ]]; then
echo "Starting Windows build..."
./scripts/build.sh make win $TAG
WIN_PATH="$PWD/arch/windows/$asset"
if [[ -f "${WIN_PATH}" ]]; then
node ./scripts/upload-release.js ${REMOTE_TAG} ${WIN_PATH}
fi
else
echo "This computer cannot build this asset, required architecture is 'x86_64'. Skipping."
fi
fi
# OSX
if [[ $asset == *"osx-x64.zip" ]]; then
if [[ $ARCH == "x86_64" ]]; then
echo "Starting OSX build..."
./scripts/build.sh make osx $TAG
OSX_PATH="$PWD/arch/osx/$asset"
if [[ -f "${OSX_PATH}" ]]; then
node ./scripts/upload-release.js ${REMOTE_TAG} ${OSX_PATH}
fi
else
echo "This computer cannot build this asset, required architecture is 'x86_64'. Skipping."
fi
fi
# iOS
if [[ $asset == *"ios.zip" ]]; then
if [[ $ARCH == "x86_64" ]]; then
echo "Starting iOS build..."
./scripts/build.sh make ios $TAG
IOS_PATH="$PWD/arch/osx/$asset"
if [[ -f "${IOS_PATH}" ]]; then
node ./scripts/upload-release.js ${REMOTE_TAG} ${IOS_PATH}
fi
else
echo "This computer cannot build this asset, required architecture is 'x86_64'. Skipping."
fi
fi
fi
done
if [[ $? -eq 0 ]]; then
cd ${ROOT}
# Clean temporary files
if [[ $? -eq 0 ]]; then
#rm ${DOWNLOADS}/${ZIP_BASENAME}.zip
#rmdir downloads
echo "All the binaries have been uploaded."
fi
fi