Compare commits
12 Commits
Author | SHA1 | Date |
---|---|---|
Cadey Ratio | e94e032942 | |
Cadey Ratio | 5c48459414 | |
Cadey Ratio | 26999f5f2c | |
Cadey Ratio | 1a0bd1fcc8 | |
Cadey Ratio | 9ad6a78579 | |
Cadey Ratio | a49864c419 | |
Cadey Ratio | 7317c2425e | |
Cadey Ratio | 26894c7fad | |
Cadey Ratio | 8b55a1cfcf | |
Cadey Ratio | 613dd68f04 | |
Cadey Ratio | 8c4017a3b3 | |
Cadey Ratio | e1db8c4df4 |
|
@ -3,7 +3,7 @@ name: tests/release
|
|||
|
||||
steps:
|
||||
- name: rust tests
|
||||
image: "rust:1"
|
||||
image: "reg.tulpa.dev/rust:1"
|
||||
pull: always
|
||||
commands:
|
||||
- cargo test --all
|
||||
|
|
20
CHANGELOG.md
20
CHANGELOG.md
|
@ -6,6 +6,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
## Unreleased
|
||||
|
||||
## 0.7.1
|
||||
|
||||
Fix a minor parsing bug
|
||||
|
||||
## 0.7.0
|
||||
|
||||
Support reading version data from `Cargo.toml`
|
||||
|
||||
## 0.6.1
|
||||
|
||||
Fixed a logic error in release cutting.
|
||||
|
||||
## 0.5.2
|
||||
|
||||
Detect tags better.
|
||||
|
||||
## 0.5.1
|
||||
|
||||
Initialize `pretty_env_logger` on app boot. Oops.
|
||||
|
||||
## 0.5.0
|
||||
|
||||
A lot of internals to this program were exposed to external consumers. This was
|
||||
|
|
|
@ -98,6 +98,17 @@ version = "0.5.4"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "130aac562c0dd69c56b3b1cc8ffd2e17be31d0b6c25b61c96b76231aa23e39e1"
|
||||
|
||||
[[package]]
|
||||
name = "cargo_toml"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "513d17226888c7b8283ac02a1c1b0d8a9d4cbf6db65dfadb79f598f5d7966fe9"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"serde_derive",
|
||||
"toml",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.54"
|
||||
|
@ -348,9 +359,10 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "gitea-release"
|
||||
version = "0.5.0"
|
||||
version = "0.7.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"cargo_toml",
|
||||
"comrak",
|
||||
"elfs",
|
||||
"git2",
|
||||
|
@ -365,6 +377,7 @@ dependencies = [
|
|||
"structopt",
|
||||
"tempfile",
|
||||
"tokio",
|
||||
"toml",
|
||||
"url",
|
||||
]
|
||||
|
||||
|
@ -881,9 +894,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.17"
|
||||
version = "1.0.24"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1502d12e458c49a4c9cbff560d0fe0060c252bc29799ed94ca2ed4bb665a0101"
|
||||
checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71"
|
||||
dependencies = [
|
||||
"unicode-xid",
|
||||
]
|
||||
|
@ -1100,18 +1113,18 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.111"
|
||||
version = "1.0.117"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9124df5b40cbd380080b2cc6ab894c040a3070d995f5c9dc77e18c34a8ae37d"
|
||||
checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.111"
|
||||
version = "1.0.117"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3f2c3ac8e6ca1e9c80b8be1023940162bf81ae3cffbb1809474152f2ce1eb250"
|
||||
checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -1209,9 +1222,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.29"
|
||||
version = "1.0.48"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb37da98a55b1d08529362d9cbb863be17556873df2585904ab9d2bc951291d0"
|
||||
checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -1353,6 +1366,15 @@ dependencies = [
|
|||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "0.5.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-service"
|
||||
version = "0.3.0"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "gitea-release"
|
||||
version = "0.5.0"
|
||||
version = "0.7.1"
|
||||
authors = ["Christine Dodrill <me@christine.website>"]
|
||||
edition = "2018"
|
||||
|
||||
|
@ -8,16 +8,19 @@ edition = "2018"
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0"
|
||||
cargo_toml = "0.8.1"
|
||||
comrak = "0.7"
|
||||
git2 = "0.13"
|
||||
http = "0.2"
|
||||
kankyo = "0.3"
|
||||
log = "0.4"
|
||||
pretty_env_logger = "0"
|
||||
reqwest = { version = "0.10", features = ["json"] }
|
||||
serde_json = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
structopt = { version = "0.3", default-features = false }
|
||||
tokio = { version = "0.2", features = ["macros"] }
|
||||
toml = "0.5.7"
|
||||
url = "2"
|
||||
|
||||
gitea = { path = "./gitea" }
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
"homepage": "",
|
||||
"owner": "nmattia",
|
||||
"repo": "naersk",
|
||||
"rev": "a82fd7dc31a58c462b6dfa9d9d886fa2cc75dfd4",
|
||||
"sha256": "00bjwir52y6jbf0b22qy9qxramw35k5fc7kp9hymr1zgpmw9kbwg",
|
||||
"rev": "529e910a3f423a8211f8739290014b754b2555b6",
|
||||
"sha256": "0bcy9nmyaan5jvp0wg80wkizc9j166ns685rdr1kbhkvdpywv46y",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/nmattia/naersk/archive/a82fd7dc31a58c462b6dfa9d9d886fa2cc75dfd4.tar.gz",
|
||||
"url": "https://github.com/nmattia/naersk/archive/529e910a3f423a8211f8739290014b754b2555b6.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
},
|
||||
"nixpkgs-mozilla": {
|
||||
|
@ -17,10 +17,10 @@
|
|||
"homepage": null,
|
||||
"owner": "mozilla",
|
||||
"repo": "nixpkgs-mozilla",
|
||||
"rev": "e912ed483e980dfb4666ae0ed17845c4220e5e7c",
|
||||
"sha256": "08fvzb8w80bkkabc1iyhzd15f4sm7ra10jn32kfch5klgl0gj3j3",
|
||||
"rev": "efda5b357451dbb0431f983cca679ae3cd9b9829",
|
||||
"sha256": "11wqrg86g3qva67vnk81ynvqyfj0zxk83cbrf0p9hsvxiwxs8469",
|
||||
"type": "tarball",
|
||||
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/e912ed483e980dfb4666ae0ed17845c4220e5e7c.tar.gz",
|
||||
"url": "https://github.com/mozilla/nixpkgs-mozilla/archive/efda5b357451dbb0431f983cca679ae3cd9b9829.tar.gz",
|
||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,16 +9,19 @@ pub async fn run(
|
|||
rm: ReleaseMeta,
|
||||
) -> Result<()> {
|
||||
let repo = git2::Repository::open(".")?;
|
||||
let tag = tag.unwrap_or(version::read_version("VERSION".into())?);
|
||||
let tag = tag.unwrap_or(version::read("VERSION".into())?);
|
||||
let vtag = format!("v{}", tag);
|
||||
|
||||
if git::has_tag(&repo, tag.clone())? {
|
||||
return Err(anyhow::anyhow!("what"));
|
||||
if git::has_tag(&repo, vtag.clone())? {
|
||||
println!("release {} already released", vtag);
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let desc = changelog::read(fname, tag.clone())?;
|
||||
let cli = gitea::Client::new(common.server, common.token, crate::APP_USER_AGENT)?;
|
||||
let vtag = format!("v{}", tag);
|
||||
let repo = cli.get_repo(common.owner.clone(), common.repo.clone()).await?;
|
||||
let repo = cli
|
||||
.get_repo(common.owner.clone(), common.repo.clone())
|
||||
.await?;
|
||||
|
||||
let cr = gitea::CreateRelease {
|
||||
body: desc,
|
||||
|
|
|
@ -6,6 +6,7 @@ use ::gitea_release::{cmd::{self, Cmd}};
|
|||
#[tokio::main]
|
||||
async fn main() -> Result<()> {
|
||||
let _ = kankyo::init();
|
||||
pretty_env_logger::init();
|
||||
let cmd = Cmd::from_args();
|
||||
|
||||
match cmd {
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
use anyhow::Result;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
pub(crate) fn read_version(fname: PathBuf) -> Result<String> {
|
||||
let version = fs::read_to_string(fname)?;
|
||||
Ok(version.trim().into())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn read_version() {
|
||||
let version = super::read_version("./testdata/VERSION".into()).unwrap();
|
||||
assert_eq!(version, "0.1.0");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
use anyhow::Result;
|
||||
use cargo_toml::Manifest;
|
||||
use std::fs::{self, File};
|
||||
use std::io::Read;
|
||||
|
||||
fn get_file_as_byte_vec(filename: &str) -> Option<Vec<u8>> {
|
||||
let f = File::open(&filename);
|
||||
if f.is_err() {
|
||||
log::debug!("can't read from Cargo.toml: {:?}", f.unwrap_err());
|
||||
return None;
|
||||
}
|
||||
let mut f = f.unwrap();
|
||||
let metadata = fs::metadata(&filename).expect("unable to read metadata");
|
||||
let mut buffer = vec![0; metadata.len() as usize];
|
||||
f.read(&mut buffer).expect("buffer overflow");
|
||||
|
||||
Some(buffer)
|
||||
}
|
||||
|
||||
pub fn read() -> Result<Option<String>> {
|
||||
log::debug!("reading version from Cargo.toml");
|
||||
let bytes = get_file_as_byte_vec("Cargo.toml");
|
||||
log::debug!("{:?}", bytes);
|
||||
|
||||
match bytes {
|
||||
Some(bytes) => {
|
||||
log::trace!("reading toml");
|
||||
let pkg : Result<Manifest, _> = toml::from_slice(&bytes);
|
||||
match pkg {
|
||||
Err(why) => {
|
||||
log::error!("error parsing Cargo.toml: {:?}", why);
|
||||
Err(why.into())
|
||||
}
|
||||
Ok(pkg) => {
|
||||
let version = pkg.package.unwrap().version;
|
||||
log::trace!("got version {}", version);
|
||||
Ok(Some(version))
|
||||
}
|
||||
}
|
||||
}
|
||||
None => Ok(None)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn read() {
|
||||
use super::read;
|
||||
let _ = pretty_env_logger::try_init();
|
||||
read().unwrap().unwrap();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
use anyhow::Result;
|
||||
use std::{fs, path::PathBuf};
|
||||
|
||||
mod cargo;
|
||||
|
||||
pub(crate) fn read(fname: PathBuf) -> Result<String> {
|
||||
let version = match read_fs(fname.clone()) {
|
||||
Ok(version) => version,
|
||||
Err(why) => {
|
||||
log::debug!("can't read {:?}: {:?}", fname, why);
|
||||
cargo::read().unwrap().unwrap()
|
||||
}
|
||||
};
|
||||
Ok(version)
|
||||
}
|
||||
|
||||
fn read_fs(fname: PathBuf) -> Result<String> {
|
||||
log::debug!("reading version data from {:?}", fname);
|
||||
Ok(fs::read_to_string(fname)?.trim().into())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn read_version() {
|
||||
let _ = pretty_env_logger::try_init();
|
||||
let version = super::read_fs("./testdata/VERSION".into()).unwrap();
|
||||
assert_eq!(version, "0.1.0");
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ const TAG: &'static str = "0.1.0";
|
|||
async fn cut() -> Result<()> {
|
||||
let _ = pretty_env_logger::try_init();
|
||||
let name = elfs::next();
|
||||
let token = std::env::var("DOMO_GITEA_TOKEN")?;
|
||||
let token = std::env::var("DOMO_GITEA_TOKEN").expect("wanted envvar DOMO_GITEA_TOKEN");
|
||||
|
||||
let cli = gitea::Client::new("https://tulpa.dev".into(), token.clone(), APP_USER_AGENT)?;
|
||||
debug!("created gitea client");
|
||||
|
|
Loading…
Reference in New Issue