Programmatically add files to a GitHub download page - github

[[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.)

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.

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!

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

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).

Related

Is there a way to add custom "badges" to files on GitHub?

I have it in my head to help people at my company get better by finding a way to highlight and call out good code.
In particular, I'd like to be able to mark a file (not a repository or directory) as having a "gold star" (or another badge) so people browsing our source code who see the badge can see they're looking at a really good implementation they might take inspiration from.
I'm taking inspiration from the code owners feature on GitHub where there's a little padlock icon on a file if it's assigned ownership by the CODEOWNERS file.
Is it possible to do a custom "badge" on GitHub? If so, what's the API?
Browsing the GitHub documentation and searching online, I wasn't able to find anything explaining how to do something like this. Most folks were talking about the little images badges like the code coverage badges people put in their readme files.
Checkout this thread. You can submit feature request to GitLab and GitHub or in case of GitLab code your own feature and submit PR.
Here are some closely related discussions. Probably you have already seen them and are not looking for them but you might use them to get idea of how to create the feature that you want.
The Shields service (at shields.io) provides a way to create custom badges for your projects. These are badges are very common and are frequently used to show status information about the project, or demonstrate tools that were used for the development of your project. (...more)
Also checkout Bring Your Own Badge

Disable zip downloads from github

Is there any way to disable viewers to download my files from github?
I want to show my work, but I am afraid anybody can steal my code.
You can't, Github actually means you want to share something with the community, or you are showcasing your work in the open source community. Unfortunately you cannot restrict the users from downloading your content from your Repository.
Alternatively what you can do Just make your Repository private. But then in this case you are not able to make you work available to view for audience.
More you can read here :-
https://help.github.com/en/github/building-a-strong-community/limiting-interactions-in-your-repository
Disabling zip/tarballs on GitHub at the moment seems to be impossible, but it would be useful for those using git submodules, which are not included in the automatic created archives, where the repository owner could replace them with a continuous integration job with something like git-archive-all.

Can i fork this code from gist and using it for my own projects?

Hello I'm new to Github/Gist and I want to use this code, but I need to modify it a little bit. Can i just fork this code and modify it to use it for my own projects? Or do i have to link to the author etc.? Here is the link: https://gist.github.com/learncodeacademy/777349747d8382bfb722
Thank you!
Github repositories are meant to be forked. You don't have to ask an author for permission. Anyway, the gist you linked to has already been forked 30 times.
When you are using a forked repository.It shows up as "forked from xyz". So attribution is automatic. But if you want to, you can always give an extra credit to the author by mentioning it specifically.
Forking a repository on Github, creates an individual copy of the code. This feature is meant to encourage collaboration as well as allow you to experiment with the repositories code. Forking can be used to propose new changes to someone else's code or jumpstart an idea or a new project. As the repository was created by someone else, it is always important to understand the limitations of using their code for your own projects (especially if you plan on selling this product). Every repository created on Github has the chance to create a license file. This file will tell you what you can or cannot do with the forked code. Often open source code is meant to be used and shared with everyone, but it is still good to check. Here is Githubs documentation on forking repositories: https://help.github.com/articles/fork-a-repo/. For more information on licensing files see http://choosealicense.com/. Github gists follow the same standard. If you are still worried, it does not hurt to contact the owner of the repository and verify that you can use it for your own projects.
The point of open sourcing code on GitHub is for others to take and use for themselves and learn from it. Also, like fuchsteufelswild said, when forking on GitHub it automatically gives credit to the author so you should be good.

How do I post code to GitHub?

I've looked everywhere but I can't find any way to post code to GitHub. I tried making a repository but then it tells me I have to download a command prompt thing?
Why can't I just post code directly to it? Is there any other way?
If you are simply looking for a way to put some code online, then you can use another feature of that site calles "gists".
If you are on a mac, then there is another app you can use (made by the GitHub guys).
But the most relevant piece of software is what you refer to as " command prompt thing", which is a version control application with a relatively steep learning curve called GIT.
On a final note you might be misunderstanding what GitHub is useful for and might be better off looking at something a bit less complicated. If you are willing to explain exactly what you are looking for then i'm sure the StackOverflow community will be willing to help you :)
You may use github's gist.
Although, the main point of using github is to share git repositories.
While GitHub has recently added limited support for editing files through the web interface, it's intended as hosting for software projects using the Git source control software. The most-used interface is the command-line git tool, though there are graphical interfaces such as TortoiseGit as well as Git components for many IDEs.
If all you're looking for is a place to put small code fragments for sending to others (like a pastebin), then you probably want Gists instead: http://gist.github.com/
Github is a code hosting site for Git.
The "command prompt thingy" is likely Git. If you don't use Git, it's unlikely you want Github either.
Luckily there are graphical Git front ends such as SmartGit.

Is it possible to somehow migrate from Google Code to Github?

We have a fairly large project, and I've decided that Google Code is not quite living up to expectations. Github looks like a much more suitable platform -- but I feel like there's no escape for us. Is it a case of migrating stuff over manually? We're using svn currently, so I understand that we'll need to move to git somehow - is this going to be possible considering that I don't have admin access to our repository? Also, I know this is subjective and I don't want to start a holy war, but please also comment on your feelings about Google Code vs Github. Should we also be considering SourceForge?
I've used all, and now I am using github and I am completely satisfied. Sourceforge had annoying ads and was slow, google code didn't have the features I wanted/needed.
As for moving to github, they have a guide here, the process should be quite simple:
http://help.github.com/svn-importing/
We're using svn currently, so I understand that we'll need to move to git somehow - is this going to be possible considering that I don't have admin access to our repository?
Nope, you can use git svn to convert a repo, even if you don't have admin access. Here's a good tutorial (from one of the GitHub guys, no doubt) that explains how to convert an SVN repo to Git (including how to migrate tags and branches properly, which git-svn doesn't do very well).
but please also comment on your feelings about Google Code vs Github.
I've never used Google Code for personal projects. I know from a visitor's standpoint, I like the interface and tools used by GitHub a lot better.
Should we also be considering SourceForge?
Ugh... I personally think SourceForge is probably the worst of the free source code hosting facilities nowadays.
I think before you go through all the work to migrate to github (which is great yes) I would consider what your problem actually is. If it is just that you are using svn and that is not a distributed version control system you could just migrate your google code repository to be HG (Mercurial) based and you would get all the benefits of a distributed version control system but could otherwise stay at google code (which has great features that github does not have as well..)
Google announced today that they're closing Google Code. They added a migration tool to export projects to GitHub, it just takes one click.