Mayil-AI-Sandbox / kuzudb_jan15

MIT License
0 stars 0 forks source link

Build CLI binary as executable prior to zip/release (hashtag2880) #8

Open vikramsubramanian opened 4 months ago

vikramsubramanian commented 4 months ago

The current CLI downloaded via the URL (for example, [this one]( when unzipped just provides a file. The user has to manually convert the file to an executable on Linux/MacOS by typing chmod +x kuzu to allow it to be executed.

Is there something that could be done during the build process that allows us to unzip the downloaded file directly as an executable? )

mayil-ai[bot] commented 4 months ago

Summary: Issue with building CLI binary as executable prior to zip/release.

Implementation ideas

To implement the feature described in the Jira ticket, you need to ensure that the CLI binary is marked as executable before it is zipped and released. Here's how you can do it:

Here's an example of how you can modify the Linux workflow:

      - name: Set executable bit
        run: chmod +x kuzu

Place this step right after the build step and before the artifact upload step.

Additionally, ensure that the packaging script that creates the zip file retains the executable bit. This can be done by using the tar command with the correct options to preserve file permissions.

Here's an example of how you can modify the packaging script in tools/nodejs_api/package.js:

  console.log("Creating tarball...");
  // Create the tarball
  await new Promise((resolve, reject) => {
    childProcess.execFile(
      "tar",
      ["-czvf", "kuzu-source.tar.gz", "--preserve-permissions", "package"],
      { cwd: CURRENT_DIR },
      (err) => {
        if (err) {
          reject(err);
        } else {
          resolve();
        }
      }
    );
  });

The --preserve-permissions option tells tar to preserve the file permissions (including the executable bit) when creating the archive.

Make sure to test the changes by running the modified workflow and packaging script, then downloading the resulting zip file and verifying that the CLI binary is executable upon extraction.

Code snippets to check