Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
bytecodealliance
GitHub Repository: bytecodealliance/wasmtime
Path: blob/main/ci/build-tarballs.sh
1685 views
1
#!/bin/bash
2
3
# A small script used for assembling release tarballs for both the `wasmtime`
4
# binary and the C API. This is executed with two arguments, mostly coming
5
# from the CI matrix.
6
#
7
# * The first argument is the name of the "build", used to name the release.
8
# * The second argument is the Rust target that the build was performed for.
9
#
10
# This expects the build to already be done and will assemble release artifacts
11
# in `dist/`
12
13
set -ex
14
15
build=$1
16
target=$2
17
18
rm -rf tmp
19
mkdir tmp
20
mkdir -p dist
21
22
tag=dev
23
if [[ $GITHUB_REF == refs/heads/release-* ]]; then
24
tag=v$(./ci/print-current-version.sh)
25
fi
26
27
# For *-min builds produce the same named artifacts as the normal build and
28
# they'll get unioned together in a later step in the CI.
29
build_pkgname=$build
30
if [[ $build == *-min ]]; then
31
build_pkgname=${build%-min}
32
fi
33
34
bin_pkgname=wasmtime-$tag-$build_pkgname
35
api_pkgname=wasmtime-$tag-$build_pkgname-c-api
36
37
api_install=target/c-api-install
38
mkdir tmp/$api_pkgname
39
mkdir tmp/$bin_pkgname
40
cp LICENSE README.md tmp/$api_pkgname
41
cp LICENSE README.md tmp/$bin_pkgname
42
43
# For *-min builds rename artifacts with a `-min` suffix to avoid eventual
44
# clashes with the normal builds when the tarballs are unioned together.
45
if [[ $build == *-min ]]; then
46
min="-min"
47
mkdir tmp/$api_pkgname/min
48
cp -r $api_install/include tmp/$api_pkgname/min
49
cp -r $api_install/lib tmp/$api_pkgname/min
50
else
51
cp -r $api_install/include tmp/$api_pkgname
52
cp -r $api_install/lib tmp/$api_pkgname
53
fi
54
55
56
fmt=tar
57
58
case $build in
59
x86_64-windows*)
60
cp target/$target/release/wasmtime.exe tmp/$bin_pkgname/wasmtime$min.exe
61
fmt=zip
62
63
if [ "$min" = "" ]; then
64
# Generate a `*.msi` installer for Windows as well
65
export WT_VERSION=`cat Cargo.toml | sed -n 's/^version = "\([^"]*\)".*/\1/p'`
66
"$WIX/bin/candle" -arch x64 -out target/wasmtime.wixobj ci/wasmtime.wxs
67
"$WIX/bin/light" -out dist/$bin_pkgname.msi target/wasmtime.wixobj -ext WixUtilExtension
68
rm dist/$bin_pkgname.wixpdb
69
fi
70
;;
71
72
# Skip the MSI for non-x86_64 builds of Windows
73
x86_64-mingw* | *-windows*)
74
cp target/$target/release/wasmtime.exe tmp/$bin_pkgname/wasmtime$min.exe
75
fmt=zip
76
;;
77
78
*-macos*)
79
cp target/$target/release/wasmtime tmp/$bin_pkgname/wasmtime$min
80
;;
81
82
*)
83
cp target/$target/release/wasmtime tmp/$bin_pkgname/wasmtime$min
84
;;
85
esac
86
87
88
mktarball() {
89
dir=$1
90
if [ "$fmt" = "tar" ]; then
91
tar -czvf dist/$dir.tar.gz -C tmp $dir
92
else
93
# Note that this runs on Windows, and it looks like GitHub Actions doesn't
94
# have a `zip` tool there, so we use something else
95
(cd tmp && 7z a ../dist/$dir.zip $dir/)
96
fi
97
}
98
99
mktarball $api_pkgname
100
mktarball $bin_pkgname
101
102