This commit is contained in:
Kieran 2025-02-12 15:24:05 +00:00
parent 03a529fc7b
commit 63cff68bdd
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
4 changed files with 92 additions and 27 deletions

View File

@ -3,10 +3,11 @@ mod repo;
use crate::manifest::Manifest;
use crate::repo::Repo;
use anyhow::{anyhow, Result};
use anyhow::{anyhow, bail, Result};
use clap::Parser;
use config::{Config, File, FileSourceFile};
use log::info;
use nostr_sdk::{EventBuilder, JsonUtil, Keys};
use std::path::PathBuf;
#[derive(clap::Parser)]
@ -53,6 +54,24 @@ async fn main() -> Result<()> {
{
return Ok(());
}
let key = dialoguer::Password::new()
.with_prompt("Enter nsec:")
.interact()?;
let key = if let Ok(nsec) = Keys::parse(&key) {
nsec
} else {
bail!("Invalid private key")
};
let ev: EventBuilder = (&manifest).into();
// create release
// publish application
let ev = ev.build(key.public_key).sign_with_keys(&key)?;
info!("{}", ev.as_json());
}
Ok(())

View File

@ -1,3 +1,4 @@
use nostr_sdk::{Event, EventBuilder, Kind, Tag};
use serde::Deserialize;
#[derive(Deserialize)]
@ -14,6 +15,9 @@ pub struct Manifest {
/// Repo URL
pub repository: Option<String>,
/// SPDX license code
pub license: Option<String>,
/// App icon
pub icon: Option<String>,
@ -24,29 +28,32 @@ pub struct Manifest {
pub tags: Vec<String>,
}
#[derive(Deserialize)]
pub enum Platform {
Android {
arch: Architecture
},
IOS,
MacOS {
arch: Architecture
},
Windows {
arch: Architecture
},
Linux {
arch: Architecture
},
Web
}
impl Into<EventBuilder> for &Manifest {
fn into(self) -> EventBuilder {
let mut b = EventBuilder::new(
Kind::Custom(32_267),
self.description.clone().unwrap_or_default(),
)
.tags([
Tag::parse(["d", &self.id]).unwrap(),
Tag::parse(["name", &self.name]).unwrap(),
]);
if let Some(icon) = &self.icon {
b = b.tag(Tag::parse(["icon", icon]).unwrap());
}
if let Some(repository) = &self.repository {
b = b.tag(Tag::parse(["repository", repository]).unwrap());
}
if let Some(license) = &self.license {
b = b.tag(Tag::parse(["license", license]).unwrap());
}
for image in &self.images {
b = b.tag(Tag::parse(["image", image]).unwrap());
}
for tag in &self.tags {
b = b.tag(Tag::parse(["t", tag]).unwrap());
}
#[derive(Deserialize)]
pub enum Architecture {
ARMv7,
ARMv8,
X86,
AMD64,
ARM64
b
}
}

View File

@ -93,7 +93,9 @@ impl TryFrom<&GithubReleaseArtifact> for RepoArtifact {
name: value.name.clone(),
size: value.size,
content_type: value.content_type.clone(),
platform: Platform::IOS,
location: RepoResource::Remote(value.browser_download_url.clone()),
metadata: (),
})
}
}

View File

@ -1,8 +1,9 @@
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use crate::manifest::Manifest;
use crate::repo::github::GithubRepo;
use anyhow::{anyhow, bail, Result};
use semver::Version;
use serde::Deserialize;
mod github;
@ -12,6 +13,34 @@ pub struct RepoArtifact {
pub size: u64,
pub location: RepoResource,
pub content_type: String,
pub platform: Platform,
pub metadata: ArtifactMetadata
}
pub enum ArtifactMetadata {
APK {
version_code: u32,
min_sdk_version: u32,
target_sdk_version: u32,
sig_hash: String,
}
}
pub enum Platform {
Android { arch: Architecture },
IOS,
MacOS { arch: Architecture },
Windows { arch: Architecture },
Linux { arch: Architecture },
Web,
}
pub enum Architecture {
ARMv7,
ARMv8,
X86,
AMD64,
ARM64,
}
/// A local/remote location where the artifact is located
@ -49,3 +78,11 @@ impl TryInto<Box<dyn Repo>> for &Manifest {
Ok(Box::new(GithubRepo::from_url(repo)?))
}
}
async fn load_artifact_url(url: &str) -> Result<RepoArtifact> {
}
async fn load_artifact(path: &Path) -> Result<RepoArtifact> {
}