Skip to content

Commit 86db067

Browse files
committed
refactor: consolidate Linux build steps and add fail-fast default case
Collapse 8 per-target Linux build steps into 2 using contains(inputs.target, 'linux') with conditional TARGET_CFLAGS. Add a default case to the musl target detection to fail fast on unknown architectures.
1 parent ec767e6 commit 86db067

2 files changed

Lines changed: 7 additions & 62 deletions

File tree

.github/actions/build-upstream/action.yml

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -61,42 +61,14 @@ runs:
6161
6262
# NAPI builds - only run on cache miss (slow, especially on Windows)
6363
# Must run before vite-plus TypeScript builds which depend on the bindings
64-
- name: Build NAPI bindings (x86_64-linux)
64+
- name: Build NAPI bindings (Linux)
6565
shell: bash
66-
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'x86_64-unknown-linux-gnu'
66+
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'linux')
6767
run: |
6868
pnpm --filter=vite-plus build-native --target ${{ inputs.target }} --use-napi-cross
6969
env:
7070
TARGET_CC: clang
71-
DEBUG: napi:*
72-
73-
- name: Build NAPI bindings (aarch64-linux)
74-
shell: bash
75-
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'aarch64-unknown-linux-gnu'
76-
run: |
77-
pnpm --filter=vite-plus build-native --target ${{ inputs.target }} --use-napi-cross
78-
env:
79-
TARGET_CC: clang
80-
TARGET_CFLAGS: '-D_BSD_SOURCE'
81-
DEBUG: napi:*
82-
83-
- name: Build NAPI bindings (x86_64-linux-musl)
84-
shell: bash
85-
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'x86_64-unknown-linux-musl'
86-
run: |
87-
pnpm --filter=vite-plus build-native --target ${{ inputs.target }} --use-napi-cross
88-
env:
89-
TARGET_CC: clang
90-
DEBUG: napi:*
91-
92-
- name: Build NAPI bindings (aarch64-linux-musl)
93-
shell: bash
94-
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'aarch64-unknown-linux-musl'
95-
run: |
96-
pnpm --filter=vite-plus build-native --target ${{ inputs.target }} --use-napi-cross
97-
env:
98-
TARGET_CC: clang
99-
TARGET_CFLAGS: '-D_BSD_SOURCE'
71+
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
10072
DEBUG: napi:*
10173

10274
- name: Build NAPI bindings (non-Linux targets)
@@ -107,42 +79,14 @@ runs:
10779
env:
10880
DEBUG: napi:*
10981

110-
- name: Build Rust CLI binary (x86_64-linux)
111-
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'x86_64-unknown-linux-gnu'
112-
shell: bash
113-
run: |
114-
pnpm exec napi build --use-napi-cross --target ${{ inputs.target }} --release -p vite_global_cli
115-
env:
116-
TARGET_CC: clang
117-
DEBUG: napi:*
118-
119-
- name: Build Rust CLI binary (aarch64-linux)
120-
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'aarch64-unknown-linux-gnu'
121-
shell: bash
122-
run: |
123-
pnpm exec napi build --use-napi-cross --target ${{ inputs.target }} --release -p vite_global_cli
124-
env:
125-
TARGET_CC: clang
126-
TARGET_CFLAGS: '-D_BSD_SOURCE'
127-
DEBUG: napi:*
128-
129-
- name: Build Rust CLI binary (x86_64-linux-musl)
130-
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'x86_64-unknown-linux-musl'
131-
shell: bash
132-
run: |
133-
pnpm exec napi build --use-napi-cross --target ${{ inputs.target }} --release -p vite_global_cli
134-
env:
135-
TARGET_CC: clang
136-
DEBUG: napi:*
137-
138-
- name: Build Rust CLI binary (aarch64-linux-musl)
139-
if: steps.cache-restore.outputs.cache-hit != 'true' && inputs.target == 'aarch64-unknown-linux-musl'
82+
- name: Build Rust CLI binary (Linux)
83+
if: steps.cache-restore.outputs.cache-hit != 'true' && contains(inputs.target, 'linux')
14084
shell: bash
14185
run: |
14286
pnpm exec napi build --use-napi-cross --target ${{ inputs.target }} --release -p vite_global_cli
14387
env:
14488
TARGET_CC: clang
145-
TARGET_CFLAGS: '-D_BSD_SOURCE'
89+
TARGET_CFLAGS: ${{ contains(inputs.target, 'aarch64') && '-D_BSD_SOURCE' || '' }}
14690
DEBUG: napi:*
14791

14892
- name: Build Rust CLI binary (non-Linux targets)

.github/actions/download-rolldown-binaries/action.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ runs:
2828
case "${{ inputs.target }}" in
2929
x86_64*) export TARGET="linux-x64-musl" ;;
3030
aarch64*) export TARGET="linux-arm64-musl" ;;
31+
*) echo "Unknown musl target: ${{ inputs.target }}"; exit 1 ;;
3132
esac
3233
else
3334
export TARGET="linux-x64-gnu"

0 commit comments

Comments
 (0)