Last active
March 24, 2016 23:57
-
-
Save badboy/0cbc3411b6c23c1cb33c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
extern crate hyper; | |
extern crate hubcaps; | |
use std::{env, process}; | |
use hyper::Client; | |
use hubcaps::{Github, ReleaseOptions, Credentials}; | |
fn main() { | |
env_logger::init().expect("Can't instantiate env logger"); | |
let token = match env::var("GH_TOKEN") { | |
Ok(token) => token, | |
_ => { | |
println!("example missing GH_TOKEN"); | |
process::exit(1); | |
} | |
}; | |
let client = Client::new(); | |
let credentials = Credentials::Token(token); | |
let github = Github::new( | |
format!("hubcaps/{}", env!("CARGO_PKG_VERSION")), | |
&client, | |
credentials); | |
let user = "username"; | |
let repo = "my-library"; | |
let name = "ONE DOT OH"; | |
let body = "This is a long long body"; | |
let tag = "v1.0.0"; | |
let opts = ReleaseOptions::builder(tag) | |
.name(name) | |
.body(body) | |
.commitish("master") | |
.draft(false) | |
.prerelease(false) | |
.build(); | |
let repo = github.repo(user, repo); | |
let release = repo.releases(); | |
match release.create(&opts) { | |
Ok(_) => println!("Release created"), | |
Err(e) => println!("Failed to create release: {:?}", e), | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment