Skip to content

Commit 30551ce

Browse files
authored
Merge pull request #27 from withastro/version
Simplify inputs for v1
2 parents e3193ac + 73877f3 commit 30551ce

File tree

2 files changed

+23
-35
lines changed

2 files changed

+23
-35
lines changed

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ For more information, please see our complete deployment guide—[Deploy your As
1111
### Inputs
1212

1313
- `path` - Optional: the root location of your Astro project inside the repository.
14-
- `node-version` - Optional: the specific version of Node that should be used to build your site. Defaults to `16`.
15-
- `package-manager` - Optional: the Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. Accepted values: `npm`, `yarn`, `pnpm`, and `bun`.
16-
- `pnpm-version` - Optional: If `package-manager` is set to `pnpm`, use this specific version. Defaults to `7.x.x`.
17-
- `resolve-dep-from-path` - Optional: If the dependency file should be resolved from the root location of your Astro project. Defaults to `true`.
14+
- `node-version` - Optional: the specific version of Node that should be used to build your site. Defaults to `18`.
15+
- `package-manager` - Optional: the Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. Accepted values: `npm`, `yarn`, `pnpm`, and `bun`. A version tag is also accepted, for example `[email protected]`, `pnpm@8`, or `bun@latest`. If not provided, version will default to `latest`.
1816

1917
### Example workflow:
2018

@@ -46,13 +44,11 @@ jobs:
4644
- name: Checkout your repository using git
4745
uses: actions/checkout@v3
4846
- name: Install, build, and upload your site output
49-
uses: withastro/action@v0
47+
uses: withastro/action@v1
5048
# with:
5149
# path: . # The root location of your Astro project inside the repository. (optional)
52-
# node-version: 16 # The specific version of Node that should be used to build your site. Defaults to 16. (optional)
53-
# package-manager: pnpm # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
54-
# pnpm-version: 8.x.x # If `package-manager` is set to `pnpm`, use this specific version. Defaults to `7.x.x`. (optional)
55-
# resolve-dep-from-path: false # If the dependency file should be resolved from the root location of your Astro project. Defaults to `true`. (optional)
50+
# node-version: 18 # The specific version of Node that should be used to build your site. Defaults to 18. (optional)
51+
# package-manager: pnpm@latest # The Node package manager that should be used to install dependencies and build your site. Automatically detected based on your lockfile. (optional)
5652

5753
deploy:
5854
needs: build

action.yml

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,18 @@ branding:
44
icon: "box"
55
color: "orange"
66
inputs:
7-
path:
8-
description: "Path of the directory containing your site"
9-
required: false
10-
default: "."
117
node-version:
128
description: "The node version to use"
139
required: false
14-
default: "16"
10+
default: "18"
1511
package-manager:
16-
description: "If not automatically detectable, you may specify your preferred 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."
1713
required: false
1814
default: ""
19-
pnpm-version:
20-
description: "If package-manager is pnpm, use this specific version. Defaults to latest"
21-
required: false
22-
default: "7.x.x"
23-
resolve-dep-from-path:
24-
description: "If the dependency file is located inside the folder specified by path"
25-
type: boolean
15+
path:
16+
description: "Path of the directory containing your site"
2617
required: false
27-
default: true
18+
default: "."
2819

2920
runs:
3021
using: composite
@@ -36,51 +27,52 @@ runs:
3627
run: |
3728
len=`echo $INPUT_PM | wc -c`
3829
if [ $len -gt 1 ]; then
39-
echo "PACKAGE_MANAGER=$INPUT_PM" >> $GITHUB_ENV
30+
PACKAGE_MANAGER=$(echo "$INPUT_PM" | grep -o '^[^@]*')
31+
VERSION=$(echo "$INPUT_PM" | grep -o '@.*' | sed 's/^@//')
32+
# Set default VERSION if not provided
33+
if [ -z "$VERSION" ]; then
34+
VERSION="latest"
35+
fi
36+
echo "PACKAGE_MANAGER=$PACKAGE_MANAGER" >> $GITHUB_ENV
4037
elif [ $(find "." -name "pnpm-lock.yaml") ]; then
4138
echo "PACKAGE_MANAGER=pnpm" >> $GITHUB_ENV
4239
echo "LOCKFILE=pnpm-lock.yaml" >> $GITHUB_ENV
4340
elif [ $(find "." -name "yarn.lock") ]; then
4441
echo "PACKAGE_MANAGER=yarn" >> $GITHUB_ENV
4542
echo "LOCKFILE=yarn.lock" >> $GITHUB_ENV
4643
elif [ $(find "." -name "package-lock.json") ]; then
44+
VERSION="latest"
4745
echo "PACKAGE_MANAGER=npm" >> $GITHUB_ENV
4846
echo "LOCKFILE=package-lock.json" >> $GITHUB_ENV
4947
elif [ $(find "." -name "bun.lockb") ]; then
48+
VERSION="latest"
5049
echo "PACKAGE_MANAGER=bun" >> $GITHUB_ENV
5150
echo "LOCKFILE=bun.lockb" >> $GITHUB_ENV
5251
else
5352
echo "No lockfile found.
5453
Please specify your preferred \"package-manager\" in the action configuration."
5554
exit 1
5655
fi
56+
echo "VERSION=$VERSION" >> $GITHUB_ENV
5757
- name: Setup PNPM
5858
if: ${{ env.PACKAGE_MANAGER == 'pnpm' }}
59-
uses: pnpm/action-setup@v2.2.4
59+
uses: pnpm/action-setup@v2
6060
with:
61-
version: ${{ inputs.pnpm-version }}
61+
version: ${{ env.VERSION }}
6262

6363
- name: Setup Bun
6464
if: ${{ env.PACKAGE_MANAGER == 'bun' }}
6565
uses: oven-sh/setup-bun@v1
6666
with:
67-
bun-version: latest
67+
bun-version: ${{ env.VERSION }}
6868

6969
- name: Setup Node
7070
uses: actions/setup-node@v3
71-
if: inputs.resolve-dep-from-path == true
7271
with:
7372
node-version: ${{ inputs.node-version }}
7473
cache: ${{ env.PACKAGE_MANAGER }}
7574
cache-dependency-path: "${{ inputs.path }}/${{ env.LOCKFILE }}"
7675

77-
- name: Setup Node
78-
uses: actions/setup-node@v3
79-
if: inputs.resolve-dep-from-path == false
80-
with:
81-
node-version: ${{ inputs.node-version }}
82-
cache: ${{ env.PACKAGE_MANAGER }}
83-
8476
- name: Install
8577
shell: "bash"
8678
run: |

0 commit comments

Comments
 (0)