2020-05-31 19:35:23 +00:00
|
|
|
use std::path::PathBuf;
|
|
|
|
use structopt::StructOpt;
|
|
|
|
|
2020-05-30 16:24:04 +00:00
|
|
|
pub(crate) mod delete;
|
2020-05-30 18:27:49 +00:00
|
|
|
pub(crate) mod download;
|
2020-05-31 19:35:23 +00:00
|
|
|
pub(crate) mod drone_plugin;
|
2020-05-30 18:50:21 +00:00
|
|
|
pub(crate) mod edit;
|
2020-05-30 16:24:04 +00:00
|
|
|
pub(crate) mod info;
|
2020-05-31 16:53:34 +00:00
|
|
|
pub(crate) mod release;
|
2020-05-30 19:15:18 +00:00
|
|
|
pub(crate) mod upload;
|
2020-05-31 19:35:23 +00:00
|
|
|
|
|
|
|
#[derive(StructOpt, Debug)]
|
|
|
|
pub(crate) struct Common {
|
|
|
|
/// The gitea server to connect to
|
|
|
|
#[structopt(short, long, env = "GITEA_SERVER")]
|
|
|
|
pub server: String,
|
|
|
|
/// The gitea token to authenticate with
|
|
|
|
#[structopt(long, env = "GITEA_TOKEN")]
|
|
|
|
pub token: String,
|
|
|
|
/// The gitea user to authenticate as
|
|
|
|
#[structopt(short, long, env = "GITEA_AUTH_USER")]
|
|
|
|
pub auth_user: String,
|
|
|
|
/// The owner of the gitea repo
|
|
|
|
#[structopt(short, long, env = "GITEA_OWNER")]
|
|
|
|
pub owner: String,
|
|
|
|
/// The gitea repo to operate on
|
|
|
|
#[structopt(short, long, env = "GITEA_REPO")]
|
|
|
|
pub repo: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(StructOpt, Debug, Clone)]
|
|
|
|
pub(crate) struct DroneEnv {
|
|
|
|
/// push URL
|
|
|
|
#[structopt(env="DRONE_GIT_HTTP_URL")]
|
|
|
|
pub push_url: String,
|
|
|
|
/// repo owner
|
|
|
|
#[structopt(env="DRONE_REPO_OWNER")]
|
|
|
|
pub owner: String,
|
|
|
|
/// repo name
|
|
|
|
#[structopt(env="DRONE_REPO_NAME")]
|
|
|
|
pub repo: String,
|
|
|
|
/// auth username
|
2020-05-31 19:47:57 +00:00
|
|
|
#[structopt(env="PLUGIN_AUTH_USERNAME")]
|
2020-05-31 19:35:23 +00:00
|
|
|
pub auth_user: String,
|
|
|
|
/// Gitea server
|
2020-05-31 19:47:57 +00:00
|
|
|
#[structopt(env="PLUGIN_GITEA_SERVER")]
|
2020-05-31 19:35:23 +00:00
|
|
|
pub server: String,
|
|
|
|
/// Gitea token
|
2020-05-31 19:47:57 +00:00
|
|
|
#[structopt(env="PLUGIN_GITEA_TOKEN")]
|
2020-05-31 19:35:23 +00:00
|
|
|
pub token: String,
|
|
|
|
/// CHANGELOG path
|
2020-05-31 19:47:57 +00:00
|
|
|
#[structopt(env="PLUGIN_CHANGELOG_PATH", default_value="./CHANGELOG.md")]
|
2020-05-31 19:35:23 +00:00
|
|
|
pub changelog_path: PathBuf,
|
|
|
|
/// branch
|
|
|
|
#[structopt(env="DRONE_REPO_BRANCH")]
|
|
|
|
pub branch: String,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<Common> for DroneEnv {
|
|
|
|
fn into(self) -> Common {
|
|
|
|
Common {
|
|
|
|
server: self.server,
|
|
|
|
token: self.token,
|
|
|
|
auth_user: self.auth_user,
|
|
|
|
owner: self.owner,
|
|
|
|
repo: self.repo,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(StructOpt, Debug)]
|
|
|
|
pub(crate) struct ReleaseMeta {
|
|
|
|
/// Release name
|
|
|
|
#[structopt(short, long)]
|
|
|
|
pub name: Option<String>,
|
|
|
|
/// Draft release
|
|
|
|
#[structopt(long)]
|
|
|
|
pub draft: bool,
|
|
|
|
/// Pre-release (not suitable for production)
|
|
|
|
#[structopt(short, long)]
|
|
|
|
pub pre_release: bool,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(StructOpt, Debug)]
|
|
|
|
#[structopt(about = "Gitea release assistant")]
|
|
|
|
pub(crate) enum Cmd {
|
|
|
|
/// Delete a given release from Gitea
|
|
|
|
Delete {
|
|
|
|
#[structopt(flatten)]
|
|
|
|
common: Common,
|
|
|
|
/// The version tag to operate on
|
|
|
|
#[structopt(short, long)]
|
|
|
|
tag: String,
|
|
|
|
},
|
|
|
|
/// Downloads release artifacts
|
|
|
|
Download {
|
|
|
|
#[structopt(flatten)]
|
|
|
|
common: Common,
|
|
|
|
/// File to download
|
|
|
|
fname: Option<PathBuf>,
|
|
|
|
/// The version tag to operate on
|
|
|
|
#[structopt(short, long)]
|
|
|
|
tag: String,
|
|
|
|
},
|
|
|
|
/// Runs the release process as a drone plugin
|
|
|
|
DronePlugin {
|
|
|
|
#[structopt(flatten)]
|
|
|
|
env: DroneEnv,
|
|
|
|
},
|
|
|
|
/// Edits a release's description, name and other flags
|
|
|
|
Edit {
|
|
|
|
#[structopt(flatten)]
|
|
|
|
common: Common,
|
|
|
|
/// Release description
|
|
|
|
#[structopt(short, long)]
|
|
|
|
description: Option<String>,
|
|
|
|
#[structopt(flatten)]
|
|
|
|
release_meta: ReleaseMeta,
|
|
|
|
/// The version tag to operate on
|
|
|
|
tag: String,
|
|
|
|
},
|
|
|
|
/// Gets release info
|
|
|
|
Info {
|
|
|
|
#[structopt(flatten)]
|
|
|
|
common: Common,
|
|
|
|
#[structopt(long, short)]
|
|
|
|
json: bool,
|
|
|
|
/// The version tag to operate on
|
|
|
|
#[structopt(short, long)]
|
|
|
|
tag: Option<String>,
|
|
|
|
},
|
|
|
|
/// Create a new tag and release on Gitea
|
|
|
|
Release {
|
|
|
|
#[structopt(flatten)]
|
|
|
|
common: Common,
|
|
|
|
/// Changelog file to read from to create the release description
|
|
|
|
#[structopt(short, long, default_value = "./CHANGELOG.md")]
|
|
|
|
changelog: PathBuf,
|
|
|
|
/// The version tag to operate on
|
|
|
|
tag: Option<String>,
|
|
|
|
#[structopt(flatten)]
|
|
|
|
release_meta: ReleaseMeta,
|
|
|
|
},
|
|
|
|
/// Uploads release artifacts to Gitea
|
|
|
|
Upload {
|
|
|
|
#[structopt(flatten)]
|
|
|
|
common: Common,
|
|
|
|
/// The version tag to operate on
|
|
|
|
#[structopt(short, long)]
|
|
|
|
tag: String,
|
|
|
|
/// The location of the file on the disk
|
|
|
|
fname: PathBuf,
|
|
|
|
},
|
|
|
|
}
|