From ff5a75d89541dafe7a7f433a5f1383ed5258c85b Mon Sep 17 00:00:00 2001 From: Micha de Vries Date: Wed, 8 Jan 2025 23:04:49 +0100 Subject: [PATCH] add build workflow (#122) --- .github/workflows/build.yml | 68 +++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..7418546 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,68 @@ +name: Publish Package to npmjs + +on: + workflow_call: + inputs: + branch: + description: 'Which branch to build' + default: 'main' + required: true + type: string +jobs: + build: + name: Publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + ref: "${{ inputs.branch }}" + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + registry-url: "https://registry.npmjs.org" + + - name: Install pnpm + uses: pnpm/action-setup@v2 + with: + version: 9 + + - name: Install Rust toolchain + uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + toolchain: 1.81.0 + + - name: Install wasm-pack + run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh + + - name: Extract versions + run: | + echo "GIT_TAG=${GITHUB_REF##*/}" >> $GITHUB_ENV + echo "PKG_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV + + - name: Assert package versions + run: | + echo "CM_VERSION=$CM_VERSION" + echo "PKG_VERSION=$PKG_VERSION" + + if [[ "v$PKG_VERSION" != "$GIT_TAG" ]]; then + echo "Version mismatch! Please correct package versions" + exit 1 + else + echo "Version check complete" + fi + + - name: Install NPM dependencies + run: pnpm install + + - name: Build & Bundle + run: pnpm build + + - name: Pack + run: npm pack --pack-destination ~ + + - uses: actions/upload-artifact@v4 + with: + name: packed + path: "~/*.tgz"