Skip to content

Instantly share code, notes, and snippets.

@badboy
Last active March 24, 2016 23:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save badboy/0cbc3411b6c23c1cb33c to your computer and use it in GitHub Desktop.
Save badboy/0cbc3411b6c23c1cb33c to your computer and use it in GitHub Desktop.
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