Skip to content

Add simple mode version to github releases#560

Open
oleole39 wants to merge 4 commits intoalam00000:mainfrom
oleole39:release_simple_mode_version
Open

Add simple mode version to github releases#560
oleole39 wants to merge 4 commits intoalam00000:mainfrom
oleole39:release_simple_mode_version

Conversation

@oleole39
Copy link
Copy Markdown

@oleole39 oleole39 commented Mar 10, 2026

Description

Add config to build and release dist-simple-${version}.zip in addition to already existing dist-${version}.zip.

Fixes #484

Type of change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • This change requires a documentation update (deployment instructions?)

🧪 How Has This Been Tested?

The new workflow has not been tested yet.

Checklist:

  • Verified output manually

Expected Results:

Upload one additional asset to the Github release.

Actual Results:

Checklist:

  • I have signed the Contributor License Agreement (CLA) or my organization has signed the Corporate CLA
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • Chores
    • Releases now publish two distribution packages (standard and simplified) as versioned zip assets.
    • Build output directory is configurable so simplified builds are produced separately (dist-simple).
    • Tooling and configs updated to ignore/exclude the simplified output from linting, type-checking, and coverage.
    • Multi-arch container build and publish steps were removed from the release workflow.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 10, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@oleole39
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Mar 10, 2026
Copy link
Copy Markdown

@MrFreePress MrFreePress left a comment

Choose a reason for hiding this comment

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

Not approving yet. This release workflow change is reasonable in principle, but the PR explicitly says it has not been tested. Untested release-pipeline changes should not merge blind.

@oleole39
Copy link
Copy Markdown
Author

Untested release-pipeline changes should not merge blind.

I assume such test is to be performed by the core team?

@alam00000
Copy link
Copy Markdown
Owner

@oleole39 That's a bot don't mind it. I have left two reviews. Also BUILD_OUTPUT_DIR is read in the dev server middleware paths in vite.config.ts where it'll never be set.

I also suggest you to run the workflow on your own branch

@oleole39
Copy link
Copy Markdown
Author

oleole39 commented Mar 23, 2026

Hello @alam00000,

I have left two reviews.

Would you mean "review comments"? I can't find them, did I miss something?

BUILD_OUTPUT_DIR is read in the dev server middleware paths in vite.config.ts where it'll never be set.

Not sure to get this point. In this PR, BUILD_OUTPUT_DIR is an environment variable defined in the workflow and processed in vite.config.js at two locations:

  • within createLanguageMiddleware() - though I'm not sure about the purpose of this function and therefore whether it is useful here. Maybe you mean that it is useless here ?
  • within export default defineConfig(()) where it is quite standard and therefore I guess it makes sense.

Comment thread scripts/package-dist.js Outdated
Comment thread scripts/package-dist.js Outdated
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 23, 2026

📝 Walkthrough

Walkthrough

CI and build tooling were changed to support a configurable build output directory (default dist) and produce both standard and "simple" distribution artifacts (dist-<version>.zip and dist-simple-<version>.zip). Docker image build/push jobs and tag-only gating were removed from the workflow.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/build-and-publish.yml
Removed tag-only gating and all Docker image jobs; runs two packaging flows (default and simple) and uploads both dist-<version>.zip and dist-simple-<version>.zip.
Packaging Script
scripts/package-dist.js
Replaced hardcoded dist with process.env.BUILD_OUTPUT_DIR (default dist); sets SIMPLE_MODE when building dist-simple; creates ./${buildOutputDir}-${version}.zip and validates the chosen output dir.
Vite & Middleware
vite.config.ts
Introduced outputDir from `process.env.BUILD_OUTPUT_DIR
Project Tooling Excludes
tsconfig.json, eslint.config.mjs, vitest.config.ts, .gitignore
Added dist-simple to TypeScript/ESLint/Vitest exclude lists and .gitignore; updated ignore patterns to exclude the simple build output.

Sequence Diagram(s)

sequenceDiagram
  participant GH as GitHub Actions
  participant Runner as CI Runner
  participant Build as Vite / npm scripts
  participant Pack as scripts/package-dist.js
  participant Release as GitHub Release

  GH->>Runner: start build-and-publish job
  Runner->>Build: run build (BUILD_OUTPUT_DIR=dist)
  Build-->>Runner: produce ./dist
  Runner->>Pack: package ./dist -> dist-<version>.zip
  Runner->>Build: run build (BUILD_OUTPUT_DIR=dist-simple, SIMPLE_MODE=true)
  Build-->>Runner: produce ./dist-simple
  Runner->>Pack: package ./dist-simple -> dist-simple-<version>.zip
  Runner->>Release: upload files: dist-<version>.zip, dist-simple-<version>.zip
  Release-->>GH: release assets uploaded
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through builds both big and small,
I crafted two zips—one simple, one tall.
ENV bits whisper, outputs find their place,
Dist and dist-simple, snug in their space. ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Out of Scope Changes check ❓ Inconclusive Docker image-related jobs were removed from the workflow; while not explicitly mentioned in issue #484, this removal may be intentional but warrants clarification regarding its relationship to the PR objectives. Clarify whether the removal of Docker image jobs (build-amd64, build-arm64, merge-manifests-ghcr, push-to-dockerhub) is intentional and necessary for this PR, or if it should be reverted.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main change: adding a simple mode distribution version to GitHub releases alongside the existing artifact.
Description check ✅ Passed The description covers the primary objective, issue reference, type of change, and testing approach, though some checklist items remain incomplete.
Linked Issues check ✅ Passed The PR addresses issue #484's primary requirement to provide a separate dist-simple distribution zip for download, implementing the feature through configuration changes to build and package both variants.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/build-and-publish.yml (1)

32-37: Consider removing duplicate build work in CI.

You currently build twice explicitly, then npm run package builds again for each package step. That’s extra runtime and increases chance of env drift between steps.

Also applies to: 44-49

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build-and-publish.yml around lines 32 - 37, The workflow
currently runs two explicit build steps ("Build full distribution" running `npm
run build` and "Build simple distribution" running `SIMPLE_MODE=true
BUILD_OUTPUT_DIR=dist-simple npm run build`) and later runs `npm run package`
which itself rebuilds, causing duplicate work; remove the redundant explicit
build steps or convert them to a single build that produces reusable artifacts
(upload/download or set outputs) that `npm run package` can consume so packaging
steps don't rebuild — update or remove the steps named "Build full distribution"
and "Build simple distribution" and ensure `npm run package` runs against the
produced artifacts (or disable its internal build) to avoid double-building.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/build-and-publish.yml:
- Around line 47-48: The "Package simple distribution" step re-runs the build
without simple mode and can overwrite dist-simple; set SIMPLE_MODE=true when
invoking the package/build step so the rebuild produces simple-mode assets (e.g.
run the package step with SIMPLE_MODE=true and BUILD_OUTPUT_DIR=dist-simple) to
ensure the zip contains simple-mode output and not default-mode files.

---

Nitpick comments:
In @.github/workflows/build-and-publish.yml:
- Around line 32-37: The workflow currently runs two explicit build steps
("Build full distribution" running `npm run build` and "Build simple
distribution" running `SIMPLE_MODE=true BUILD_OUTPUT_DIR=dist-simple npm run
build`) and later runs `npm run package` which itself rebuilds, causing
duplicate work; remove the redundant explicit build steps or convert them to a
single build that produces reusable artifacts (upload/download or set outputs)
that `npm run package` can consume so packaging steps don't rebuild — update or
remove the steps named "Build full distribution" and "Build simple distribution"
and ensure `npm run package` runs against the produced artifacts (or disable its
internal build) to avoid double-building.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 2d5b3b26-a560-4bcc-b6e6-08bf5e71c615

📥 Commits

Reviewing files that changed from the base of the PR and between d2a1450 and 5669e77.

📒 Files selected for processing (7)
  • .github/workflows/build-and-publish.yml
  • .gitignore
  • eslint.config.mjs
  • scripts/package-dist.js
  • tsconfig.json
  • vite.config.ts
  • vitest.config.ts

Comment on lines +47 to +48
- name: Package simple distribution
run: BUILD_OUTPUT_DIR=dist-simple npm run package
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Set SIMPLE_MODE=true during simple packaging, or the “simple” zip can contain default-mode output.

npm run package triggers a build again, so at Line 48 the rebuild runs without simple mode and can overwrite dist-simple with default-mode assets before zipping.

✅ Minimal fix
-      - name: Package simple distribution
-        run: BUILD_OUTPUT_DIR=dist-simple npm run package
+      - name: Package simple distribution
+        run: SIMPLE_MODE=true BUILD_OUTPUT_DIR=dist-simple npm run package
📝 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: Package simple distribution
run: BUILD_OUTPUT_DIR=dist-simple npm run package
- name: Package simple distribution
run: SIMPLE_MODE=true BUILD_OUTPUT_DIR=dist-simple npm run package
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build-and-publish.yml around lines 47 - 48, The "Package
simple distribution" step re-runs the build without simple mode and can
overwrite dist-simple; set SIMPLE_MODE=true when invoking the package/build step
so the rebuild produces simple-mode assets (e.g. run the package step with
SIMPLE_MODE=true and BUILD_OUTPUT_DIR=dist-simple) to ensure the zip contains
simple-mode output and not default-mode files.

@oleole39 oleole39 force-pushed the release_simple_mode_version branch from 2b333b8 to 526d644 Compare March 24, 2026 00:39
@oleole39
Copy link
Copy Markdown
Author

I've tested the workflow on my fork, at least the build-and-release job of build-and-publish.yml (I haven't tried building the Docker images, but I've not changed much in this area from the original code): https://github.com/oleole39/bentopdf/actions/runs/23467398303

As you will notice, build and packaging steps work fine.
Creating release in Github fails due to the wrong version tag extracted at the Extract version step, but I assume this is related to the fact that the action didn't run from the original branch.

Still you will want to check the review comments left open in this PR.

  1. is the suggested change in createLanguageMiddleware() in vite.config.js required?
  2. the build-and-release job of build-and-publish.yml workflow builds the app twice for each version (=in total 4 times) for some reason. One is probably enough?

Comment thread .github/workflows/build-and-publish.yml
Comment thread .github/workflows/build-and-publish.yml
@oleole39 oleole39 force-pushed the release_simple_mode_version branch from 526d644 to 57a7f47 Compare March 24, 2026 12:44
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
scripts/package-dist.js (1)

11-11: Constrain BUILD_OUTPUT_DIR to expected values.

At Line 11, any directory name is accepted. With Line 61 archiving that directory, a typo or bad env value could package unintended content. Consider whitelisting to dist / dist-simple and failing fast.

Proposed guard
-const buildOutputDirName = process.env.BUILD_OUTPUT_DIR || 'dist';
+const buildOutputDirName = process.env.BUILD_OUTPUT_DIR || 'dist';
+const allowedOutputDirs = new Set(['dist', 'dist-simple']);
+if (!allowedOutputDirs.has(buildOutputDirName)) {
+  console.error(`❌ Invalid BUILD_OUTPUT_DIR: ${buildOutputDirName}`);
+  process.exit(1);
+}

Also applies to: 35-37, 61-61

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/package-dist.js` at line 11, Reject any BUILD_OUTPUT_DIR values
outside the allowed set to avoid packaging unintended files: when reading
process.env.BUILD_OUTPUT_DIR into buildOutputDirName, validate it against a
whitelist (e.g., 'dist' and 'dist-simple'); if it's empty use the default
'dist', but if provided and not one of the allowed values fail fast (throw or
process.exit with a clear error). Apply the same whitelist check wherever
buildOutputDirName is used (notably the build steps around the earlier variable
usage and the archiving step that references the directory) so archiving only
ever runs on an allowed directory.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@scripts/package-dist.js`:
- Around line 14-18: Replace the unnecessary ternary for isSimpleMode with a
boolean assignment and stop inlining environment variables in the shell command;
instead set SIMPLE_MODE via the execSync env option. Specifically, update the
isSimpleMode declaration (currently named isSimpleMode) to a simple boolean and
change the execSync call that runs `npm run build` to pass an env object
(merging process.env) with SIMPLE_MODE set to the boolean/string value so the
command is cross-platform compatible on Windows and Unix.

---

Nitpick comments:
In `@scripts/package-dist.js`:
- Line 11: Reject any BUILD_OUTPUT_DIR values outside the allowed set to avoid
packaging unintended files: when reading process.env.BUILD_OUTPUT_DIR into
buildOutputDirName, validate it against a whitelist (e.g., 'dist' and
'dist-simple'); if it's empty use the default 'dist', but if provided and not
one of the allowed values fail fast (throw or process.exit with a clear error).
Apply the same whitelist check wherever buildOutputDirName is used (notably the
build steps around the earlier variable usage and the archiving step that
references the directory) so archiving only ever runs on an allowed directory.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 916ae80d-9431-445c-92ba-eada501e0ef6

📥 Commits

Reviewing files that changed from the base of the PR and between 2b333b8 and 57a7f47.

📒 Files selected for processing (1)
  • scripts/package-dist.js

Comment thread scripts/package-dist.js
Comment on lines +14 to +18
const isSimpleMode = (buildOutputDirName === "dist-simple") ? true : false;

// Run the build command
try {
execSync('npm run build', { stdio: 'inherit' });
execSync(`SIMPLE_MODE=${isSimpleMode} npm run build`, { stdio: 'inherit' });
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify how SIMPLE_MODE is consumed (truthy/presence vs strict comparison).
rg -nP --type=ts --type=js -C3 'process\.env\.SIMPLE_MODE|SIMPLE_MODE'

Repository: alam00000/bentopdf

Length of output: 3454


Fix cross-platform env variable passing in build command.

The inline SIMPLE_MODE=${isSimpleMode} npm run build syntax does not work on Windows shells. Use the env option in execSync instead for cross-platform compatibility. Also simplify the unnecessary ternary operator.

Proposed fix
-const isSimpleMode = (buildOutputDirName === "dist-simple") ? true : false;
+const isSimpleMode = buildOutputDirName === 'dist-simple';

 try {
-  execSync(`SIMPLE_MODE=${isSimpleMode} npm run build`, { stdio: 'inherit' });
+  execSync('npm run build', {
+    stdio: 'inherit',
+    env: {
+      ...process.env,
+      ...(isSimpleMode ? { SIMPLE_MODE: 'true' } : {}),
+    },
+  });
   console.log('✅ Build completed successfully');
 } catch (error) {
📝 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
const isSimpleMode = (buildOutputDirName === "dist-simple") ? true : false;
// Run the build command
try {
execSync('npm run build', { stdio: 'inherit' });
execSync(`SIMPLE_MODE=${isSimpleMode} npm run build`, { stdio: 'inherit' });
const isSimpleMode = buildOutputDirName === 'dist-simple';
// Run the build command
try {
execSync('npm run build', {
stdio: 'inherit',
env: {
...process.env,
...(isSimpleMode ? { SIMPLE_MODE: 'true' } : {}),
},
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@scripts/package-dist.js` around lines 14 - 18, Replace the unnecessary
ternary for isSimpleMode with a boolean assignment and stop inlining environment
variables in the shell command; instead set SIMPLE_MODE via the execSync env
option. Specifically, update the isSimpleMode declaration (currently named
isSimpleMode) to a simple boolean and change the execSync call that runs `npm
run build` to pass an env object (merging process.env) with SIMPLE_MODE set to
the boolean/string value so the command is cross-platform compatible on Windows
and Unix.

@oleole39 oleole39 requested a review from alam00000 March 30, 2026 14:40
@oleole39
Copy link
Copy Markdown
Author

oleole39 commented Apr 5, 2026

@alam00000 Probably this can be closed after 2.8.2 release?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(Question) How to set the download zip version to simple mode

3 participants