@@ -3,17 +3,17 @@ name: Build
33on :
44 push :
55 tags :
6- - " v* "
6+ - ' v* '
77 paths-ignore :
8- - " **.md"
9- - " **.spec.js"
10- - " .idea"
11- - " .vscode"
12- - " .dockerignore"
13- - " Dockerfile"
14- - " .gitignore"
15- - " .github/**"
16- - " !.github/workflows/build.yml"
8+ - ' **.md'
9+ - ' **.spec.js'
10+ - ' .idea'
11+ - ' .vscode'
12+ - ' .dockerignore'
13+ - ' Dockerfile'
14+ - ' .gitignore'
15+ - ' .github/**'
16+ - ' !.github/workflows/build.yml'
1717
1818permissions :
1919 contents : write
@@ -260,3 +260,198 @@ jobs:
260260 release/mac-arm64/*
261261 release/win-x64/*
262262 release/linux-x64/*
263+
264+ # Extract version from tag (e.g., v0.0.82 -> 0.0.82)
265+ - name : Extract version
266+ if : startsWith(github.ref, 'refs/tags/')
267+ id : version
268+ run : |
269+ VERSION=${GITHUB_REF#refs/tags/v}
270+ echo "version=$VERSION" >> $GITHUB_OUTPUT
271+ echo "Extracted version: $VERSION"
272+
273+ # Configure AWS credentials (skipped when AWS secrets not configured)
274+ - name : Configure AWS credentials
275+ id : aws-check
276+ if : env.AWS_ACCESS_KEY_ID != ''
277+ env :
278+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
279+ uses : aws-actions/configure-aws-credentials@v4
280+ with :
281+ aws-access-key-id : ${{ secrets.AWS_ACCESS_KEY_ID }}
282+ aws-secret-access-key : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
283+ aws-region : ${{ secrets.AWS_REGION }}
284+
285+ # Upload to S3 - versioned directory (immutable; all files get long cache)
286+ - name : Upload to S3 (versioned)
287+ if : steps.aws-check.outcome == 'success'
288+ run : |
289+ VERSION="${{ steps.version.outputs.version }}"
290+ BUCKET="${{ secrets.AWS_S3_BUCKET }}"
291+
292+ echo "Uploading version $VERSION to S3 bucket: $BUCKET"
293+
294+ declare -a targets=(
295+ "release/mac-arm64 mac-arm64"
296+ "release/mac-intel mac-intel"
297+ "release/win-x64 win-x64"
298+ "release/linux-x64 linux-x64"
299+ )
300+ for t in "${targets[@]}"; do
301+ src_dir="${t%% *}"
302+ path_suffix="${t##* }"
303+ if [ -d "$src_dir" ] && [ "$(ls -A "$src_dir")" ]; then
304+ echo "Uploading $path_suffix files..."
305+ aws s3 sync "$src_dir/" "s3://$BUCKET/releases/v$VERSION/$path_suffix/" \
306+ --content-type "binary/octet-stream" \
307+ --metadata-directive REPLACE \
308+ --cache-control "public, max-age=31536000, immutable"
309+ fi
310+ done
311+
312+ echo "Version $VERSION uploaded successfully"
313+
314+ # Upload to S3 - latest directory
315+ - name : Upload to S3 (latest)
316+ if : steps.aws-check.outcome == 'success'
317+ run : |
318+ BUCKET="${{ secrets.AWS_S3_BUCKET }}"
319+
320+ echo "Uploading latest release to S3 bucket: $BUCKET"
321+
322+ # Upload macOS ARM64 files to latest
323+ if [ -d "release/mac-arm64" ] && [ "$(ls -A release/mac-arm64)" ]; then
324+ echo "Uploading latest macOS ARM64 files..."
325+ aws s3 sync release/mac-arm64/ "s3://$BUCKET/releases/latest/mac-arm64/" \
326+ --delete \
327+ --content-type "binary/octet-stream" \
328+ --metadata-directive REPLACE \
329+ --cache-control "public, max-age=300" \
330+ --exclude "*.yml" \
331+ --exclude "*.blockmap"
332+
333+ aws s3 sync release/mac-arm64/ "s3://$BUCKET/releases/latest/mac-arm64/" \
334+ --delete \
335+ --exclude "*" \
336+ --include "*.yml" \
337+ --include "*.blockmap" \
338+ --cache-control "public, max-age=300"
339+ fi
340+
341+ # Upload macOS Intel files to latest (if exists)
342+ if [ -d "release/mac-intel" ] && [ "$(ls -A release/mac-intel)" ]; then
343+ echo "Uploading latest macOS Intel files..."
344+ aws s3 sync release/mac-intel/ "s3://$BUCKET/releases/latest/mac-intel/" \
345+ --delete \
346+ --content-type "binary/octet-stream" \
347+ --metadata-directive REPLACE \
348+ --cache-control "public, max-age=300" \
349+ --exclude "*.yml" \
350+ --exclude "*.blockmap"
351+
352+ aws s3 sync release/mac-intel/ "s3://$BUCKET/releases/latest/mac-intel/" \
353+ --delete \
354+ --exclude "*" \
355+ --include "*.yml" \
356+ --include "*.blockmap" \
357+ --cache-control "public, max-age=300"
358+ fi
359+
360+ # Upload Windows files to latest
361+ if [ -d "release/win-x64" ] && [ "$(ls -A release/win-x64)" ]; then
362+ echo "Uploading latest Windows files..."
363+ aws s3 sync release/win-x64/ "s3://$BUCKET/releases/latest/win-x64/" \
364+ --delete \
365+ --content-type "binary/octet-stream" \
366+ --metadata-directive REPLACE \
367+ --cache-control "public, max-age=300" \
368+ --exclude "*.yml" \
369+ --exclude "*.blockmap"
370+
371+ aws s3 sync release/win-x64/ "s3://$BUCKET/releases/latest/win-x64/" \
372+ --delete \
373+ --exclude "*" \
374+ --include "*.yml" \
375+ --include "*.blockmap" \
376+ --cache-control "public, max-age=300"
377+ fi
378+
379+ # Upload Linux files to latest
380+ if [ -d "release/linux-x64" ] && [ "$(ls -A release/linux-x64)" ]; then
381+ echo "Uploading latest Linux files..."
382+ aws s3 sync release/linux-x64/ "s3://$BUCKET/releases/latest/linux-x64/" \
383+ --delete \
384+ --content-type "binary/octet-stream" \
385+ --metadata-directive REPLACE \
386+ --cache-control "public, max-age=300" \
387+ --exclude "*.yml" \
388+ --exclude "*.blockmap"
389+
390+ aws s3 sync release/linux-x64/ "s3://$BUCKET/releases/latest/linux-x64/" \
391+ --delete \
392+ --exclude "*" \
393+ --include "*.yml" \
394+ --include "*.blockmap" \
395+ --cache-control "public, max-age=300"
396+ fi
397+
398+ echo "Latest release uploaded successfully"
399+
400+ # Generate download URLs
401+ - name : Generate download URLs
402+ if : steps.aws-check.outcome == 'success'
403+ run : |
404+ VERSION="${{ steps.version.outputs.version }}"
405+ BUCKET="${{ secrets.AWS_S3_BUCKET }}"
406+ REGION="${{ secrets.AWS_REGION }}"
407+
408+ # Determine S3 endpoint based on region
409+ if [[ "$REGION" == cn-* ]]; then
410+ ENDPOINT="s3.$REGION.amazonaws.com.cn"
411+ else
412+ ENDPOINT="s3.$REGION.amazonaws.com"
413+ fi
414+
415+ echo "================================"
416+ echo "Download URLs for version v$VERSION"
417+ echo "================================"
418+ echo ""
419+ echo "Versioned URLs:"
420+
421+ # Check which platforms exist and show URLs
422+ if [ -d "release/mac-arm64" ] && [ "$(ls -A release/mac-arm64)" ]; then
423+ echo "macOS (ARM64): https://$BUCKET.$ENDPOINT/releases/v$VERSION/mac-arm64/"
424+ fi
425+
426+ if [ -d "release/mac-intel" ] && [ "$(ls -A release/mac-intel)" ]; then
427+ echo "macOS (Intel): https://$BUCKET.$ENDPOINT/releases/v$VERSION/mac-intel/"
428+ fi
429+
430+ if [ -d "release/win-x64" ] && [ "$(ls -A release/win-x64)" ]; then
431+ echo "Windows (x64): https://$BUCKET.$ENDPOINT/releases/v$VERSION/win-x64/"
432+ fi
433+
434+ if [ -d "release/linux-x64" ] && [ "$(ls -A release/linux-x64)" ]; then
435+ echo "Linux (x64): https://$BUCKET.$ENDPOINT/releases/v$VERSION/linux-x64/"
436+ fi
437+
438+ echo ""
439+ echo "Latest URLs:"
440+
441+ if [ -d "release/mac-arm64" ] && [ "$(ls -A release/mac-arm64)" ]; then
442+ echo "macOS (ARM64): https://$BUCKET.$ENDPOINT/releases/latest/mac-arm64/"
443+ fi
444+
445+ if [ -d "release/mac-intel" ] && [ "$(ls -A release/mac-intel)" ]; then
446+ echo "macOS (Intel): https://$BUCKET.$ENDPOINT/releases/latest/mac-intel/"
447+ fi
448+
449+ if [ -d "release/win-x64" ] && [ "$(ls -A release/win-x64)" ]; then
450+ echo "Windows (x64): https://$BUCKET.$ENDPOINT/releases/latest/win-x64/"
451+ fi
452+
453+ if [ -d "release/linux-x64" ] && [ "$(ls -A release/linux-x64)" ]; then
454+ echo "Linux (x64): https://$BUCKET.$ENDPOINT/releases/latest/linux-x64/"
455+ fi
456+
457+ echo "================================"
0 commit comments