File: build-tarballs.sh

package info (click to toggle)
rust-wasmtime 26.0.1%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 48,492 kB
  • sloc: ansic: 4,003; sh: 561; javascript: 542; cpp: 254; asm: 175; ml: 96; makefile: 55
file content (99 lines) | stat: -rwxr-xr-x 2,674 bytes parent folder | download
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
#!/bin/bash

# A small script used for assembling release tarballs for both the `wasmtime`
# binary and the C API. This is executed with two arguments, mostly coming
# from the CI matrix.
#
# * The first argument is the name of the "build", used to name the release.
# * The second argument is the Rust target that the build was performed for.
#
# This expects the build to already be done and will assemble release artifacts
# in `dist/`

set -ex

build=$1
target=$2

rm -rf tmp
mkdir tmp
mkdir -p dist

tag=dev
if [[ $GITHUB_REF == refs/heads/release-* ]]; then
  tag=v$(./ci/print-current-version.sh)
fi

# For *-min builds produce the same named artifacts as the normal build and
# they'll get unioned together in a later step in the CI.
build_pkgname=$build
if [[ $build == *-min ]]; then
  build_pkgname=${build%-min}
fi

bin_pkgname=wasmtime-$tag-$build_pkgname
api_pkgname=wasmtime-$tag-$build_pkgname-c-api

api_install=target/c-api-install
mkdir tmp/$api_pkgname
mkdir tmp/$bin_pkgname
cp LICENSE README.md tmp/$api_pkgname
cp LICENSE README.md tmp/$bin_pkgname

# For *-min builds rename artifacts with a `-min` suffix to avoid eventual
# clashes with the normal builds when the tarballs are unioned together.
if [[ $build == *-min ]]; then
  min="-min"
  cp -r $api_install/include tmp/$api_pkgname/min
  cp -r $api_install/lib tmp/$api_pkgname/min
else
  cp -r $api_install/include tmp/$api_pkgname
  cp -r $api_install/lib tmp/$api_pkgname
fi


fmt=tar

case $build in
  x86_64-windows*)
    cp target/$target/release/wasmtime.exe tmp/$bin_pkgname/wasmtime$min.exe
    fmt=zip

    if [ "$min" = "" ]; then
      # Generate a `*.msi` installer for Windows as well
      export WT_VERSION=`cat Cargo.toml | sed -n 's/^version = "\([^"]*\)".*/\1/p'`
      "$WIX/bin/candle" -arch x64 -out target/wasmtime.wixobj ci/wasmtime.wxs
      "$WIX/bin/light" -out dist/$bin_pkgname.msi target/wasmtime.wixobj -ext WixUtilExtension
      rm dist/$bin_pkgname.wixpdb
    fi
    ;;

  # Skip the MSI for non-x86_64 builds of Windows
  x86_64-mingw* | *-windows*)
    cp target/$target/release/wasmtime.exe tmp/$bin_pkgname/wasmtime$min.exe
    fmt=zip
    ;;

  *-macos*)
    cp target/$target/release/wasmtime tmp/$bin_pkgname/wasmtime$min
    ;;

  *)
    cp target/$target/release/wasmtime tmp/$bin_pkgname/wasmtime$min
    ;;
esac


mktarball() {
  dir=$1
  if [ "$fmt" = "tar" ]; then
    tar -czvf dist/$dir.tar.gz -C tmp $dir
  else
    # Note that this runs on Windows, and it looks like GitHub Actions doesn't
    # have a `zip` tool there, so we use something else
    (cd tmp && 7z a ../dist/$dir.zip $dir/)
  fi
}

mktarball $api_pkgname
mktarball $bin_pkgname