-
Notifications
You must be signed in to change notification settings - Fork 6
/
package.sh
executable file
·62 lines (55 loc) · 1.85 KB
/
package.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
#!/bin/bash
# THIS SCRIPT SHOULD BE INVOKED BY CI INSTEAD OF lal publish
# This is because lal intentionally uses semver.
# If you have done `lal build lal --release`
# It will convert the standard release structure of ARTIFACT:
#
# ARTIFACT/
# ├── lal.tar.gz
# └── lockfile.json
#
# And converts it into this folder structure:
#
# ARTIFACT/
# ├── 3.3.3
# │ └── lal.tar.gz
# ├── latest
# │ └── lal.tar.gz
# └── lockfile.json
#
# Such that jenkins will upload this verbatim to:
# http://engci-maven.cisco.com/artifactory/CME-release/lal/
# This is the canonical source of lal AT THE MOMENT
# It is also hardcoded in `lal upgrade` so this works.
# We cannot (and should never) `lal publish lal` because lal uses semver.
# We also would not want it accidentally introduced into the normal dependency tree.
#
# crates.io may become the canonical one in the future if it is open sourced.
mutate_artifact_folder() {
local -r lalversion=$(grep version Cargo.toml | awk -F"\"" '{print $2}' | head -n 1)
# Guard on version not existing
buildurl="http://engci-maven.cisco.com/artifactory/api/storage/CME-release/lal"
if curl -s "${buildurl}" | grep -q "$lalversion"; then
echo "lal version already uploaded - stopping" # don't want to overwrite
# don't want to upload anything accidentally - jenkins is dumb
rm -rf ARTIFACT/
else
echo "Packaging new lal version"
mkdir "ARTIFACT/${lalversion}" -p
mv ARTIFACT/lal.tar.gz "ARTIFACT/${lalversion}/lal.tar.gz"
# Overwrite the latest folder
cp "ARTIFACT/${lalversion}" "ARTIFACT/latest" -R
fi
}
main() {
set -e
if [ ! -f ARTIFACT/lal.tar.gz ]; then
echo "No release build of lal found"
rm -rf ARTIFACT # just in case
exit 2
fi
echo "Found release build with:"
tar tvf ARTIFACT/lal.tar.gz
mutate_artifact_folder
}
main "$@"