Skip to content

Commit 34603e9

Browse files
authored
fix: allow publishing with no version in config file (#868)
https://github.com/dsherret/jsr-publish-on-tag/actions/runs/12332179143/job/34419677355 ``` $ deno publish --set-version 0.2.0 Download https://registry.npmjs.org/@types/node/-/node-18.16.19.tgz Check file:///home/runner/work/jsr-publish-on-tag/jsr-publish-on-tag/src/main.ts Checking for slow types in the public API... Check file:///home/runner/work/jsr-publish-on-tag/jsr-publish-on-tag/src/main.ts Publishing @david/[email protected] ... error: Failed to publish @david/[email protected] Caused by: Failed to publish @david/publish-on-tag at 0.2.0: invalid config file '/deno.json': missing field `version` Error: Process completed with exit code 1. ```
1 parent f597b42 commit 34603e9

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

api/src/npm/tarball.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ mod tests {
647647
) -> Result<(), anyhow::Error> {
648648
let scope = spec.jsr_json.name.scope.clone();
649649
let package = spec.jsr_json.name.package.clone();
650-
let version = spec.jsr_json.version.clone();
650+
let version = spec.jsr_json.version.clone().unwrap();
651651

652652
let exports = match exports_map_from_json(spec.jsr_json.exports.clone()) {
653653
Ok(exports) => exports,

api/src/publish.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ pub mod tests {
791791
.unwrap();
792792
let deno_json: ConfigFile = serde_json::from_slice(&json).unwrap();
793793
assert_eq!(deno_json.name.to_string(), "@scope/foo");
794-
assert_eq!(deno_json.version.to_string(), "1.2.3");
794+
assert_eq!(deno_json.version.unwrap().to_string(), "1.2.3");
795795
{
796796
let metadata_json = t
797797
.buckets

api/src/tarball.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,12 +247,14 @@ pub async fn process_tarball(
247247
publish_task_name: publishing_task_scoped_package_name,
248248
});
249249
}
250-
if config_file.version != publishing_task.package_version {
251-
return Err(PublishError::ConfigFileVersionMismatch {
252-
path: Box::new(publishing_task.config_file.clone()),
253-
deno_json_version: Box::new(config_file.version),
254-
publish_task_version: Box::new(publishing_task.package_version.clone()),
255-
});
250+
if let Some(config_file_version) = config_file.version {
251+
if config_file_version != publishing_task.package_version {
252+
return Err(PublishError::ConfigFileVersionMismatch {
253+
path: Box::new(publishing_task.config_file.clone()),
254+
deno_json_version: Box::new(config_file_version),
255+
publish_task_version: Box::new(publishing_task.package_version.clone()),
256+
});
257+
}
256258
}
257259

258260
let exports =
@@ -690,7 +692,7 @@ pub struct FileInfo {
690692
#[derive(Debug, Serialize, Deserialize)]
691693
pub struct ConfigFile {
692694
pub name: ScopedPackageName,
693-
pub version: Version,
695+
pub version: Option<Version>,
694696
pub exports: Option<serde_json::Value>,
695697
}
696698

frontend/static/schema/config-file.v1.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"description": "A JSON representation of a JSR configuration file.",
55
"required": [
66
"name",
7-
"version",
87
"exports"
98
],
109
"title": "JSR configuration file Schema",

0 commit comments

Comments
 (0)