11#!/usr/bin/env -S deno run --allow-write=. --lock=./tools/deno.lock.json
2- // Copyright 2018-2024 the Deno authors. All rights reserved . MIT license.
2+ // Copyright 2018-2025 the Deno authors. MIT license.
33import { stringify } from "jsr:@std/yaml@^0.221/stringify" ;
44
55// Bump this number when you want to purge the cache.
66// Note: the tools/release/01_bump_crate_versions.ts script will update this version
77// automatically via regex, so ensure that this line maintains this format.
8- const cacheVersion = 25 ;
8+ const cacheVersion = 32 ;
99
1010const ubuntuX86Runner = "ubuntu-24.04" ;
1111const ubuntuX86XlRunner = "ubuntu-24.04-xl" ;
@@ -59,6 +59,15 @@ const Runners = {
5959
6060const prCacheKeyPrefix =
6161 `${ cacheVersion } -cargo-target-\${{ matrix.os }}-\${{ matrix.arch }}-\${{ matrix.profile }}-\${{ matrix.job }}-` ;
62+ const prCacheKey = `${ prCacheKeyPrefix } \${{ github.sha }}` ;
63+ const prCachePath = [
64+ // this must match for save and restore (https://github.com/actions/cache/issues/1444)
65+ "./target" ,
66+ "!./target/*/gn_out" ,
67+ "!./target/*/gn_root" ,
68+ "!./target/*/*.zip" ,
69+ "!./target/*/*.tar.gz" ,
70+ ] . join ( "\n" ) ;
6271
6372// Note that you may need to add more version to the `apt-get remove` line below if you change this
6473const llvmVersion = 19 ;
@@ -196,7 +205,7 @@ const installNodeStep = {
196205const installDenoStep = {
197206 name : "Install Deno" ,
198207 uses : "denoland/setup-deno@v2" ,
199- with : { "deno-version" : "v1 .x" } ,
208+ with : { "deno-version" : "v2 .x" } ,
200209} ;
201210
202211const authenticateWithGoogleCloud = {
@@ -475,6 +484,27 @@ const ci = {
475484 " -czvf target/release/deno_src.tar.gz -C .. deno" ,
476485 ] . join ( "\n" ) ,
477486 } ,
487+ {
488+ name : "Cache Cargo home" ,
489+ uses : "actions/cache@v4" ,
490+ with : {
491+ // See https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
492+ // Note that with the new sparse registry format, we no longer have to cache a `.git` dir
493+ path : [
494+ "~/.cargo/.crates.toml" ,
495+ "~/.cargo/.crates2.json" ,
496+ "~/.cargo/bin" ,
497+ "~/.cargo/registry/index" ,
498+ "~/.cargo/registry/cache" ,
499+ "~/.cargo/git/db" ,
500+ ] . join ( "\n" ) ,
501+ key :
502+ `${ cacheVersion } -cargo-home-\${{ matrix.os }}-\${{ matrix.arch }}-\${{ hashFiles('Cargo.lock') }}` ,
503+ // We will try to restore from the closest cargo-home we can find
504+ "restore-keys" :
505+ `${ cacheVersion } -cargo-home-\${{ matrix.os }}-\${{ matrix.arch }}-` ,
506+ } ,
507+ } ,
478508 installRustStep ,
479509 {
480510 if :
@@ -598,37 +628,14 @@ const ci = {
598628 installBenchTools ,
599629 ] . join ( "\n" ) ,
600630 } ,
601- {
602- name : "Cache Cargo home" ,
603- uses : "actions/cache@v4" ,
604- with : {
605- // See https://doc.rust-lang.org/cargo/guide/cargo-home.html#caching-the-cargo-home-in-ci
606- // Note that with the new sparse registry format, we no longer have to cache a `.git` dir
607- path : [
608- "~/.cargo/registry/index" ,
609- "~/.cargo/registry/cache" ,
610- ] . join ( "\n" ) ,
611- key :
612- `${ cacheVersion } -cargo-home-\${{ matrix.os }}-\${{ matrix.arch }}-\${{ hashFiles('Cargo.lock') }}` ,
613- // We will try to restore from the closest cargo-home we can find
614- "restore-keys" :
615- `${ cacheVersion } -cargo-home-\${{ matrix.os }}-\${{ matrix.arch }}` ,
616- } ,
617- } ,
618631 {
619632 // Restore cache from the latest 'main' branch build.
620633 name : "Restore cache build output (PR)" ,
621634 uses : "actions/cache/restore@v4" ,
622635 if :
623636 "github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/')" ,
624637 with : {
625- path : [
626- "./target" ,
627- "!./target/*/gn_out" ,
628- "!./target/*/gn_root" ,
629- "!./target/*/*.zip" ,
630- "!./target/*/*.tar.gz" ,
631- ] . join ( "\n" ) ,
638+ path : prCachePath ,
632639 key : "never_saved" ,
633640 "restore-keys" : prCacheKeyPrefix ,
634641 } ,
@@ -709,6 +716,19 @@ const ci = {
709716 "df -h" ,
710717 ] . join ( "\n" ) ,
711718 } ,
719+ {
720+ name : "Build denort release" ,
721+ if : [
722+ "matrix.job == 'test' &&" ,
723+ "matrix.profile == 'release' &&" ,
724+ "github.repository == 'denoland/deno'" ,
725+ ] . join ( "\n" ) ,
726+ run : [
727+ "df -h" ,
728+ "cargo build --profile=release-slim --locked --bin denort" ,
729+ "df -h" ,
730+ ] . join ( "\n" ) ,
731+ } ,
712732 {
713733 // Run a minimal check to ensure that binary is not corrupted, regardless
714734 // of our build mode
@@ -755,10 +775,11 @@ const ci = {
755775 "cd target/release" ,
756776 "zip -r deno-${{ matrix.arch }}-unknown-linux-gnu.zip deno" ,
757777 "shasum -a 256 deno-${{ matrix.arch }}-unknown-linux-gnu.zip > deno-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum" ,
758- "strip denort" ,
759- "zip -r denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort" ,
760- "shasum -a 256 denort-${{ matrix.arch }}-unknown-linux-gnu.zip > denort-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum" ,
761778 "./deno types > lib.deno.d.ts" ,
779+ "cd ../release-slim" ,
780+ "zip -r ../release/denort-${{ matrix.arch }}-unknown-linux-gnu.zip denort" ,
781+ "cd ../release" ,
782+ "shasum -a 256 denort-${{ matrix.arch }}-unknown-linux-gnu.zip > denort-${{ matrix.arch }}-unknown-linux-gnu.zip.sha256sum" ,
762783 ] . join ( "\n" ) ,
763784 } ,
764785 {
@@ -783,8 +804,9 @@ const ci = {
783804 "cd target/release" ,
784805 "zip -r deno-${{ matrix.arch }}-apple-darwin.zip deno" ,
785806 "shasum -a 256 deno-${{ matrix.arch }}-apple-darwin.zip > deno-${{ matrix.arch }}-apple-darwin.zip.sha256sum" ,
786- "strip denort" ,
787- "zip -r denort-${{ matrix.arch }}-apple-darwin.zip denort" ,
807+ "cd ../release-slim" ,
808+ "zip -r ../release/denort-${{ matrix.arch }}-apple-darwin.zip denort" ,
809+ "cd ../release" ,
788810 "shasum -a 256 denort-${{ matrix.arch }}-apple-darwin.zip > denort-${{ matrix.arch }}-apple-darwin.zip.sha256sum" ,
789811 ]
790812 . join ( "\n" ) ,
@@ -801,7 +823,8 @@ const ci = {
801823 run : [
802824 "Compress-Archive -CompressionLevel Optimal -Force -Path target/release/deno.exe -DestinationPath target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip" ,
803825 "Get-FileHash target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/deno-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum" ,
804- "Compress-Archive -CompressionLevel Optimal -Force -Path target/release/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip" ,
826+
827+ "Compress-Archive -CompressionLevel Optimal -Force -Path target/release-slim/denort.exe -DestinationPath target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip" ,
805828 "Get-FileHash target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip -Algorithm SHA256 | Format-List > target/release/denort-${{ matrix.arch }}-pc-windows-msvc.zip.sha256sum" ,
806829 ] . join ( "\n" ) ,
807830 } ,
@@ -1080,14 +1103,8 @@ const ci = {
10801103 if :
10811104 "(matrix.job == 'test' || matrix.job == 'lint') && github.ref == 'refs/heads/main'" ,
10821105 with : {
1083- path : [
1084- "./target" ,
1085- "!./target/*/gn_out" ,
1086- "!./target/*/*.zip" ,
1087- "!./target/*/*.sha256sum" ,
1088- "!./target/*/*.tar.gz" ,
1089- ] . join ( "\n" ) ,
1090- key : prCacheKeyPrefix + "${{ github.sha }}" ,
1106+ path : prCachePath ,
1107+ key : prCacheKey ,
10911108 } ,
10921109 } ,
10931110 ] ) ,
0 commit comments