diff --git a/.github/workflows/release_crypto_js.yml b/.github/workflows/release_crypto_js.yml new file mode 100644 index 00000000000..f5f98ce95ba --- /dev/null +++ b/.github/workflows/release_crypto_js.yml @@ -0,0 +1,63 @@ +# This workflow releases the `matrix-sdk-crypto-js` project. +# +# It is triggered when a new tag appears that matches +# `matrix-sdk-crypto-js-v[0-9]+.*`. This workflow builds the package +# for the binding, run its tests to ensure everything is still +# correct, and publish the package on NPM and on a newly created +# Github release. + + +name: Release `crypto-js` + +env: + CARGO_TERM_COLOR: always + PKG_PATH: "bindings/matrix-sdk-crypto-js" + +on: + push: + tags: + - matrix-sdk-crypto-js-v[0-9]+.* + +jobs: + publish-matrix-sdk-crypto-js: + name: Publish 🕸 [m]-crypto-js + + runs-on: ubuntu-latest + + steps: + - name: Checkout the repo + uses: actions/checkout@v3 + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: wasm32-unknown-unknown + profile: minimal + override: true + + - name: Load cache + uses: Swatinem/rust-cache@v1 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 18.0 + + - name: Install NPM dependencies + working-directory: ${{ env.PKG_PATH }} + run: npm install + + - name: Configure NPM auth token + working-directory: ${{ env.PKG_PATH }} + run: npm set "//registry.npmjs.org/:_authToken" "${{ secrets.NPM_TOKEN }}" + + - name: Publish the WebAssembly + JavaScript binding (imply building + testing) + working-directory: ${{ env.PKG_PATH }} + run: npm run publish + + - name: Create the Github release + uses: softprops/action-gh-release@v1 + with: + draft: true + files: ${{ env.PKG_PATH }}/pkg/matrix-org-matrix-sdk-crypto-js-*.tgz diff --git a/bindings/matrix-sdk-crypto-js/package.json b/bindings/matrix-sdk-crypto-js/package.json index 8b0a8f800fc..59cce9d6030 100644 --- a/bindings/matrix-sdk-crypto-js/package.json +++ b/bindings/matrix-sdk-crypto-js/package.json @@ -38,6 +38,8 @@ "scripts": { "build": "cross-env RUSTFLAGS='-C opt-level=z' wasm-pack build --release --target nodejs --scope matrix-org --out-dir ./pkg", "test": "jest --verbose", - "doc": "typedoc --tsconfig ." + "doc": "typedoc --tsconfig .", + "prepublish": "$npm_execpath run build && $npm_execpath run test", + "publish": "wasm-pack pack && wasm-pack publish" } }