Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare WASM bindings for release #1176

Merged
merged 8 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/release-wasm-bindings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release WASM Bindings

on:
workflow_dispatch:

env:
CARGO_TERM_COLOR: always

Comment on lines +3 to +8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add version control parameters to the workflow trigger.

Consider adding input parameters to control the release version and ensure intentional releases:

 on:
   workflow_dispatch:
+    inputs:
+      version:
+        description: 'Version to release (e.g., 1.0.0)'
+        required: true
+      dry_run:
+        description: 'Perform a dry run without publishing'
+        type: boolean
+        default: false
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
on:
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
on:
workflow_dispatch:
inputs:
version:
description: 'Version to release (e.g., 1.0.0)'
required: true
dry_run:
description: 'Perform a dry run without publishing'
type: boolean
default: false
env:
CARGO_TERM_COLOR: always

jobs:
release:
permissions:
id-token: write
runs-on: warp-ubuntu-latest-x64-16x
Comment on lines +10 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Update permissions for NPM publishing.

The current permissions block might be insufficient for NPM publishing. Consider adding necessary permissions:

   permissions:
     id-token: write
+    contents: read
+    packages: write
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
release:
permissions:
id-token: write
runs-on: warp-ubuntu-latest-x64-16x
release:
permissions:
id-token: write
contents: read
packages: write
runs-on: warp-ubuntu-latest-x64-16x
🧰 Tools
🪛 actionlint

13-13: label "warp-ubuntu-latest-x64-16x" is unknown. available labels are "windows-latest", "windows-latest-8-cores", "windows-2022", "windows-2019", "ubuntu-latest", "ubuntu-latest-4-cores", "ubuntu-latest-8-cores", "ubuntu-latest-16-cores", "ubuntu-24.04", "ubuntu-22.04", "ubuntu-20.04", "macos-latest", "macos-latest-xl", "macos-latest-xlarge", "macos-latest-large", "macos-15-xlarge", "macos-15-large", "macos-15", "macos-14-xl", "macos-14-xlarge", "macos-14-large", "macos-14", "macos-14.0", "macos-13-xl", "macos-13-xlarge", "macos-13-large", "macos-13", "macos-13.0", "macos-12-xl", "macos-12-xlarge", "macos-12-large", "macos-12", "macos-12.0", "self-hosted", "x64", "arm", "arm64", "linux", "macos", "windows". if it is a custom label for self-hosted runner, set list of labels in actionlint.yaml config file

(runner-label)

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Update rust toolchains, add target
run: |
rustup update

- name: Cache
uses: Swatinem/rust-cache@v2
with:
workspaces: |
.
bindings_wasm

Comment on lines +22 to +28
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Optimize Rust caching configuration.

The current cache configuration could be more specific:

       - name: Cache
         uses: Swatinem/rust-cache@v2
         with:
           workspaces: |
-            .
-            bindings_wasm
+            bindings_wasm:target
           shared-key: "wasm-bindings"
+          cache-directories: |
+            bindings_wasm/node_modules

Committable suggestion was skipped due to low confidence.

- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache-dependency-path: "bindings_wasm/yarn.lock"
cache: "yarn"
env:
SKIP_YARN_COREPACK_CHECK: "1"

Comment on lines +29 to +37
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add NPM registry configuration for publishing.

The Node.js setup should include registry configuration for publishing:

       - name: Setup node
         uses: actions/setup-node@v4
         with:
           node-version-file: ".node-version"
           cache-dependency-path: "bindings_wasm/yarn.lock"
           cache: "yarn"
+          registry-url: 'https://registry.npmjs.org'
         env:
           SKIP_YARN_COREPACK_CHECK: "1"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache-dependency-path: "bindings_wasm/yarn.lock"
cache: "yarn"
env:
SKIP_YARN_COREPACK_CHECK: "1"
- name: Setup node
uses: actions/setup-node@v4
with:
node-version-file: ".node-version"
cache-dependency-path: "bindings_wasm/yarn.lock"
cache: "yarn"
registry-url: 'https://registry.npmjs.org'
env:
SKIP_YARN_COREPACK_CHECK: "1"

- name: Enable corepack
run: corepack enable

- name: Install dependencies
working-directory: bindings_wasm
run: |
yarn

- name: Build
working-directory: bindings_wasm
run: yarn build

Comment on lines +46 to +49
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Add build validation step.

Consider adding validation after the build step to ensure the output is correct:

       - name: Build
         working-directory: bindings_wasm
         run: yarn build
+
+      - name: Validate build output
+        working-directory: bindings_wasm
+        run: |
+          if [ ! -f "dist/index.js" ] || [ ! -f "dist/index.d.ts" ]; then
+            echo "Error: Build output files are missing"
+            exit 1
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Build
working-directory: bindings_wasm
run: yarn build
- name: Build
working-directory: bindings_wasm
run: yarn build
- name: Validate build output
working-directory: bindings_wasm
run: |
if [ ! -f "dist/index.js" ] || [ ! -f "dist/index.d.ts" ]; then
echo "Error: Build output files are missing"
exit 1
fi

- name: Publish to NPM
uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
package: bindings_wasm
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Comment on lines +50 to +56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Enhance the publishing step with validation and documentation.

The publishing step could be improved with additional checks and documentation:

       - name: Publish to NPM
         uses: JS-DevTools/npm-publish@v3
         with:
           token: ${{ secrets.NPM_TOKEN }}
           package: bindings_wasm
+          dry-run: ${{ inputs.dry_run }}
+          check-version: true
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+
+      - name: Create GitHub Release
+        if: ${{ !inputs.dry_run }}
+        uses: actions/create-release@v1
+        env:
+          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+        with:
+          tag_name: wasm-v${{ inputs.version }}
+          release_name: WASM Bindings v${{ inputs.version }}
+          body_path: bindings_wasm/CHANGELOG.md
+          draft: false

Committable suggestion was skipped due to low confidence.

12 changes: 12 additions & 0 deletions bindings_wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,14 @@
/target
/build

# yarn
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/sdks
!.yarn/versions

# build artifacts
dist
2 changes: 1 addition & 1 deletion bindings_wasm/.node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.19.1
20.15.0
2 changes: 1 addition & 1 deletion bindings_wasm/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18.19.1
20.15.0
934 changes: 934 additions & 0 deletions bindings_wasm/.yarn/releases/yarn-4.5.1.cjs

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions bindings_wasm/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
compressionLevel: mixed

enableGlobalCache: false

nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-4.5.1.cjs
5 changes: 5 additions & 0 deletions bindings_wasm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @xmtp/wasm-bindings

## 0.0.1

Initial release
292 changes: 0 additions & 292 deletions bindings_wasm/package-lock.json

This file was deleted.

Loading