diff --git a/.github/workflows/aicirt.yml b/.github/workflows/aicirt.yml index ec21d33f..fc3c2344 100644 --- a/.github/workflows/aicirt.yml +++ b/.github/workflows/aicirt.yml @@ -3,6 +3,8 @@ name: AICIrt on: push: branches: [ "main" ] + tags: + - "v*.*.*" pull_request: branches: [ "main" ] @@ -35,3 +37,13 @@ jobs: - name: Build aicirt run: cargo build --verbose --release working-directory: aicirt + - name: Release script + run: ./scripts/release.sh --xz + - name: Release + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + with: + body_path: target/dist/README.md + files: | + target/dist/*.tar.gz + target/dist/*.tar.xz diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 00000000..925e0afb --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,74 @@ +#!/bin/sh + +FOLDERS="aici_abi uppercase pyctrl jsctrl declctrl aicirt" +NATIVE="$(uname -s | tr 'A-Z' 'a-z')-$(uname -m)" +D=`date +%Y%m%d-%H%M` +TAG=`git describe --dirty --tags --match 'v[0-9]*' --always | sed -e 's/^v//; s/-dirty/-'"$D/"` +XZ= + +if [ "$1" == "--xz" ] ; then + XZ=1 + shift +fi + +echo "Building for $NATIVE" + +set -e + +for f in $FOLDERS ; do + echo "Build $f..." + (cd $f && cargo build --release) +done + +function release() { + +T0=$1 +T=target/dist/$1 +shift + +TITLE="$1" +shift + +SUFF="$1" +shift + +rm -rf $T +mkdir -p $T +echo "# $TITLE ($SUFF-$TAG)" > $T/README.md + +BN= +for f in "$@" ; do + cp $f $T/ + BN="$BN $(basename $f)" +done + +echo >> $T/README.md +echo "Contents:" >> $T/README.md +echo '```' >> $T/README.md +(cd $T && ls -l $BN | awk '{print $5, $9}') >> $T/README.md +echo >> $T/README.md +(cd $T && sha256sum $BN) >> $T/README.md +echo '```' >> $T/README.md +echo >> $T/README.md + +cat $T/README.md >> target/dist/README.md + +if [ "$XZ" = "1" ] ; then +DST=target/dist/$T0-$SUFF-$TAG.tar.xz +tar -Jcf $DST -C target/dist $T0 +ls -l $DST +fi + +DST=target/dist/$T0-$SUFF-$TAG.tar.gz +tar -zcf $DST -C target/dist $T0 +ls -l $DST + +} + +rm -rf target/dist +mkdir -p target/dist +echo -n > target/dist/README.md + +release aici-controllers "AICI Controllers" "wasm32-wasi" target/wasm32-wasi/release/*.wasm +strip target/release/aicirt +release aicirt "AICI Runtime" "$NATIVE" target/release/aicirt