Skip to content

Commit 4ca7cad

Browse files
committed
fix: windows artifact path issue
1 parent 18c759e commit 4ca7cad

File tree

2 files changed

+56
-47
lines changed

2 files changed

+56
-47
lines changed

.github/workflows/actions/download-archive/action.yml

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ inputs:
2525
runs:
2626
using: 'composite'
2727
steps:
28+
# Check if this is a rerun of a previous workflow run
29+
- name: 🔄 Check for Rerun
30+
id: check-rerun
31+
shell: bash
32+
run: |
33+
if [ "${{ github.run_attempt }}" -gt 1 ]; then
34+
echo "rerun_suffix=-rerun${{ github.run_attempt }}" >> $GITHUB_OUTPUT
35+
else
36+
echo "rerun_suffix=" >> $GITHUB_OUTPUT
37+
fi
38+
2839
# Generate standard cache keys
2940
- name: 🔑 Generate Cache Keys
3041
id: generate-keys
@@ -35,17 +46,22 @@ runs:
3546
NAME="${{ inputs.name }}"
3647
OS="${{ runner.os }}"
3748
RUN_ID="${{ github.run_id }}"
49+
RERUN_SUFFIX="${{ steps.check-rerun.outputs.rerun_suffix }}"
50+
51+
# Generate platform-specific key (no cross-platform sharing to avoid path issues)
52+
PLATFORM_KEY="${OS}-${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX}"
53+
echo "platform_key=${PLATFORM_KEY}" >> $GITHUB_OUTPUT
3854
39-
# Generate standard key (os-specific)
40-
STANDARD_KEY="${OS}-${CACHE_PREFIX}-${NAME}-${RUN_ID}"
55+
# Generate standard key (os-specific) for backward compatibility
56+
STANDARD_KEY="${OS}-${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX}"
4157
echo "standard_key=${STANDARD_KEY}" >> $GITHUB_OUTPUT
4258
4359
# Generate OS-agnostic key
44-
AGNOSTIC_KEY="${CACHE_PREFIX}-${NAME}-${RUN_ID}"
60+
AGNOSTIC_KEY="${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX}"
4561
echo "agnostic_key=${AGNOSTIC_KEY}" >> $GITHUB_OUTPUT
4662
4763
# Generate Linux-specific key for cross-OS compatibility
48-
LINUX_KEY="Linux-${CACHE_PREFIX}-${NAME}-${RUN_ID}"
64+
LINUX_KEY="Linux-${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX}"
4965
echo "linux_key=${LINUX_KEY}" >> $GITHUB_OUTPUT
5066
5167
# Generate pattern keys
@@ -80,38 +96,24 @@ runs:
8096
lookup-only: false
8197
fail-on-cache-miss: false
8298

83-
# Restore with standard key (os-specific)
84-
- name: 🗄️ Restore with Standard Key
85-
id: cache-restore-standard
99+
# Restore with platform-specific key
100+
- name: 🗄️ Restore with Platform-Specific Key
101+
id: cache-restore-platform
86102
if: steps.cache-restore-exact.outputs.cache-hit != 'true'
87103
uses: actions/cache/restore@v4
88104
env:
89105
ACTIONS_CACHE_SERVICE_V2: 'true'
90106
with:
91107
path: ${{ steps.normalize-path.outputs.normalized_path }}
92-
key: ${{ steps.generate-keys.outputs.standard_key }}
93-
enableCrossOsArchive: true
94-
lookup-only: false
95-
fail-on-cache-miss: false
96-
97-
# Restore with OS-agnostic key
98-
- name: 🗄️ Restore with OS-Agnostic Key
99-
id: cache-restore-agnostic
100-
if: steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-standard.outputs.cache-hit != 'true'
101-
uses: actions/cache/restore@v4
102-
env:
103-
ACTIONS_CACHE_SERVICE_V2: 'true'
104-
with:
105-
path: ${{ steps.normalize-path.outputs.normalized_path }}
106-
key: ${{ steps.generate-keys.outputs.agnostic_key }}
108+
key: ${{ steps.generate-keys.outputs.platform_key }}
107109
enableCrossOsArchive: true
108110
lookup-only: false
109111
fail-on-cache-miss: false
110112

111113
# Restore with Linux key for cross-OS compatibility
112114
- name: 🗄️ Restore with Linux Key
113115
id: cache-restore-linux
114-
if: steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-standard.outputs.cache-hit != 'true' && steps.cache-restore-agnostic.outputs.cache-hit != 'true' && runner.os != 'Linux'
116+
if: steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-platform.outputs.cache-hit != 'true' && runner.os != 'Linux'
115117
uses: actions/cache/restore@v4
116118
env:
117119
ACTIONS_CACHE_SERVICE_V2: 'true'
@@ -125,7 +127,7 @@ runs:
125127
# Try OS-specific pattern as fallback (finds latest matching cache)
126128
- name: 🗄️ Restore with Pattern
127129
id: cache-restore-pattern
128-
if: steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-standard.outputs.cache-hit != 'true' && steps.cache-restore-agnostic.outputs.cache-hit != 'true' && steps.cache-restore-linux.outputs.cache-hit != 'true'
130+
if: steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-platform.outputs.cache-hit != 'true' && steps.cache-restore-linux.outputs.cache-hit != 'true'
129131
uses: actions/cache/restore@v4
130132
env:
131133
ACTIONS_CACHE_SERVICE_V2: 'true'
@@ -140,7 +142,7 @@ runs:
140142

141143
# Handle cache miss
142144
- name: ⚠️ Handle Cache Miss
143-
if: steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-standard.outputs.cache-hit != 'true' && steps.cache-restore-agnostic.outputs.cache-hit != 'true' && steps.cache-restore-linux.outputs.cache-hit != 'true' && steps.cache-restore-pattern.outputs.cache-hit != 'true'
145+
if: steps.cache-restore-exact.outputs.cache-hit != 'true' && steps.cache-restore-platform.outputs.cache-hit != 'true' && steps.cache-restore-linux.outputs.cache-hit != 'true' && steps.cache-restore-pattern.outputs.cache-hit != 'true'
144146
shell: bash
145147
run: |
146148
if [ -n "${{ inputs.use_cache }}" ] && [ "${{ inputs.use_cache }}" = "true-only" ]; then
@@ -160,10 +162,8 @@ runs:
160162
# Summary of what method was used to get the file (for debugging)
161163
if [ "${{ steps.cache-restore-exact.outputs.cache-hit }}" == "true" ]; then
162164
SOURCE="exact key cache"
163-
elif [ "${{ steps.cache-restore-standard.outputs.cache-hit }}" == "true" ]; then
164-
SOURCE="standard key cache"
165-
elif [ "${{ steps.cache-restore-agnostic.outputs.cache-hit }}" == "true" ]; then
166-
SOURCE="OS-agnostic key cache"
165+
elif [ "${{ steps.cache-restore-platform.outputs.cache-hit }}" == "true" ]; then
166+
SOURCE="platform-specific key cache"
167167
elif [ "${{ steps.cache-restore-linux.outputs.cache-hit }}" == "true" ]; then
168168
SOURCE="Linux key cache"
169169
elif [ "${{ steps.cache-restore-pattern.outputs.cache-hit }}" == "true" ]; then

.github/workflows/actions/upload-archive/action.yml

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,24 @@ runs:
120120
}
121121
}
122122
123-
# Compress directories preserving structure
124-
# Use paths directly instead of individual files to maintain directory hierarchy
123+
# Compress directories preserving structure using 7zip for cross-platform compatibility
124+
# 7zip creates ZIP files with forward slashes, avoiding Windows path separator issues
125125
try {
126126
if ($paths.Count -gt 0) {
127-
Compress-Archive -Path $paths -DestinationPath "${{ inputs.output }}" -Force -ErrorAction Stop
127+
# Install 7zip if not available
128+
if (!(Get-Command "7z" -ErrorAction SilentlyContinue)) {
129+
Write-Host "Installing 7zip for cross-platform ZIP creation..."
130+
choco install 7zip -y --no-progress
131+
}
132+
133+
# Use 7zip for cross-platform compatible ZIP creation
134+
$7zArgs = @("a", "-tzip", "${{ inputs.output }}")
135+
$7zArgs += $paths
136+
137+
& 7z @7zArgs
138+
if ($LASTEXITCODE -ne 0) {
139+
throw "7zip failed with exit code $LASTEXITCODE"
140+
}
128141
} else {
129142
# Create empty archive if no paths found
130143
Compress-Archive -Path @() -DestinationPath "${{ inputs.output }}" -Force -ErrorAction Stop
@@ -155,7 +168,7 @@ runs:
155168
156169
# Get archive size for reporting
157170
$fileSize = (Get-Item "${{ inputs.output }}").Length
158-
$humanSize = if ($fileSize -lt 1KB) { "$fileSize B" }
171+
$humanSize = if ($fileSize -lt 1KB) { "$fileSize B" }
159172
elseif ($fileSize -lt 1MB) { "{0:N1} KB" -f ($fileSize / 1KB) }
160173
elseif ($fileSize -lt 1GB) { "{0:N1} MB" -f ($fileSize / 1MB) }
161174
else { "{0:N1} GB" -f ($fileSize / 1GB) }
@@ -189,7 +202,11 @@ runs:
189202
RUN_ID="${{ github.run_id }}"
190203
RERUN_SUFFIX="${{ steps.check-rerun.outputs.rerun_suffix }}"
191204
192-
# Generate standard key (OS specific)
205+
# Generate platform-specific key (no cross-platform sharing to avoid path issues)
206+
PLATFORM_KEY="${OS}-${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX}"
207+
echo "platform_key=${PLATFORM_KEY}" >> $GITHUB_OUTPUT
208+
209+
# Keep standard key for backward compatibility
193210
STANDARD_KEY="${OS}-${CACHE_PREFIX}-${NAME}-${RUN_ID}${RERUN_SUFFIX}"
194211
echo "standard_key=${STANDARD_KEY}" >> $GITHUB_OUTPUT
195212
@@ -206,22 +223,14 @@ runs:
206223
retention-days: ${{ inputs.retention_days }}
207224
if-no-files-found: error
208225

209-
# Cache with OS-specific key
210-
- name: 🗄️ Cache Artifact (OS-specific)
211-
uses: actions/cache/save@v4
212-
env:
213-
ACTIONS_CACHE_SERVICE_V2: 'true'
214-
with:
215-
path: ${{ inputs.output }}
216-
key: ${{ steps.generate-keys.outputs.standard_key }}
217-
enableCrossOsArchive: true
218-
219-
# Cache with OS-agnostic key
220-
- name: 🗄️ Cache Artifact (OS-agnostic)
226+
# Cache with platform-specific key
227+
# Cross-platform archive enabled - works for TypeScript packages (wdio-electron-build)
228+
# Tauri apps use 7zip for cross-platform compatible ZIPs
229+
- name: 🗄️ Cache Artifact (Platform-specific)
221230
uses: actions/cache/save@v4
222231
env:
223232
ACTIONS_CACHE_SERVICE_V2: 'true'
224233
with:
225234
path: ${{ inputs.output }}
226-
key: ${{ steps.generate-keys.outputs.agnostic_key }}
235+
key: ${{ steps.generate-keys.outputs.platform_key }}
227236
enableCrossOsArchive: true

0 commit comments

Comments
 (0)