Skip to content

Commit

Permalink
release 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
taissan committed Jun 30, 2023
1 parent 2a7e625 commit 7bc782c
Show file tree
Hide file tree
Showing 10 changed files with 314 additions and 128 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- uses: taiki-e/create-gh-release-action@v1
with:
# (optional) Path to changelog.
# changelog: CHANGELOG.md
changelog: CHANGELOG.md
# (required) GitHub token for creating GitHub Releases.
token: ${{ secrets.GITHUB_TOKEN }}

Expand Down
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Changelog

## [Unreleased]

### Added
- New feature A
- New feature B

### Changed
- Improved feature C

## [1.0.0] - 2023-06-30

### Added
- 添加--proxy,--log-level参数
- 处理错误
- 发布完整版本

## [0.0.2] - 2023-06-25

### Init
- 发布可用版本
23 changes: 22 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "dtrack"
version = "0.0.2"
version = "1.0.0"
edition = "2021"
description = "Dependency-Track in the CI"
license = "MIT"
Expand All @@ -14,4 +14,5 @@ log = "0.4"
reqwest = { version = "0.11", features = ["blocking", "json","multipart"] }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
thiserror = "1"
tokio = { version = "1", features = ["full"] }
40 changes: 31 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,45 @@
# dtrack

dtrack is the rust script to facilitate usage of DependencyTrack in the CI, optionally failing the build based on different parameters.
dtrack DependencyTrack 的cli程序

```
Usage: dtrack [OPTIONS]
Options:
-u, --url <Url> 设置dependencytrack的访问地址. eg. http://dtrack.abc.local:8080 [default: http://127.0.0.1:8081]
-k, --key <Apikey> 设置dependencytrack的apikey. eg. adfadfe343g [default: Oh9LHLfrLgk77e67DEZtiitOWZwvFVXI]
-p, --project <Project Name> 设置dependencytrack的项目名称 [default: test]
-e, --edition <Project Version> 设置dependencytrack的项目版本 [default: default]
-f, --file <Bom File> 设置dependencytrack的文件
-r, --rule <Rule> 设置dependencytrack的规则
-d, --dversion 输出dependencytrack版本信息
-o, --output <Scan Result> 设置dependencytrack的扫描结果存储位置 [default: results.json]
-u, --url <Url> 设置 Dependency-track 的访问地址. eg. http://dtrack.abc.local:8081 [default: http://127.0.0.1:8081]
-k, --key <Apikey> 设置 Dependency-track 的apikey. eg. adfadfe343g [default: Oh9LHLfrLgk77e67DEZtiitOWZwvFVXI]
--proxy <Proxy> 设置 Dependency-track 的连接代理. eg. http://127.0.0.1:8080
-p, --project <Project Name> 设置 Dependency-track 的项目名称 [default: test]
-e, --edition <Project Version> 设置 Dependency-track 的项目版本 [default: default]
-f, --file <Bom File> 设置 Dependency-track 的文件
-r, --rule <Rule> 设置 Dependency-track 的规则
-d, --dversion 输出 Dependency-track 版本信息
-o, --output <Scan Result> 设置 Dependency-track 的扫描结果存储位置 [default: results.json]
-l, --log-level <LOG_LEVEL> 设置输出日志的级别(选择off不输出日志) [default: debug] [possible values: off, debug, info, warn, error]
-h, --help Print help
-V, --version Print version
```

## 如何下载

### 1.Cargo
```
cargo install dtrack
```
### 2.Windows
```
直接下载dtrack-x86_64-pc-windows-msvc.zip解压即可
```

### 3.Linux
```
LATEST_VERSION=$(curl -s https://api.github.com/repos/cnsino/dtrack/releases/latest | jq -r '.tag_name')
DOWNLOAD_URL="https://github.com/cnsino/dtrack/releases/download/$LATEST_VERSION/dtrack-x86_64-unknown-linux-gnu.tar.gz"
curl -L $DOWNLOAD_URL
tar -xzvf dtrack-x86_64-unknown-linux-gnu.tar.gz
mv dtrack /usr/local/bin/
```

## 使用方式
```bash
dtrack -p test2 -e 0.0.1 -f /root/bom.xml -o /root/results.json
Expand Down
47 changes: 31 additions & 16 deletions src/args.rs
Original file line number Diff line number Diff line change
@@ -1,50 +1,65 @@
use std::str::FromStr;

use clap::builder::TypedValueParser as _;
use clap::Parser;
/// Dependency-track 的cli程序
use reqwest::Url;
/// Dependency-track 的命令行程序
#[derive(Parser, Debug, Clone)]
#[command(author,version, about, long_about = None)]
pub(crate) struct Dtrack {
/// 设置dependencytrack的访问地址. eg. http://dtrack.abc.local:8080.
/// 设置 Dependency-track 的访问地址. eg. http://dtrack.abc.local:8081.
#[arg(
short,
long,
value_name = "Url",
default_value = "http://127.0.0.1:8081"
)]
pub(crate) url: Option<String>,
/// 设置dependencytrack的apikey. eg. adfadfe343g.
pub(crate) url: Option<Url>,
/// 设置 Dependency-track 的apikey. eg. adfadfe343g.
#[arg(
short,
long,
value_name = "Apikey",
default_value = "Oh9LHLfrLgk77e67DEZtiitOWZwvFVXI"
)]
pub(crate) key: Option<String>,
/// 设置dependencytrack的项目名称.

/// 设置 Dependency-track 的连接代理. eg. http://127.0.0.1:8080.
#[arg(
long,
value_name = "Proxy",
)]
pub(crate) proxy: Option<Url>,
/// 设置 Dependency-track 的项目名称.
#[arg(short, long, value_name = "Project Name", default_value = "test")]
pub(crate) project: Option<String>,
/// 设置dependencytrack的项目版本.
/// 设置 Dependency-track 的项目版本.
#[arg(short, long, value_name = "Project Version", default_value = "default")]
pub(crate) edition: Option<String>,
/// 设置dependencytrack的文件.
/// 设置 Dependency-track 的文件.
#[arg(short, long, value_name = "Bom File")]
pub(crate) file: Option<String>,
/// 设置dependencytrack的规则.
/// 设置 Dependency-track 的规则.
#[arg(short, long, value_name = "Rule")]
pub(crate) rule: Option<String>,
/// 输出dependencytrack版本信息.
#[arg(
short,
long,
value_name = "Dependency-Track Version",
default_value_t = false
)]
/// 输出 Dependency-track 版本信息.
#[arg(short, long, default_value_t = false)]
pub(crate) dversion: bool,
/// 设置dependencytrack的扫描结果存储位置.
/// 设置 Dependency-track 的扫描结果存储位置.
#[arg(
short,
long,
value_name = "Scan Result",
default_value = "results.json"
)]
pub(crate) output: Option<String>,
/// 设置输出日志的级别(选择off不输出日志)
#[arg(
short,
long,
default_value = "debug",
value_parser = clap::builder::PossibleValuesParser::new(["off", "debug", "info", "warn", "error"])
.map(|s| log::LevelFilter::from_str(&s).unwrap()),
)]
pub(crate) log_level: log::LevelFilter,
}
Loading

0 comments on commit 7bc782c

Please sign in to comment.