diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 29059d7..551daf9 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -105,6 +105,9 @@ jobs: run: npm publish --access public working-directory: aqua + - name: Install ipfs + uses: nahsi/setup-ipfs@v1 + - name: Create builtin distribution package if: needs.release-please.outputs.trust-graph-release-created run: ./builtin-package/package.sh diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9bdf9dc..94a7c82 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -58,6 +58,9 @@ jobs: - run: npm run build working-directory: aqua + - name: Install ipfs + uses: nahsi/setup-ipfs@v1 + - name: Create distribution package run: ./builtin-package/package.sh diff --git a/builtin-package/blueprint.json b/builtin-package/blueprint.json deleted file mode 100644 index 3e0d9c3..0000000 --- a/builtin-package/blueprint.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name": "trust-graph", - "dependencies": [ - "name:sqlite3", - "name:trust-graph" - ] -} diff --git a/builtin-package/package.sh b/builtin-package/package.sh index 2ea15ea..2acdde4 100755 --- a/builtin-package/package.sh +++ b/builtin-package/package.sh @@ -3,18 +3,39 @@ set -o pipefail -o nounset -o errexit # set current working directory to script directory to run script from everywhere cd "$(dirname "$0")" -SCRIPT_DIR="$(pwd)" +PACKAGE_DIR="$(pwd)/../package" + +( + rm -f $PACKAGE_DIR/* + mkdir -p $PACKAGE_DIR +) ( echo "*** copy wasm files ***" cd ../service - cp artifacts/*.wasm "$SCRIPT_DIR" + cp artifacts/*.wasm "$PACKAGE_DIR" ) +( + echo "*** copy on_start script ***" + cp on_start.json "$PACKAGE_DIR" + cp on_start.air "$PACKAGE_DIR" +) + +TRUST_GRAPH_CID=$(ipfs add -q --only-hash --cid-version=1 --chunker=size-262144 $PACKAGE_DIR/trust-graph.wasm) +SQLITE_CID=$(ipfs add -q --only-hash --cid-version=1 --chunker=size-262144 $PACKAGE_DIR/sqlite3.wasm) +mv $PACKAGE_DIR/trust-graph.wasm "$PACKAGE_DIR"/"$TRUST_GRAPH_CID".wasm +mv $PACKAGE_DIR/sqlite3.wasm "$PACKAGE_DIR"/"$SQLITE_CID".wasm +cp trust-graph_config.json "$PACKAGE_DIR"/"$TRUST_GRAPH_CID"_config.json +cp sqlite3_config.json "$PACKAGE_DIR"/"$SQLITE_CID"_config.json + +# write blueprint.json +echo "{}" | jq --arg trust_graph_cid "$TRUST_GRAPH_CID" --arg sqlite_cid "$SQLITE_CID" '{"name": "trust-graph", "dependencies":[{"/":$sqlite_cid},{"/":$trust_graph_cid}]}' > "$PACKAGE_DIR/blueprint.json" + ( echo "*** create builtin distribution package ***" - cd .. - tar --exclude="package.sh" -f trust-graph.tar.gz -zcv --transform 's|builtin-package|trust-graph|' builtin-package + cd $PACKAGE_DIR + (tar cf - * | gzip) > ../trust-graph.tar.gz ) echo "*** done ***"