generated from PlexSheep/rs-base
Compare commits
2 Commits
Author | SHA1 | Date |
---|---|---|
Christoph J. Scherr | 06bf976a7d | |
Christoph J. Scherr | 12dc5f1c84 |
|
@ -17,14 +17,14 @@ api:
|
|||
type: github
|
||||
repository: autocrate
|
||||
auth:
|
||||
user: PlexSheep
|
||||
user: plexsheep
|
||||
pass:
|
||||
!env TOKEN_GH
|
||||
cscherr:
|
||||
type: forgejo
|
||||
endpoint: https://git.cscherr.de
|
||||
repository: autocrate
|
||||
auth:
|
||||
user: PlexSheep
|
||||
pass:
|
||||
!env TOKEN_CSCHERR
|
||||
# cscherr:
|
||||
# type: forgejo
|
||||
# endpoint: https://git.cscherr.de
|
||||
# repository: autocrate
|
||||
# auth:
|
||||
# user: PlexSheep
|
||||
# pass:
|
||||
# !env TOKEN_CSCHERR
|
||||
|
|
|
@ -37,7 +37,7 @@ jobs:
|
|||
- name: cargo fmt
|
||||
run: cargo fmt --all
|
||||
- name: cargo test
|
||||
run: cargo test --all-features --all-targets --workspace
|
||||
run: cargo test --all-features --all-targets --workspace && cargo test --all-features --workspace --doc
|
||||
- name: commit back to repository
|
||||
uses: https://github.com/stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
|
|
|
@ -38,7 +38,7 @@ jobs:
|
|||
- name: cargo fmt
|
||||
run: cargo fmt --all
|
||||
- name: cargo test
|
||||
run: cargo test --all-features --all-targets --workspace
|
||||
run: cargo test --all-features --all-targets --workspace && cargo test --all-features --workspace --doc
|
||||
- name: commit back to repository
|
||||
uses: stefanzweifel/git-auto-commit-action@v5
|
||||
with:
|
||||
|
|
|
@ -8,7 +8,7 @@ use libpt::log::{debug, error, trace};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
use crate::error::*;
|
||||
use crate::{error::*, git};
|
||||
|
||||
pub mod cli;
|
||||
pub mod packages;
|
||||
|
@ -295,14 +295,7 @@ impl Debug for Config {
|
|||
|
||||
impl Config {
|
||||
pub fn load(cli: &Cli) -> Result<Self> {
|
||||
let repo = match git2::Repository::open_from_env() {
|
||||
Ok(repo) => repo,
|
||||
Err(_err) => {
|
||||
let err = ConfigError::GitRepoNotFound.into();
|
||||
error!("{err}");
|
||||
return Err(err);
|
||||
}
|
||||
};
|
||||
let repo = git::get_repo()?;
|
||||
let mut path = repo.path().to_path_buf();
|
||||
path.pop(); // we want the real root, not the `.git` dir
|
||||
|
||||
|
|
26
src/main.rs
26
src/main.rs
|
@ -1,5 +1,3 @@
|
|||
use std::error::Error as _;
|
||||
|
||||
use autocrate::{
|
||||
changelog::*,
|
||||
config::{
|
||||
|
@ -11,37 +9,25 @@ use autocrate::{
|
|||
release::release,
|
||||
serverapi::ApiCollection,
|
||||
};
|
||||
use libpt::log::{debug, error};
|
||||
use libpt::log::{debug, error, trace};
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let cli = Cli::cli_parse();
|
||||
let cfg = Config::load(&cli)?;
|
||||
|
||||
let status: Option<Error> = match cli.command {
|
||||
match cli.command {
|
||||
Commands::Changelog { .. } => {
|
||||
let chlog = Changelog::build(&cfg);
|
||||
if chlog.is_ok() {
|
||||
println!("{}", chlog.unwrap());
|
||||
None
|
||||
} else {
|
||||
Some(chlog.unwrap_err())
|
||||
}
|
||||
println!("{}", Changelog::build(&cfg)?);
|
||||
}
|
||||
Commands::Release { .. } => {
|
||||
// TODO: check if repo is dirty and create a commit with a given option
|
||||
let mut apis = ApiCollection::build(&cfg).await?;
|
||||
match release(&cfg, &mut apis).await {
|
||||
Ok(_) => None,
|
||||
Err(err) => Some(err),
|
||||
}
|
||||
release(&cfg, &mut apis).await?;
|
||||
}
|
||||
Commands::Publish { .. } => {
|
||||
// TODO: check if repo is dirty and create a commit with a given option
|
||||
match publish(&cfg).await {
|
||||
Ok(_) => None,
|
||||
Err(err) => Some(err),
|
||||
}
|
||||
publish(&cfg).await?;
|
||||
}
|
||||
Commands::Version {} => {
|
||||
// TODO: version bump
|
||||
|
@ -56,7 +42,7 @@ async fn main() -> Result<()> {
|
|||
};
|
||||
if let Some(err) = status {
|
||||
error!("{err}");
|
||||
debug!("{:#?}", err.source());
|
||||
trace!("{:#?}", err.source());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
use async_trait::async_trait;
|
||||
use libpt::log::debug;
|
||||
use octocrab;
|
||||
|
||||
use super::{PublishContext, ReleaseContext, ServerApi};
|
||||
|
@ -21,18 +22,18 @@ impl Github {
|
|||
#[async_trait]
|
||||
impl ServerApi for Github {
|
||||
async fn push_release(&mut self, rc: ReleaseContext) -> Result<()> {
|
||||
let _response = octocrab::instance()
|
||||
.repos(rc.username, rc.repository)
|
||||
.releases()
|
||||
debug!("release context: {rc:#?}");
|
||||
let t1 = octocrab::instance();
|
||||
let t2 = t1.repos(rc.username, rc.repository);
|
||||
let t = t2.releases();
|
||||
let req = t
|
||||
.create(&rc.tag)
|
||||
.target_commitish(&rc.commit_sig)
|
||||
.name(&rc.tag)
|
||||
.body(&rc.text)
|
||||
.draft(rc.draft)
|
||||
.prerelease(rc.prerelease)
|
||||
.send()
|
||||
.await
|
||||
.map_err(ServerApiError::from)?;
|
||||
.prerelease(rc.prerelease);
|
||||
req.send().await.map_err(ServerApiError::from)?;
|
||||
Ok(())
|
||||
}
|
||||
async fn push_release_artifact(&mut self, _rc: ReleaseContext) -> Result<()> {
|
||||
|
|
Loading…
Reference in New Issue