Skip to content

Commit e8cea0c

Browse files
jp-knjdelucisjp-knjFryuni
authored
Support Deno (#77)
Co-authored-by: Chris Swithinbank <[email protected]> Co-authored-by: jp-knj <[email protected]> Co-authored-by: Fryuni <[email protected]>
1 parent 77fad83 commit e8cea0c

File tree

1 file changed

+44
-7
lines changed

1 file changed

+44
-7
lines changed

action.yml

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ 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:
@@ -32,7 +32,12 @@ runs:
3232
VERSION=$(echo "$INPUT_PM" | { grep -o '@.*' || true; } | sed 's/^@//')
3333
# Set default VERSION if not provided
3434
if [ -z "$VERSION" ]; then
35-
VERSION="latest"
35+
if [ "$PACKAGE_MANAGER" = "deno" ]; then
36+
# The denoland/setup-deno action equivalent of "latest"
37+
VERSION="vx.x.x"
38+
else
39+
VERSION="latest"
40+
fi
3641
fi
3742
echo "PACKAGE_MANAGER=$PACKAGE_MANAGER" >> $GITHUB_ENV
3843
elif [ $(find "." -maxdepth 1 -name "pnpm-lock.yaml") ]; then
@@ -59,6 +64,10 @@ runs:
5964
VERSION="latest"
6065
echo "PACKAGE_MANAGER=bun" >> $GITHUB_ENV
6166
echo "LOCKFILE=bun.lockb" >> $GITHUB_ENV
67+
elif [ -f "deno.json" ] || [ -f "deno.jsonc" ] || [ -f "deno.lock" ]; then
68+
VERSION="vx.x.x"
69+
echo "PACKAGE_MANAGER=deno" >> $GITHUB_ENV
70+
echo "LOCKFILE=deno.lock" >> $GITHUB_ENV
6271
else
6372
echo "No lockfile found.
6473
Please specify your preferred \"package-manager\" in the action configuration."
@@ -78,9 +87,15 @@ runs:
7887
with:
7988
bun-version: ${{ env.VERSION }}
8089

90+
- name: Setup Deno
91+
if: ${{ env.PACKAGE_MANAGER == 'deno' }}
92+
uses: denoland/setup-deno@v2
93+
with:
94+
deno-version: ${{ env.VERSION }}
95+
8196
- name: Setup Node
8297
uses: actions/setup-node@v4
83-
if: ${{ env.PACKAGE_MANAGER != 'bun' }}
98+
if: ${{ env.PACKAGE_MANAGER != 'bun' && env.PACKAGE_MANAGER != 'deno' }}
8499
with:
85100
node-version: ${{ inputs.node-version }}
86101
cache: ${{ env.PACKAGE_MANAGER }}
@@ -93,15 +108,37 @@ runs:
93108
node-version: ${{ inputs.node-version }}
94109

95110
- name: Install
96-
shell: "bash"
111+
shell: bash
97112
working-directory: ${{ inputs.path }}
98-
run: $PACKAGE_MANAGER install
113+
run: |
114+
if [ "$PACKAGE_MANAGER" = "deno" ]; then
115+
# For Deno projects with deno.json, cache dependencies
116+
if [ -f "deno.json" ] || [ -f "deno.jsonc" ]; then
117+
echo "Caching Deno dependencies..."
118+
deno cache --lock=deno.lock --lock-write **/*.ts **/*.tsx 2>/dev/null || true
119+
fi
120+
# For hybrid projects with package.json, install npm dependencies
121+
if [ -f "package.json" ]; then
122+
echo "Installing npm dependencies with Deno..."
123+
deno install --allow-scripts
124+
fi
125+
else
126+
# Standard package manager install
127+
$PACKAGE_MANAGER install
128+
fi
99129
100-
- name: Build
101-
shell: "bash"
130+
- name: Build (npm/yarn/pnpm/bun)
131+
if: ${{ env.PACKAGE_MANAGER != 'deno' }}
132+
shell: bash
102133
working-directory: ${{ inputs.path }}
103134
run: $PACKAGE_MANAGER run build
104135

136+
- name: Build (Deno)
137+
if: ${{ env.PACKAGE_MANAGER == 'deno' }}
138+
shell: bash
139+
working-directory: ${{ inputs.path }}
140+
run: deno task build
141+
105142
- name: Upload Pages Artifact
106143
uses: actions/upload-pages-artifact@v3
107144
with:

0 commit comments

Comments
 (0)