Skip to content

Commit

Permalink
fix: setup node support macos 14 in arm64
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed May 8, 2024
1 parent c68dde8 commit 93d491d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/node-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ jobs:
steps:
# Checkout action repository
- name: Checkout action repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: node-modules/github-actions
path: action_repo
ref: ${{ inputs.action_ref }}

# Checkout project repository
- name: Checkout project repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: main_repo
token: ${{ secrets.GIT_TOKEN }}

# Setup Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4

# Install action dependencies
- name: Install action dependencies
Expand Down
29 changes: 23 additions & 6 deletions .github/workflows/node-test-mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:

version:
type: string
description: 'Node.js Version, such as 16, 18'
default: '16, 18'
description: 'Node.js Version, such as 16, 18, 20, 22'
default: '16, 18, 20, 22'

install:
type: string
Expand Down Expand Up @@ -39,15 +39,15 @@ jobs:
steps:
# Checkout action repository
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: node-modules/github-actions
path: action_repo
ref: ${{ inputs.action_ref }}

# Setup Node.js environment
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4

# Install dependencies
- name: Install dependencies
Expand Down Expand Up @@ -98,12 +98,29 @@ jobs:

steps:
- name: Checkout Git Source
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Calculate Architecture
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const osVersion = '${{ matrix.os }}';
const nodeVersion = '${{ matrix['node-version'] }}';
const isMacOS = osVersion === 'macos-latest' || osVersion.startsWith('macos');
const isMajor14 = nodeVersion === '14' || nodeVersion.startsWith('14.');
if (isMacOS && isMajor14) {
return 'x64';
} else {
return '';
}
- name: Use Node.js ${{ matrix.version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
architecture: ${{ steps.calculate_architecture.outputs.result }}
check-latest: true

- name: Install Dependencies
run: ${{ inputs.install }}
Expand Down
20 changes: 18 additions & 2 deletions .github/workflows/node-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ on:

version:
type: string
description: 'Node.js Version, such as 16, 18, 20'
default: '16, 18, 20'
description: 'Node.js Version, such as 16, 18, 20, 22'
default: '16, 18, 20, 22'

install:
type: string
Expand Down Expand Up @@ -75,10 +75,26 @@ jobs:
- name: Checkout Git Source
uses: actions/checkout@v4

- name: Calculate Architecture
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const osVersion = '${{ matrix.os }}';
const nodeVersion = '${{ matrix['node-version'] }}';
const isMacOS = osVersion === 'macos-latest' || osVersion.startsWith('macos');
const isMajor14 = nodeVersion === '14' || nodeVersion.startsWith('14.');
if (isMacOS && isMajor14) {
return 'x64';
} else {
return '';
}
- name: Use Node.js ${{ matrix.version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.version }}
architecture: ${{ steps.calculate_architecture.outputs.result }}
check-latest: true

- name: Install Dependencies
Expand Down

0 comments on commit 93d491d

Please sign in to comment.