|
1 | | -name: determine-node-versions |
2 | | -description: Calculate Node and Node-1 versions for unit tests |
3 | | - |
| 1 | +name: Determine node versions |
| 2 | +description: "Get all the supported node versions" |
4 | 3 | inputs: |
5 | 4 | nodeVersionOverride: |
6 | | - description: Semver version to set version and version-1 |
7 | | - required: false |
8 | | - nodeDisableCurrent: |
9 | | - description: Disable testing on Node "current" |
| 5 | + description: Set node to a specific Semver version |
10 | 6 | required: false |
11 | | - nodeDisablePrevious: |
12 | | - description: Disable testing on Node "-1" |
| 7 | + nodeDisableVersions: |
| 8 | + description: A string of major version(s) to disable (18 or 18,23) |
13 | 9 | required: false |
14 | | - |
15 | 10 | outputs: |
16 | 11 | nodeVersions: |
17 | 12 | description: Node versions to be consumed by a workflow matrix |
18 | 13 | value: ${{ steps.node-versions.outputs.nodeVersions }} |
19 | | - |
20 | | -# Sample output looks like this: |
21 | | -# |
22 | | -# nodeVersions<<EOF |
23 | | -# [ |
24 | | -# "current", |
25 | | -# "lts/*", |
26 | | -# "lts/-1", |
27 | | -# ] |
28 | | -# EOF |
29 | | -# |
30 | | -# OR... |
31 | | -# |
32 | | -# nodeVersions<<EOF |
33 | | -# [ |
34 | | -# "18.15.0", |
35 | | -# "16" |
36 | | -# ] |
37 | | -# EOF |
38 | | - |
39 | 14 | runs: |
40 | | - using: composite |
| 15 | + using: 'composite' |
41 | 16 | steps: |
42 | | - - name: Determine node versions |
| 17 | + # Note: this is not typically how you would run javascript in an action |
| 18 | + # This is need so that we can get the correct node version used elsewhere |
| 19 | + - name: Set up Node |
| 20 | + uses: actions/setup-node@v4 |
| 21 | + with: |
| 22 | + node-version: ${{ inputs.nodeVersionOverride || 'lts/*' }} |
| 23 | + - name: Run main script |
43 | 24 | shell: bash |
44 | 25 | id: node-versions |
45 | | - run: | |
46 | | - # Current can be disabled by setting the "nodeDisableCurrent" input to "true" |
47 | | - # Previous LTS can be disabled by setting the "nodeDisablePrevious" input to "true" |
48 | | - # IF "NODE_VERSION" is overridden, "NODE_VERSION_CURRENT" will also be disabled |
49 | | -
|
50 | | - NODE_VERSION_CURRENT="current" |
51 | | - if [ "$INPUTS_NODE_DISABLE_CURRENT" = "true" ] || [ -n "$INPUTS_NODE_VERSION_OVERRIDE" ]; then |
52 | | - NODE_VERSION_CURRENT="" |
53 | | - fi |
54 | | -
|
55 | | - NODE_VERSION="lts/*" |
56 | | - if [ -n "$INPUTS_NODE_VERSION_OVERRIDE" ]; then |
57 | | - NODE_VERSION="$INPUTS_NODE_VERSION_OVERRIDE" |
58 | | - fi |
59 | | -
|
60 | | - NODE_PREVIOUS_LTS="lts/-1" |
61 | | - if [ "$INPUTS_NODE_DISABLE_PREVIOUS" = "true" ]; then |
62 | | - NODE_PREVIOUS_LTS="" |
63 | | - fi |
64 | | -
|
65 | | - if [ -n "$INPUTS_NODE_VERSION_OVERRIDE" ] && [ "$INPUTS_NODE_DISABLE_PREVIOUS" != "true" ] ; then |
66 | | - NODE_VERSION_MAJOR=$(echo "$INPUTS_NODE_VERSION_OVERRIDE" | cut -d '.' -f 1) |
67 | | -
|
68 | | - # LTS-1 will always be the previous LTS, which is always even. Here we calculate the nearest LTS |
69 | | - if [ $((NODE_VERSION_MAJOR % 2)) = 0 ]; then |
70 | | - NODE_PREVIOUS_LTS="$((NODE_VERSION_MAJOR - 2))" |
71 | | - else |
72 | | - NODE_PREVIOUS_LTS="$((NODE_VERSION_MAJOR - 1))" |
73 | | - fi |
74 | | - fi |
75 | | -
|
76 | | - { |
77 | | - echo "nodeVersions<<EOF" |
78 | | - jq -n --arg v1 "$NODE_VERSION_CURRENT" --arg v2 "$NODE_VERSION" --arg v3 "$NODE_PREVIOUS_LTS" '[$v1, $v2, $v3] | map(select(. != ""))' |
79 | | - echo "EOF" |
80 | | - } >> "$GITHUB_OUTPUT" |
| 26 | + run: node "$GITHUB_ACTION_PATH/dist/index.js" |
81 | 27 | env: |
82 | | - INPUTS_NODE_VERSION_OVERRIDE: ${{ inputs.nodeVersionOverride }} |
83 | | - INPUTS_NODE_DISABLE_CURRENT: ${{ inputs.nodeDisableCurrent }} |
84 | | - INPUTS_NODE_DISABLE_PREVIOUS: ${{ inputs.nodeDisablePrevious }} |
| 28 | + NODE_DISABLE_VERSIONS: ${{ inputs.nodeDisableVersions }} |
| 29 | + |
0 commit comments