Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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