diff --git a/.github/workflows/publish-standalone.yml b/.github/workflows/publish-standalone.yml new file mode 100644 index 0000000..a950911 --- /dev/null +++ b/.github/workflows/publish-standalone.yml @@ -0,0 +1,25 @@ +name: Publish Standalone + +on: + release: + types: [created] + +jobs: + build: + uses: ./.github/workflows/build.yml + + publish-standalone: + needs: build + strategy: + matrix: + os: [macos-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v2 + - uses: ./.github/actions/setup + - run: make -C src/standalone install-deps package + - uses: skx/github-action-publish-binaries@44887b225ceca96efd8a912d39c09ad70312af31 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + args: 'waforth-*.tgz' diff --git a/src/standalone/.gitignore b/src/standalone/.gitignore index 78be286..7cf6216 100644 --- a/src/standalone/.gitignore +++ b/src/standalone/.gitignore @@ -2,3 +2,4 @@ /waforth_core.h /wasm-micro-runtime /wasmtime-* +/*.tgz \ No newline at end of file diff --git a/src/standalone/Makefile b/src/standalone/Makefile index 09d7eea..2ca9471 100644 --- a/src/standalone/Makefile +++ b/src/standalone/Makefile @@ -3,20 +3,24 @@ UNAME_P=$(shell uname -p) ifeq ($(UNAME_S),Darwin) WASMTIME_DIR=wasmtime-v0.37.0-x86_64-macos-c-api WASMTIME_RELEASE_URL=https://github.com/bytecodealliance/wasmtime/releases/download/v0.37.0/wasmtime-v0.37.0-x86_64-macos-c-api.tar.xz +PACKAGE_SUFFIX=x86_64-macos else WASMTIME_DIR=wasmtime-v0.37.0-x86_64-linux-c-api WASMTIME_RELEASE_URL=https://github.com/bytecodealliance/wasmtime/releases/download/v0.37.0/wasmtime-v0.37.0-x86_64-linux-c-api.tar.xz LIBS=-lpthread -lm -ldl +PACKAGE_SUFFIX=x86_64-linux endif CFLAGS=-I$(WASMTIME_DIR)/include LDFLAGS= LIBS:=$(WASMTIME_DIR)/lib/libwasmtime.a $(LIBS) +VERSION?=$(shell cat ../../package.json | grep '"version"' | sed -e 's/.*:.*"\(.*\)".*/\1/') BIN2H=../../scripts/bin2h WAT2WASM=wat2wasm WAT2WASM_FLAGS=--debug-names +CFLAGS:=-DVERSION='"$(VERSION)"' $(CFLAGS) OBJECTS=main.o all: waforth @@ -37,7 +41,10 @@ install-deps: -rm -rf wasmtime-* curl -L -s $(WASMTIME_RELEASE_URL) | tar xJv +.PHONY: package +package: waforth + tar czf waforth-v$(VERSION)-$(PACKAGE_SUFFIX).tgz waforth .PHONY: clean clean: - -rm -f waforth_core.wasm waforth_core.h $(OBJECTS) waforth + -rm -f waforth_core.wasm waforth_core.h $(OBJECTS) waforth *.tgz diff --git a/src/standalone/main.c b/src/standalone/main.c index 506e9d5..187e4b4 100644 --- a/src/standalone/main.c +++ b/src/standalone/main.c @@ -3,6 +3,10 @@ #include "waforth_core.h" #include "wasm.h" +#ifndef VERSION +#define VERSION "dev" +#endif + #define CORE_TABLE_EXPORT_INDEX 0 #define CORE_MEMORY_EXPORT_INDEX 1 #define CORE_INTERPRET_EXPORT_INDEX 6 @@ -164,7 +168,7 @@ int main(int argc, char *argv_main[]) { return -1; } - printf("WAForth\n"); + printf("WAForth (" VERSION ")\n"); wasm_val_t as[1] = {WASM_I32_VAL(0)}; wasm_val_vec_t args = WASM_ARRAY_VEC(as); wasm_val_t vs[] = {WASM_INIT_VAL};