I have a repo with source code / releases for a mac app and a server that regulates version updates.
I have one repo for the app and another for the update server I'm using squirrel.
My plan was to have the releases out of the repos. I think that that's a best practice.
I just tried to download the release which is in a private repo with this link
https://<TOKEN>:x-oauth-basic#github.com/user/repo/releases/download/v0.0.1/app-v0.0.1.zip
and it didn't work, it would be nice if it did =)
Thoughts? Is there any other way to do this? Should I just have the release in the server repo?
One Solution:
http://github.com/brant-hwang/get-git-private-repo-latest-release-zip
ID={YOUR_GITHUB_ID}
PW={YOUR_GITHUB_PASSWORD}
OWNER={OWNER}
REPO={REPOSITORY}
curl -u $ID:$PW https://api.github.com/repos/$OWNER/$REPO/releases/latest > latest.json
TAG_NAME=`cat latest.json | jq '.tag_name' | tr -d '"'`
URL="https://github.com/$OWNER/$REPO/archive/$TAG_NAME.zip"
curl -O -J -L -u $ID:$PW $URL
Outlined here in Korean :(
Related
How to use github cli to auto pull all newly created or updated repos to local pc?
I think I need to listen for new repo creation/updation and pull the repos. How to do it with cli?
If can't listen, I need to pull latest 100 repos to local machiene. How to do it?
I tried https://api.github.com/users/xxxx/repos?per_page=100. It gives in alphabetical order.
I use following code
#!/bin/sh
cat repolist.txt | while read line
do
REPOSRC=$line
LOCALREPO=$line
# We do it this way so that we can abstract if from just git later on
LOCALREPO_VC_DIR=$LOCALREPO/.git
if [ ! -d $LOCALREPO_VC_DIR ]
then
cd ~/xxxx
gh repo clone $REPOSRC
cd ~
else
cd ~
gh repo sync $REPOSRC -s $REPOSRC
fi
done
# End
The sort key
you're looking for seems to be sort=pushed.
Try curl -s 'https://api.github.com/users/xxxx/repos?sort=pushed&per_page=100' | jq '.[].name' to verify.
I'm looking for a way to get both the version number and license details from a repo providing I have the URL for the Repo. I have a way at the moment that doesn't work for all repos I am reviewing but it's basically html scraping.
I assume there is an API example somewhere that pulls these details?
some random examples
https://github.com/Microsoft/Terminal
https://github.com/leoasis/redux-immutable-state-invariant
https://github.com/zeroclipboard/zeroclipboard
What version do you need ? If a package.json file is present, you can use it and get the version in it:
curl -sL https://raw.githubusercontent.com/leoasis/redux-immutable-state-invariant/master/package.json | jq -r '.version'
For the latest release tag name (aka version), use
curl -sL https://api.github.com/repos/Microsoft/Terminal/releases/latest | jq -r '.tag_name'
To retreive the license, use the Github API and go to https://api.github.com/repos/zeroclipboard/zeroclipboard/license, e.g.
curl -sL https://api.github.com/repos/zeroclipboard/zeroclipboard/license | jq -r '.license.name'
`
any idea why this does not work:
D:\apache-tomcat-8.0.33\bin>"C:\Program Files\Git\bin\git.exe" -c core.askpass=true ls-remote -h https://tobias#wdmycloud/shares/githome/Repo.git HEAD
fatal: repository 'https://tobias#wdmycloud/shares/githome/Repo.git/' not found
I can successfully clone this repository using eclipse:
In Eclipse, you're using SSH, and on the commandline you're using HTTPS. Those are two different protocols, and the fact that one works doesn't necessarily mean the other will work, too. Try SSH URL instead:
"C:\Program Files\Git\bin\git.exe" -c core.askpass=true ls-remote -h ssh://tobias#wdmycloud/shares/githome/Repo.git HEAD
Regarding WD MyCloud, you will find tutorial to access a git repo through ssh, which is fairly easy to setup, considering all you need is a sshd running.
But for an https url to work, you would need an Apache server running, properly configured to support git http-backend.
Something along the line of an httpd.conf including:
# Configure Git HTTP Backend
SetEnv GIT_PROJECT_ROOT /www/example.com/git
SetEnv GIT_HTTP_EXPORT_ALL
# Note: Serve static files directly
AliasMatch ^/(.*/objects/[0-9a-f]{2}/[0-9a-f]{38})$ /var/www/git/$1
AliasMatch ^/(.*/objects/pack/pack-[0-9a-f]{40}.(pack|idx))$ /var/www/git/$1
# Note: Serve repository objects with Git HTTP backend
ScriptAliasMatch \
"(?x)^/(.*/(HEAD | \
info/refs | \
objects/info/[^/]+ | \
git-(upload|receive)-pack))$" \
/usr/libexec/git-core/git-http-backend/$1
And that is not standard, unless you set it up beforehand yourself.
Looking for particular command or python script to download all repositories or sub branches of the particular organization from Github at once
This gist (or this one) allows to list and clone all repos from an organization
curl -s https://api.github.com/orgs/twitter/repos?per_page=200 | ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}'
You have the same in python with the project muhasturk/gitim
It isn't hard to curl the zip archive of a repo instead (instead of cloning the repo):
curl -u '<git username>' -L -o master.zip https://github.com/<organization>/<reponame>/zipball/master
I am looking to backup all my Starred repositories and I'm searching for a simple a way to do it.
This should do it. Note you will need
jq
curl https://api.github.com/users/<user>/starred |
jq -r '.[].html_url' |
xargs -l git clone
If you don't want to use jq you can replace with this ugly awk line
awk '/^ {4}"html_url"/&&$0=$4' FS='"' |
Yes, here is a simple one-liner (change foo to your username):
USER=foo; curl "https://api.github.com/users/$USER/starred?per_page=1000" | grep -o 'git#[^"]*' | xargs -L1 git clone
Add -P parameter for xargs to increase speed by setting number of parallel processes (e.g. -P4 = 4 processes).
To raise the GitHub limits, you can authenticate by specifying your API key.
If you don't have any issues with ruby and can install a few gems, you can give this a shot.
gem install octokit git parallel
Then this should do it.
ruby -e "require 'octokit'; require 'git'; require 'parallel'; Parallel.each(Octokit.starred('__username__'), :in_processes=>4){|s| Git.clone(s[:html_url], s[:name])}"
For readability:
require 'octokit'
require 'git'
require 'parallel'
Parallel.each(Octokit.starred('__username__'), :in_processes=>4){|s| Git.clone(s[:html_url], s[:name])}
This does seem like overkill though.
You could also fetch the list as suggested, and create a new Repo for thoose projects that you are really interested on backuping. This method will help you update your backups easily.
Create a new repository, public/private, with submodules and clone/pull all toggether. You should see something like this.
git clone https://github.com/<user>/<repo>
cd <repo>
git submodule add https://github.com/<someone>/<repo1>
git submodule add https://github.com/<someother>/<repo2>
git submodule update --init --recursive
git commit -m "submodules added"
git push
Then do
git clone --recurse-submodules https://github.com/<user>/<repo>
# OR
git pull --recurse-submodules