18

[[Please note that Github has changed a lot since this question was first asked; instead of "download page" read "new release".]]

I generate PDF documentation as part of my projects and I'd like them to stay in sync with my Git repository (it's not always possible for people to build their own since they often use proprietary fonts).

However, it's not really "correct" to add the PDFs to the repository since it's a derived file; furthermore, doing this adds significantly to the size of the commits and the size of the repository overall.

Is it possible to programmatically send files to the GitHub download page? (I know that tagged commits are automatically added there with git push --tags but I don't know where this is documented. I suppose I could do something fancy by adding a separate branch only containing the PDFs themselves — as done by the GitHub user pages — but I'm a bit rusty on using Git this way.)

Will Robertson
  • 62,540
  • 32
  • 99
  • 117
  • 1
    FWIW, I think it's quite reasonable to add PDF documentation into the repository under version control. It makes sense to me, and shouldn't increase the size because it'll only be diff, and the format may not be that different per change. – Noon Silk Sep 16 '09 at 05:21
  • Wouldn't the binary data not diff very well? To be honest I haven't really checked. – Will Robertson Sep 16 '09 at 05:56
  • It may not diff that well, but it depends how it's stored. Can't hurt to check it, and regardless, I wouldn't really worry. Your file will be what, 100kb? Maybe 300? Depends what your storage limit is. Personally, I'd consider it as part of a version of the software. At home I keep all relevant media for the project in source control. I mean, it is derrived, and if you can get it as a post-build, that's better (maybe), but I thnik it's acceptable, unless there are extreme space issues. – Noon Silk Sep 16 '09 at 06:04
  • I was hoping that there was an API call for uploading files (since you can upload arbitrary files to your project's download page), but there doesn't seem to be one. :/ If they every add one, though, then that would probably be a good way to go about it. – Xiong Chiamiov Nov 03 '09 at 20:32

4 Answers4

10

Github API v3 supports this feature.

GitHub also provides a maven plugin based on the java API that is part of the Eclipse Mylyn connector for GitHub.

There is a ruby gem called github_api.

The other answer talks about net-github-upload which is available for perl and ruby.

fmjrey
  • 1,141
  • 1
  • 10
  • 16
Mic92
  • 1,298
  • 15
  • 13
9

check out for net-github-upload which is available

for perl: http://github.com/typester/net-github-upload-perl and ruby: http://github.com/Constellation/ruby-net-github-upload

With that you can write a small script to upload and update your PDF easily. To sad there's no easy way provided by github guys themselves..

cheer!

RngTng
  • 1,229
  • 2
  • 12
  • 22
2

The GitHub blog post announcing that this feature has been disabled: https://github.com/blog/1302-goodbye-uploads

Joseph
  • 3,127
  • 2
  • 21
  • 11
1

I take it that by "GitHub download page", the owner means a repo–more specifically a branch– that can be downloaded via the "download" button.

If you want to add a file to a repo using the API, you will have to become familiar with the process described here: https://developer.github.com/v3/git/

It's not the easiest process in the world, but mastering it will force you to understand the concepts of blobs, trees, commits and references, amongst others.

You can't just "send a file" to a repo because you're working with Git, and Git has some "internal expectations" that you just can't ignore (it's impossible to think of GitHub as some sort of host that you can ftp). Explaining the flow required to create a file in a GitHub repo is certainly beyond the scope of the original question, but to provide a clear answer: no, it's not possible to programmatically upload a file on GitHub, but yes it is possible to programmatically push a file on GitHub".

There's a PHP library named GitHubTreePHP that lets you automate the process (Disclaimer: I wrote it).

alexduloz
  • 11
  • 2
  • The repository downloads pages no longer exist. This question nowadays would refer to the processing of adding binary files to a new "release" such as `https://github.com///releases/new` – Will Robertson Jul 04 '14 at 01:21