Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8c78878
feat(action): add @node-minify/action GitHub Action package
srod Jan 9, 2026
44736c9
feat(action): add marketplace support and documentation
srod Jan 9, 2026
4c23751
fix(action): build dependencies before bundling action
srod Jan 9, 2026
22d7df6
fix(action): also build @node-minify/core before bundling
srod Jan 9, 2026
f20d288
fix(action): install compressor packages in test jobs
srod Jan 9, 2026
f9c4d25
fix(action): install compressors in temp dir to avoid workspace: prot…
srod Jan 9, 2026
7b41637
fix(action): copy compressor packages to repo node_modules
srod Jan 9, 2026
7d79a5a
fix(action): ensure node_modules dir exists and copy all deps
srod Jan 9, 2026
b1c51e8
fix(action): copy deps to packages/action/node_modules for resolution
srod Jan 9, 2026
c9454d8
fix(action): brute force copy of node_modules to all possible locations
srod Jan 9, 2026
7dcf118
refactor(action): cleanup test workflow installation steps
srod Jan 9, 2026
bb7b638
fix(action): ensure root node_modules directory exists before copying
srod Jan 9, 2026
0a51025
chore: add changeset for action and utils
srod Jan 9, 2026
abbfce5
feat(action): extract threshold logic and improve PR reporter pagination
srod Jan 9, 2026
4910a33
test(utils): add coverage for getFilesizeGzippedRaw
srod Jan 9, 2026
3ee69f5
test(utils): improve error assertions and add directory check for get…
srod Jan 9, 2026
757bbcb
📝 Add docstrings to `feature/github-action-package`
coderabbitai[bot] Jan 9, 2026
5b1bee1
fix(security): sanitize inputs in release workflow and check-publishe…
srod Jan 9, 2026
f954034
fix(scripts): allow dots in package names in check-published regex
srod Jan 9, 2026
cd46f1b
ci(release): commit compiled action dist during release
srod Jan 9, 2026
ce947a5
feat(action): add benchmark support to GitHub Action
srod Jan 9, 2026
80af89c
fix(action): add missing @node-minify/benchmark dependency
srod Jan 9, 2026
e481c45
fix(ci): build benchmark package before action in test workflow
srod Jan 9, 2026
ada9968
ci(release): improve release-action workflow robustness and add concu…
srod Jan 9, 2026
10b0760
fix(action): add missing compressor dependencies and robust gzip size…
srod Jan 10, 2026
508c293
feat(action): add benchmark outputs and improve input validation
srod Jan 10, 2026
7bb9549
ci(release): avoid empty commit when building action dist in release-…
srod Jan 10, 2026
6cbf94d
fix(action): improve input validation and push dist to tag in release
srod Jan 10, 2026
658bfc7
fix(action): improve release workflow tag handling, artifact packagin…
srod Jan 10, 2026
fb28e33
fix(benchmark): populate gzipBytes field for action compatibility
srod Jan 10, 2026
e150289
docs(test-action): document why compressor packages must be installed
srod Jan 10, 2026
2ef2d7f
refactor(action): remove misleading validateJavaCompressor alias
srod Jan 10, 2026
53f66a6
docs: use @v1 instead of @main for action version reference
srod Jan 10, 2026
f1c18ca
fix(action): filter out type-required compressors from benchmark when…
srod Jan 10, 2026
c705213
test(action): add comprehensive tests for inputs, outputs, and benchmark
srod Jan 10, 2026
1af49d9
fix(benchmark): only pass type to minify when defined
srod Jan 10, 2026
0360054
fix(action): remove lightningcss from type-required compressors
srod Jan 10, 2026
829aae8
fix(action): improve input parsing robustness and security
srod Jan 10, 2026
9973c64
docs: remove 'requires type' for lightningcss across all documentation
srod Jan 10, 2026
9f1ced3
feat(action): add benchmark-json output and improve release workflow
srod Jan 10, 2026
8f451e6
ci(action): ensure release tag is only updated if dist changes
srod Jan 10, 2026
5ce6645
ci(action): use explicit refspecs for pushing release tags
srod Jan 13, 2026
512da8f
fix(action): throw descriptive error when benchmark yields no results
srod Jan 13, 2026
250f688
docs(action): document compressor package installation requirement
srod Jan 13, 2026
a6a7a0d
test(action): update benchmark test to expect error on empty results
srod Jan 13, 2026
4b465d8
fix: improve gzip size stream handling and action documentation
srod Jan 13, 2026
3d4d2d0
docs: add changeset for gzip and action fixes
srod Jan 13, 2026
3f53cf5
refactor: simplify gzip size implementation for better coverage
srod Jan 13, 2026
fad512f
docs: add removed inputs migration guide for deprecated action
srod Jan 13, 2026
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
8 changes: 8 additions & 0 deletions .changeset/fix-gzip-stream-and-action-build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@node-minify/utils": patch
"@node-minify/action": patch
---

fix: improve gzip size stream handling in utils
fix: ensure action build fails if type definitions copy fails
docs: add documentation for action inputs and java-version migration
8 changes: 8 additions & 0 deletions .changeset/fluffy-eagles-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@node-minify/utils": minor
"@node-minify/benchmark": minor
"@node-minify/docs": patch
---

feat: add `getFilesizeGzippedRaw` utility and update benchmark defaults
feat(action): launch `@node-minify/action` GitHub Action
159 changes: 73 additions & 86 deletions .github/actions/node-minify/README.md
Original file line number Diff line number Diff line change
@@ -1,41 +1,94 @@
# node-minify GitHub Action
# node-minify GitHub Action (DEPRECATED)

Minify JavaScript, CSS, and HTML files in your CI/CD pipeline with detailed reporting.
> **This action is deprecated.** Please use the new bundled action instead:
>
> ```yaml
> - uses: srod/node-minify@v1
> ```

## Usage
The new action includes:
- Bundled dependencies (faster startup)
- PR comment reporting
- File annotations
- Benchmark comparison
- Threshold enforcement
- More compressor options

### Basic Example
## Migration

Replace:

```yaml
- name: Minify JavaScript
uses: srod/node-minify/.github/actions/node-minify@main
- uses: srod/node-minify/.github/actions/node-minify@main
with:
input: "src/app.js"
output: "dist/app.min.js"
compressor: "terser"
```

With:

```yaml
- uses: srod/node-minify@v1
with:
input: "src/app.js"
output: "dist/app.min.js"
compressor: "terser"
```

### With All Options
### Removed Inputs

The following inputs are **not supported** in the new action and must be removed from your workflow YAML:

| Removed Input | Migration Guide |
|---------------|-----------------|
| `include-gzip` | Gzip sizes are now always included in the output. No action needed. |
| `java-version` | Use `actions/setup-java@v4` before running the action (see example below). |

#### Java Compressors Migration

If you use `gcc` or `yui` compressors that require Java:

**Before (deprecated):**
```yaml
- uses: srod/node-minify/.github/actions/node-minify@main
with:
compressor: gcc
java-version: "17"
```

**After:**
```yaml
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

- uses: srod/node-minify@v1
with:
compressor: gcc
```

See [packages/action/README.md](../../../packages/action/README.md) for full documentation.

---

## Legacy Documentation

The following documentation is for the deprecated composite action.

### Basic Example

```yaml
- name: Minify with full options
id: minify
- name: Minify JavaScript
uses: srod/node-minify/.github/actions/node-minify@main
with:
input: "src/app.js"
output: "dist/app.min.js"
compressor: "esbuild"
type: "js"
options: '{"minify": true}'
report-summary: "true"
include-gzip: "true"

- name: Show results
run: |
echo "Reduction: ${{ steps.minify.outputs.reduction-percent }}%"
compressor: "terser"
```

## Inputs
### Inputs

| Input | Description | Required | Default |
|-------|-------------|----------|---------|
Expand All @@ -48,30 +101,7 @@ Minify JavaScript, CSS, and HTML files in your CI/CD pipeline with detailed repo
| `include-gzip` | Include gzip sizes | No | `true` |
| `java-version` | Java version for gcc/yui | No | - |

### Available Compressors

**JavaScript (no Java required):**
- `terser` (recommended)
- `esbuild` (fastest)
- `swc`
- `oxc`
- `uglify-js`

**CSS (no Java required):**
- `lightningcss` (recommended)
- `clean-css`
- `cssnano`
- `csso`
- `esbuild`

**HTML:**
- `html-minifier`

**Requires Java:**
- `gcc` (Google Closure Compiler)
- `yui` (deprecated)

## Outputs
### Outputs

| Output | Description |
|--------|-------------|
Expand All @@ -84,49 +114,6 @@ Minify JavaScript, CSS, and HTML files in your CI/CD pipeline with detailed repo
| `gzip-size-formatted` | Gzipped size formatted |
| `time-ms` | Compression time in milliseconds |

## Examples

### CSS Minification

```yaml
- name: Minify CSS
uses: srod/node-minify/.github/actions/node-minify@main
with:
input: "src/styles.css"
output: "dist/styles.min.css"
compressor: "lightningcss"
type: "css"
```

### Using Google Closure Compiler

```yaml
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"

- name: Minify with GCC
uses: srod/node-minify/.github/actions/node-minify@main
with:
input: "src/app.js"
output: "dist/app.min.js"
compressor: "gcc"
options: '{"compilation_level": "ADVANCED_OPTIMIZATIONS"}'
```

### HTML Minification

```yaml
- name: Minify HTML
uses: srod/node-minify/.github/actions/node-minify@main
with:
input: "src/index.html"
output: "dist/index.html"
compressor: "html-minifier"
```

## License

MIT
19 changes: 12 additions & 7 deletions .github/actions/node-minify/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: "node-minify"
description: "Minify JavaScript, CSS, and HTML files with detailed reporting"
name: "node-minify (deprecated)"
description: "DEPRECATED: Use srod/node-minify@v1 instead. This composite action will be removed in a future release."
author: "srod"
branding:
icon: "minimize-2"
color: "green"
color: "gray"

inputs:
input:
Expand All @@ -20,7 +20,7 @@ inputs:
description: "Output file path"
required: true
type:
description: "File type: js or css (required for esbuild, lightningcss, yui)"
description: "File type: js or css (required for esbuild, yui)"
required: false
options:
description: "Compressor-specific options (JSON string)"
Expand Down Expand Up @@ -67,15 +67,18 @@ outputs:
runs:
using: "composite"
steps:
# Setup Java for gcc/yui compressors (auto-setup with default if java-version not specified)
- name: Deprecation warning
shell: bash
run: |
echo "::warning::This action (.github/actions/node-minify) is DEPRECATED. Please migrate to 'uses: srod/node-minify@v1' for the new bundled action with more features (PR comments, annotations, benchmarking)."

- name: Setup Java (for gcc/yui)
if: contains(fromJSON('["gcc", "google-closure-compiler", "yui"]'), inputs.compressor)
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: ${{ inputs.java-version || '17' }}

# Warn about deprecated yui compressor
- name: Deprecation warning (yui)
if: inputs.compressor == 'yui'
shell: bash
Expand Down Expand Up @@ -121,7 +124,7 @@ runs:
shell: bash
run: |
cat >> $GITHUB_STEP_SUMMARY << EOF
## 📦 node-minify Results
## node-minify Results

| Metric | Value |
|--------|-------|
Expand All @@ -134,4 +137,6 @@ runs:
| **Gzip Size** | ${{ steps.minify.outputs.gzip-size-formatted }} |
| **Time** | ${{ steps.minify.outputs.time-ms }}ms |

> **Note:** This action is deprecated. Please migrate to \`uses: srod/node-minify@v1\` for enhanced features.

EOF
67 changes: 5 additions & 62 deletions .github/actions/node-minify/minify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,65 +2,10 @@ import { appendFileSync, existsSync } from "node:fs";
import { stat } from "node:fs/promises";
import { resolve } from "node:path";
import { minify } from "@node-minify/core";
import { getFilesizeGzippedInBytes } from "@node-minify/utils";

const KNOWN_COMPRESSOR_EXPORTS: Record<string, string> = {
esbuild: "esbuild",
"google-closure-compiler": "gcc",
gcc: "gcc",
oxc: "oxc",
swc: "swc",
terser: "terser",
"uglify-js": "uglifyJs",
"babel-minify": "babelMinify",
"uglify-es": "uglifyEs",
yui: "yui",
"clean-css": "cleanCss",
cssnano: "cssnano",
csso: "csso",
lightningcss: "lightningCss",
crass: "crass",
sqwish: "sqwish",
"html-minifier": "htmlMinifier",
jsonminify: "jsonMinify",
imagemin: "imagemin",
sharp: "sharp",
svgo: "svgo",
"no-compress": "noCompress",
};

/**
* Resolves a compressor function from the @node-minify/{name} package and returns it with a label.
*
* @param name - Compressor package identifier (e.g., "terser", "esbuild"); used to import @node-minify/{name}
* @returns An object containing `compressor` (the resolved compressor function) and `label` (the provided name)
* @throws Error if the package does not export a usable compressor function
*/
async function resolveCompressor(
name: string
): Promise<{ compressor: unknown; label: string }> {
const packageName = `@node-minify/${name}`;
const mod = (await import(packageName)) as Record<string, unknown>;

const knownExport = KNOWN_COMPRESSOR_EXPORTS[name];
if (knownExport && typeof mod[knownExport] === "function") {
return { compressor: mod[knownExport], label: name };
}

if (typeof mod.default === "function") {
return { compressor: mod.default, label: name };
}

for (const value of Object.values(mod)) {
if (typeof value === "function") {
return { compressor: value, label: name };
}
}

throw new Error(
`Package '${packageName}' doesn't export a valid compressor function.`
);
}
import {
getFilesizeGzippedInBytes,
resolveCompressor,
} from "@node-minify/utils";

interface ActionResult {
originalSize: number;
Expand Down Expand Up @@ -164,9 +109,7 @@ async function run(): Promise<void> {

console.log(`Minifying ${inputFile} with ${label}...`);

const requiresType = ["esbuild", "lightningcss", "yui"].includes(
compressorName
);
const requiresType = ["esbuild", "yui"].includes(compressorName);
if (requiresType && !fileType) {
console.error(
`::error::Compressor '${compressorName}' requires the 'type' input (js or css)`
Expand Down
Loading