-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease.sh
executable file
·202 lines (166 loc) · 5.67 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/bin/bash
PROJECT_NAME=cesium
REPO="duniter/cesium"
REPO_PUBLIC_URL="https://github.com/${REPO}"
NODEJS_VERSION=18
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.7.12"
echo ""
exit 1
fi
# Override with a local file, if any
if [[ -f "${ROOT}/.local/env.sh" ]]; then
echo "Loading environment variables from: '.local/env.sh'"
source ${ROOT}/.local/env.sh
[[ $? -ne 0 ]] && exit 1
else
echo "No file '${ROOT}/.local/env.sh' found. Will use defaults"
fi
# Force nodejs version
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 -q "${REPO_PUBLIC_URL}/releases/download/${REMOTE_TAG}/${ZIP_BASENAME}.zip" || exit 2
cd ${ROOT}
fi
if [[ "_$EXPECTED_ASSETS" == "_" ]]; then
EXPECTED_ASSETS="${PROJECT_NAME}-desktop-$REMOTE_TAG-linux-x64.tar.gz
${PROJECT_NAME}-desktop-$REMOTE_TAG-linux-x64.deb
${PROJECT_NAME}-desktop-$REMOTE_TAG-linux-x64.AppImage
${PROJECT_NAME}-desktop-$REMOTE_TAG-windows-x64.exe"
fi
# Remove old vagrant virtual machines
echo "Removing old Vagrant VM... TODO: optimize this !"
rm -rf ~/.vagrant.d/*
#echo "Assets: $EXPECTED_ASSETS"
for ASSET_BASENAME in $EXPECTED_ASSETS; do
echo ""
echo "--- Checking if asset '$ASSET_BASENAME' exists on GitHub..."
if [[ -z `echo $ASSETS | grep -F "$ASSET_BASENAME"` ]]; then
# Debian
if [[ $ASSET_BASENAME == *"linux-x64."* ]]; then
if [[ $ARCH == "x86_64" ]]; then
ASSET_PATH="$PWD/arch/linux/$ASSET_BASENAME"
# Build
if [[ ! -f "${ASSET_PATH}" ]]; then
echo "--- Building '${ASSET_BASENAME}'..."
./scripts/build.sh make linux $TAG
[[ $? -eq 0 ]] && echo "--- Building '${ASSET_BASENAME}' [OK]"
fi
# Upload asset
if [[ -f "${ASSET_PATH}" ]]; then
echo ""
echo "--- Uploading '${ASSET_BASENAME}' to github ..."
node ./scripts/upload-release.js ${REMOTE_TAG} ${ASSET_PATH}
fi
# Upload sha256 (if exists)
if [[ -f "${ASSET_PATH}.sha256" ]]; then
echo "--- Uploading '${ASSET_BASENAME}.sha256' to github ..."
node ./scripts/upload-release.js ${REMOTE_TAG} ${ASSET_PATH}.sha256
fi
else
echo "This computer cannot build this asset, required architecture is 'x86_64'. Skipping."
fi
fi
# Windows
if [[ $ASSET_BASENAME == *".exe" ]]; then
if [[ $ARCH == "x86_64" ]]; then
ASSET_PATH="$PWD/arch/windows/$ASSET_BASENAME"
# Build
if [[ ! -f "${ASSET_PATH}" ]]; then
echo "--- Building '${ASSET_BASENAME}'..."
./scripts/build.sh make win $TAG
[[ $? -eq 0 ]] && echo "--- Building '${ASSET_BASENAME}' [OK]"
fi
# Upload asset
if [[ -f "${ASSET_PATH}" ]]; then
echo ""
echo "--- Uploading '${ASSET_BASENAME}' to github ..."
node ./scripts/upload-release.js ${REMOTE_TAG} ${ASSET_PATH}
fi
# Upload sha256 (if exists)
if [[ -f "${ASSET_PATH}.sha256" ]]; then
node ./scripts/upload-release.js ${REMOTE_TAG} ${ASSET_PATH}.sha256
fi
else
echo "This computer cannot build this asset, required architecture is 'x86_64'. Skipping."
fi
fi
# OSX
if [[ $ASSET_BASENAME == *"osx-x64.zip" ]]; then
if [[ $ARCH == "x86_64" ]]; then
ASSET_PATH="$PWD/arch/osx/$ASSET_BASENAME"
# Build
if [[ ! -f "${ASSET_PATH}" ]]; then
echo "--- Building '${ASSET_BASENAME}'..."
./scripts/build.sh make osx $TAG
[[ $? -eq 0 ]] && echo "--- Building '${ASSET_BASENAME}' [OK]"
fi
# Upload asset
if [[ -f "${ASSET_PATH}" ]]; then
echo ""
echo "--- Uploading '${ASSET_BASENAME}' to github ..."
node ./scripts/upload-release.js ${REMOTE_TAG} ${ASSET_PATH}
fi
# Upload sha256 (if exists)
if [[ -f "${ASSET_PATH}.sha256" ]]; then
node ./scripts/upload-release.js ${REMOTE_TAG} ${ASSET_PATH}.sha256
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/cesium-*-web.zip
rmdir --ignore-fail-on-non-empty downloads
echo "--- All assets have been uploaded."
fi
fi