-
Notifications
You must be signed in to change notification settings - Fork 232
Expand file tree
/
Copy pathaction.yml
More file actions
104 lines (93 loc) · 4.22 KB
/
Copy pathaction.yml
File metadata and controls
104 lines (93 loc) · 4.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: 'Build Windows CLI binaries'
description: >-
Cross-compile the Windows release NAPI binding and vp/vp-shim/vp-setup
binaries on Linux with cargo-xwin, cache them by source hash, and upload
them as an artifact for Windows jobs to consume (with build-upstream's
skip-native input). Run on a Linux runner after checkout + clone.
inputs:
save-cache:
description: "Whether setup-xwin's setup-rust should save its cache (usually only on main)."
required: false
default: 'false'
artifact-name:
description: 'Name for the uploaded binaries artifact.'
required: false
default: 'windows-cli-binaries'
runs:
using: 'composite'
steps:
# The shared action is the single source of truth for inputs that affect
# the native binaries and generated bindings.
- uses: ./.github/actions/compute-native-cache-input-hash
id: native-cache-inputs
# Use a distinct prefix: this cache stores Linux-relative paths and must
# never mix with the caches build-upstream saves on other runners. Sharing
# this one key across ci.yml and e2e-test.yml lets whichever workflow builds
# first serve the other.
- name: Compute binaries cache key
id: cache-key
shell: bash
run: |
echo "key=windows-cli-xwin-v1-${{ steps.native-cache-inputs.outputs.hash }}" >> "$GITHUB_OUTPUT"
- name: Define binary paths
id: binary-paths
shell: bash
run: |
{
echo 'paths<<EOF'
echo 'packages/cli/binding/*.node'
echo 'target/x86_64-pc-windows-msvc/release/vp.exe'
echo 'target/x86_64-pc-windows-msvc/release/vp-shim.exe'
echo 'target/x86_64-pc-windows-msvc/release/vp-setup.exe'
echo 'EOF'
} >> "$GITHUB_OUTPUT"
- name: Restore binaries cache
id: binaries-cache
uses: actions/cache/restore@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
with:
path: ${{ steps.binary-paths.outputs.paths }}
key: ${{ steps.cache-key.outputs.key }}
- uses: ./.github/actions/setup-xwin
if: steps.binaries-cache.outputs.cache-hit != 'true'
with:
save-cache: ${{ inputs.save-cache }}
cache-key: windows-cli-cross
- uses: oxc-project/setup-node@4c588e9266bd930b6ddc34307df0659ed511d187 # v1.3.1
if: steps.binaries-cache.outputs.cache-hit != 'true'
# --skip-format: formatting the generated index.cjs/index.d.cts needs the
# repo vite config, which imports the not-yet-built vite-plus dist; this
# action skips the TS builds on purpose.
- name: Build NAPI binding
if: steps.binaries-cache.outputs.cache-hit != 'true'
shell: bash
run: pnpm --filter=vite-plus build-native --target x86_64-pc-windows-msvc -x --skip-format
env:
DEBUG: 'napi:*'
XWIN_ACCEPT_LICENSE: '1'
# See setup-xwin / build-windows-tests for why this Detours escape
# hatch is needed.
CXXFLAGS: -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH
- name: Build Rust CLI binaries
if: steps.binaries-cache.outputs.cache-hit != 'true'
shell: bash
run: cargo xwin build --release --target x86_64-pc-windows-msvc -p vite_global_cli -p vite_trampoline -p vite_installer
env:
XWIN_ACCEPT_LICENSE: '1'
CXXFLAGS: -D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH
- uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: ${{ inputs.artifact-name }}
# Both path roots are workspace-relative, so the artifact preserves the
# repo layout and a plain download into the workspace places every file
# where tool install-global-cli expects it. The generated binding JS
# (index.cjs etc.) is NOT included: those files are committed, and the
# unformatted copies this action produces (--skip-format) must not
# overwrite them in consumer checkouts (vp check would flag them).
path: ${{ steps.binary-paths.outputs.paths }}
if-no-files-found: error
retention-days: 7
- uses: actions/cache/save@caa296126883cff596d87d8935842f9db880ef25 # v5.1.0
if: steps.binaries-cache.outputs.cache-hit != 'true'
with:
path: ${{ steps.binary-paths.outputs.paths }}
key: ${{ steps.cache-key.outputs.key }}