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