Skip to content

Commit fe0c1aa

Browse files
authored
chore: trusted crates.io publishing (#92)
1 parent f637238 commit fe0c1aa

File tree

19 files changed

+130
-116
lines changed

19 files changed

+130
-116
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616

1717
steps:
1818
- name: Clone repository
19-
uses: actions/checkout@v4
19+
uses: actions/checkout@v5
2020

2121
- name: Install rust
2222
uses: dsherret/rust-toolchain-file@v1
@@ -39,15 +39,6 @@ jobs:
3939
- name: Test
4040
run: cargo test
4141

42-
- name: Cargo publish
43-
if: |
44-
contains(matrix.os, 'ubuntu') &&
45-
github.repository == 'denoland/deno_cache_dir' &&
46-
startsWith(github.ref, 'refs/tags/')
47-
env:
48-
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
49-
run: cargo publish -p deno_cache_dir
50-
5142
deno:
5243
name: deno_cache_dir-deno
5344
if: |
@@ -61,7 +52,7 @@ jobs:
6152

6253
steps:
6354
- name: Clone repository
64-
uses: actions/checkout@v4
55+
uses: actions/checkout@v5
6556
- name: Install rust
6657
uses: dsherret/rust-toolchain-file@v1
6758
- uses: Swatinem/rust-cache@v2

.github/workflows/publish.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: publish
2+
3+
on:
4+
push:
5+
tags:
6+
- "*"
7+
8+
jobs:
9+
publish:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
id-token: write
14+
steps:
15+
- name: Clone repository
16+
uses: actions/checkout@v5
17+
- uses: rust-lang/crates-io-auth-action@v1
18+
id: auth
19+
- run: cargo publish
20+
env:
21+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
steps:
2222
- name: Clone repository
23-
uses: actions/checkout@v4
23+
uses: actions/checkout@v5
2424
with:
2525
token: ${{ secrets.DENOBOT_PAT }}
2626

@@ -36,4 +36,4 @@ jobs:
3636
run: |
3737
git config user.email "denobot@users.noreply.github.com"
3838
git config user.name "denobot"
39-
deno run -A https://raw.githubusercontent.com/denoland/automation/0.20.0/tasks/publish_release.ts --${{github.event.inputs.releaseKind}} deno_cache_dir
39+
deno run -A jsr:@deno/rust-automation@0.22.0/publish-release --${{github.event.inputs.releaseKind}} deno_cache_dir

.rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
max_width = 80
22
tab_spaces = 2
3-
edition = "2021"
3+
edition = "2024"

rs_lib/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[package]
22
name = "deno_cache_dir"
33
version = "0.25.0"
4-
edition = "2021"
4+
edition = "2024"
55
license = "MIT"
66
description = "Cache directory logic used in Deno"
7-
repository = "https://github.com/denoland/deno_cache"
7+
repository = "https://github.com/denoland/deno_cache_dir"
88

99
[lib]
1010
crate-type = ["cdylib", "lib"]

rs_lib/clippy.toml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,6 @@ disallowed-methods = [
99
{ path = "std::path::Path::read_link", reason = "File system operations should be done using DenoCacheEnv trait" },
1010
{ path = "std::path::Path::symlink_metadata", reason = "File system operations should be done using DenoCacheEnv trait" },
1111
{ path = "std::path::Path::try_exists", reason = "File system operations should be done using DenoCacheEnv trait" },
12-
{ path = "std::path::PathBuf::exists", reason = "File system operations should be done using DenoCacheEnv trait" },
13-
{ path = "std::path::PathBuf::canonicalize", reason = "File system operations should be done using DenoCacheEnv trait" },
14-
{ path = "std::path::PathBuf::is_dir", reason = "File system operations should be done using DenoCacheEnv trait" },
15-
{ path = "std::path::PathBuf::is_file", reason = "File system operations should be done using DenoCacheEnv trait" },
16-
{ path = "std::path::PathBuf::is_symlink", reason = "File system operations should be done using DenoCacheEnv trait" },
17-
{ path = "std::path::PathBuf::metadata", reason = "File system operations should be done using DenoCacheEnv trait" },
18-
{ path = "std::path::PathBuf::read_dir", reason = "File system operations should be done using DenoCacheEnv trait" },
19-
{ path = "std::path::PathBuf::read_link", reason = "File system operations should be done using DenoCacheEnv trait" },
20-
{ path = "std::path::PathBuf::symlink_metadata", reason = "File system operations should be done using DenoCacheEnv trait" },
21-
{ path = "std::path::PathBuf::try_exists", reason = "File system operations should be done using DenoCacheEnv trait" },
2212
{ path = "std::env::set_current_dir", reason = "File system operations should be done using DenoCacheEnv trait" },
2313
{ path = "std::env::temp_dir", reason = "File system operations should be done using DenoCacheEnv trait" },
2414
{ path = "std::fs::canonicalize", reason = "File system operations should be done using DenoCacheEnv trait" },

rs_lib/src/cache.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ use std::time::SystemTime;
1010
use thiserror::Error;
1111
use url::Url;
1212

13+
use crate::GlobalHttpCacheRc;
14+
use crate::LocalHttpCacheRc;
15+
use crate::common::HeadersMap;
1316
use crate::common::base_url_to_filename_parts;
1417
use crate::common::checksum;
15-
use crate::common::HeadersMap;
1618
use crate::global::GlobalHttpCacheSys;
1719
use crate::local::LocalHttpCacheSys;
1820
use crate::sync::MaybeSend;
1921
use crate::sync::MaybeSync;
20-
use crate::GlobalHttpCacheRc;
21-
use crate::LocalHttpCacheRc;
2222

2323
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
2424
pub enum GlobalToLocalCopy {

rs_lib/src/deno_dir.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,13 @@ use thiserror::Error;
1010

1111
#[derive(Debug, Error)]
1212
pub enum DenoDirResolutionError {
13-
#[error("Could not resolve global Deno cache directory. Please make sure that either the DENO_DIR environment variable is set or the cache directory is available.")]
13+
#[error(
14+
"Could not resolve global Deno cache directory. Please make sure that either the DENO_DIR environment variable is set or the cache directory is available."
15+
)]
1416
NoCacheOrHomeDir,
15-
#[error("Could not resolve global Deno cache directory because the current working directory could not be resolved. Please set the DENO_DIR environment variable and ensure it is pointing at an absolute path.")]
17+
#[error(
18+
"Could not resolve global Deno cache directory because the current working directory could not be resolved. Please set the DENO_DIR environment variable and ensure it is pointing at an absolute path."
19+
)]
1620
FailedCwd {
1721
#[source]
1822
source: std::io::Error,

rs_lib/src/file_fetcher/auth_tokens.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use std::net::Ipv6Addr;
88
use std::net::SocketAddr;
99
use std::str::FromStr;
1010

11-
use base64::prelude::BASE64_STANDARD;
1211
use base64::Engine;
12+
use base64::prelude::BASE64_STANDARD;
1313
use log::debug;
1414
use log::error;
1515
use sys_traits::EnvVar;

rs_lib/src/file_fetcher/http_util.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ impl CacheSemantics {
8787
};
8888
}
8989

90-
if let Some(last_modified) = self.headers.get("last-modified") {
91-
if let Ok(last_modified) = DateTime::parse_from_rfc2822(last_modified) {
92-
let last_modified = SystemTime::UNIX_EPOCH
93-
+ Duration::from_secs(last_modified.timestamp().max(0) as _);
94-
if let Ok(diff) = server_date.duration_since(last_modified) {
95-
let secs_left = diff.as_secs() as f64 * 0.1;
96-
return default_min_ttl.max(Duration::from_secs(secs_left as _));
97-
}
90+
if let Some(last_modified) = self.headers.get("last-modified")
91+
&& let Ok(last_modified) = DateTime::parse_from_rfc2822(last_modified)
92+
{
93+
let last_modified = SystemTime::UNIX_EPOCH
94+
+ Duration::from_secs(last_modified.timestamp().max(0) as _);
95+
if let Ok(diff) = server_date.duration_since(last_modified) {
96+
let secs_left = diff.as_secs() as f64 * 0.1;
97+
return default_min_ttl.max(Duration::from_secs(secs_left as _));
9898
}
9999
}
100100

@@ -120,16 +120,16 @@ impl CacheSemantics {
120120
return false;
121121
}
122122

123-
if let Some(max_age) = self.cache_control.max_age {
124-
if self.age() > max_age {
125-
return false;
126-
}
123+
if let Some(max_age) = self.cache_control.max_age
124+
&& self.age() > max_age
125+
{
126+
return false;
127127
}
128128

129-
if let Some(min_fresh) = self.cache_control.min_fresh {
130-
if self.time_to_live() < min_fresh {
131-
return false;
132-
}
129+
if let Some(min_fresh) = self.cache_control.min_fresh
130+
&& self.time_to_live() < min_fresh
131+
{
132+
return false;
133133
}
134134

135135
if self.is_stale() {

0 commit comments

Comments
 (0)