Skip to content

Commit 5b97650

Browse files
committed
refactor: simplify Deno support to match other package managers
- deno now follows the same pattern as npm/yarn/pnpm/bun - unified install step handles all package managers - support npm dependencies in hybrid Deno projects via deno install - use package-manager input for Deno version (e.g., [email protected])
1 parent ecde5fe commit 5b97650

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

action.yml

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,13 @@ inputs:
99
required: false
1010
default: "22"
1111
package-manager:
12-
description: "You may specify your preferred package manager (one of `npm | yarn | pnpm | bun` and an optional `@<version>` tag). Otherwise, the package manager will be automatically detected."
12+
description: "You may specify your preferred package manager (one of `npm | yarn | pnpm | bun | deno` and an optional `@<version>` tag). Otherwise, the package manager will be automatically detected."
1313
required: false
1414
default: ""
1515
path:
1616
description: "Path of the directory containing your site"
1717
required: false
1818
default: "."
19-
deno-version:
20-
description: "The Deno version to use when deno.json/deno.jsonc/deno.lock exists"
21-
required: false
22-
default: "1.x"
23-
deno-setup-task:
24-
description: "Name of the optional Deno task to run before build (will be skipped if undefined)"
25-
required: false
26-
default: "setup"
2719

2820
runs:
2921
using: composite
@@ -40,9 +32,17 @@ runs:
4032
VERSION=$(echo "$INPUT_PM" | { grep -o '@.*' || true; } | sed 's/^@//')
4133
# Set default VERSION if not provided
4234
if [ -z "$VERSION" ]; then
43-
VERSION="latest"
35+
if [ "$PACKAGE_MANAGER" = "deno" ]; then
36+
VERSION="1.x"
37+
else
38+
VERSION="latest"
39+
fi
4440
fi
4541
echo "PACKAGE_MANAGER=$PACKAGE_MANAGER" >> $GITHUB_ENV
42+
# Set lockfile for deno when explicitly specified
43+
if [ "$PACKAGE_MANAGER" = "deno" ]; then
44+
echo "LOCKFILE=deno.lock" >> $GITHUB_ENV
45+
fi
4646
elif [ $(find "." -maxdepth 1 -name "pnpm-lock.yaml") ]; then
4747
echo "PACKAGE_MANAGER=pnpm" >> $GITHUB_ENV
4848
echo "LOCKFILE=pnpm-lock.yaml" >> $GITHUB_ENV
@@ -62,9 +62,9 @@ runs:
6262
echo "PACKAGE_MANAGER=bun" >> $GITHUB_ENV
6363
echo "LOCKFILE=bun.lockb" >> $GITHUB_ENV
6464
elif [ -f "deno.json" ] || [ -f "deno.jsonc" ] || [ -f "deno.lock" ]; then
65-
VERSION="${{ inputs.deno-version }}"
65+
VERSION="1.x"
6666
echo "PACKAGE_MANAGER=deno" >> $GITHUB_ENV
67-
echo "LOCKFILE=deno.lock" >> $GITHUB_ENV
67+
echo "LOCKFILE=deno.lock" >> $GITHUB_ENV
6868
else
6969
echo "No lockfile found.
7070
Please specify your preferred \"package-manager\" in the action configuration."
@@ -104,17 +104,25 @@ runs:
104104
with:
105105
node-version: ${{ inputs.node-version }}
106106

107-
- name: Install (npm/yarn/pnpm)
108-
if: ${{ env.PACKAGE_MANAGER != 'deno' }}
109-
shell: bash
110-
working-directory: ${{ inputs.path }}
111-
run: $PACKAGE_MANAGER install
112-
113-
- name: Cache deps & vendor (Deno)
114-
if: ${{ env.PACKAGE_MANAGER == 'deno' }}
107+
- name: Install
115108
shell: bash
116109
working-directory: ${{ inputs.path }}
117-
run: deno task ${{ inputs.deno-setup-task }} || echo "No deno ${{ inputs.deno-setup-task }} task defined - skipping"
110+
run: |
111+
if [ "$PACKAGE_MANAGER" = "deno" ]; then
112+
# For Deno projects with deno.json, cache dependencies
113+
if [ -f "deno.json" ] || [ -f "deno.jsonc" ]; then
114+
echo "Caching Deno dependencies..."
115+
deno cache --lock=deno.lock --lock-write **/*.ts **/*.tsx 2>/dev/null || true
116+
fi
117+
# For hybrid projects with package.json, install npm dependencies
118+
if [ -f "package.json" ]; then
119+
echo "Installing npm dependencies with Deno..."
120+
deno install --allow-scripts
121+
fi
122+
else
123+
# Standard package manager install
124+
$PACKAGE_MANAGER install
125+
fi
118126
119127
- name: Build (npm/yarn/pnpm/bun)
120128
if: ${{ env.PACKAGE_MANAGER != 'deno' }}
@@ -127,3 +135,8 @@ runs:
127135
shell: bash
128136
working-directory: ${{ inputs.path }}
129137
run: deno task build
138+
139+
- name: Upload Pages Artifact
140+
uses: actions/upload-pages-artifact@v3
141+
with:
142+
path: "${{ inputs.path }}/dist/"

0 commit comments

Comments
 (0)