#!/bin/bash12# Script to merge the outputs of a run on github actions to github releases.3# This is invoked from `.github/workflows/publish-artifacts.yml`. All previous4# artifacts from builds are located in `bins-*` folders. The main purpose of5# this script is to take the "min" build and merge it into the "normal" build to6# produce one final tarball. This means that the final artifacts will have both7# a normal and a min build in them for comparison and usage.89set -ex1011# Prepare the upload folder and move all artifacts that aren't being merged into12# this folder, e.g. the MSI installer and adapter wasm files.13rm -rf dist14mkdir dist15mv -t dist bins-*/*.{msi,wasm}16mv wasmtime-platform-header/* dist1718# Merge tarballs and zips by searching for `*-min` builds, unpacking the19# min/normal builds, into the same destination, and then repacking into a20# tarball.21#22# Note that for now xz compression is used for the final artifact to try to get23# small artifacts, but it's left at the default level since a lot of artifacts24# are processed here and turning it up to the max 9 compression might take25# quite awhile on CI for this one builder to process.26for min in bins-*-min/*.tar.*; do27normal=${min/-min\//\/}28filename=$(basename $normal)29dir=${filename%.tar.gz}3031rm -rf tmp32mkdir tmp33tar xf $min -C tmp34tar xf $normal -C tmp35tar -cf - -C tmp $dir | xz -T0 > dist/$dir.tar.xz36rm $min $normal37done3839for min in bins-*-min/*.zip; do40normal=${min/-min\//\/}41filename=$(basename $normal)42dir=${filename%.zip}4344rm -rf tmp45mkdir tmp46(cd tmp && unzip -o ../$min)47(cd tmp && unzip -o ../$normal)48(cd tmp && 7z a ../dist/$dir.zip $dir/)49rm $min $normal50done5152# Copy over remaining source tarball into the dist folder53mv -t dist bins-*/*.tar.*545556