1#!/bin/bash 2 3# Script to merge the outputs of a run on github actions to github releases. 4# This is invoked from `.github/workflows/publish-artifacts.yml`. All previous 5# artifacts from builds are located in `bins-*` folders. The main purpose of 6# this script is to take the "min" build and merge it into the "normal" build to 7# produce one final tarball. This means that the final artifacts will have both 8# a normal and a min build in them for comparison and usage. 9 10set -ex 11 12# Prepare the upload folder and move all artifacts that aren't being merged into 13# this folder, e.g. the MSI installer and adapter wasm files. 14rm -rf dist 15mkdir dist 16mv -t dist bins-*/*.{msi,wasm} 17mv wasmtime-platform-header/* dist 18 19# Merge tarballs and zips by searching for `*-min` builds, unpacking the 20# min/normal builds, into the same destination, and then repacking into a 21# tarball. 22# 23# Note that for now xz compression is used for the final artifact to try to get 24# small artifacts, but it's left at the default level since a lot of artifacts 25# are processed here and turning it up to the max 9 compression might take 26# quite awhile on CI for this one builder to process. 27for min in bins-*-min/*.tar.*; do 28 normal=${min/-min\//\/} 29 filename=$(basename $normal) 30 dir=${filename%.tar.gz} 31 32 rm -rf tmp 33 mkdir tmp 34 tar xf $min -C tmp 35 tar xf $normal -C tmp 36 tar -cf - -C tmp $dir | xz -T0 > dist/$dir.tar.xz 37 rm $min $normal 38done 39 40for min in bins-*-min/*.zip; do 41 normal=${min/-min\//\/} 42 filename=$(basename $normal) 43 dir=${filename%.zip} 44 45 rm -rf tmp 46 mkdir tmp 47 (cd tmp && unzip -o ../$min) 48 (cd tmp && unzip -o ../$normal) 49 (cd tmp && 7z a ../dist/$dir.zip $dir/) 50 rm $min $normal 51done 52 53# Copy over remaining source tarball into the dist folder 54mv -t dist bins-*/*.tar.* 55