Asked  10 Months ago    Answers:  5   Viewed   9 times

I am using blow command to publish a release on Github repo:

curl -X POST -H "Authorization: token xxxxxxxxx"  -d '{"tag_name": "test", "name":"release-0.0.1","body":"this is a test release"}'  https://api.github.com/repos/xxxxxx

I can see that a new release is created. But there are two download buttons under it:

Source code (zip)
Source code (tar.gz)

How can I make a release without source code?

If I can't remove the source code attachment, how can I upload additional binary files? I tried to use the API Upload a release asset like this: POST https://<upload_url>/repos/:owner/:repo/releases/:id/assets?name=foo.zip, it returns successfully but I couldn't find the binaries on Github release tab.

 Answers

3

To create a new release and upload additional binaries, you can :

  • create the release using POST /repos/:username/:repo/releases and store the upload_url field from the response
  • upload your asset using POST $upload_url with additional parameters name and optional label (refer to this)

A quick example using bash, curl and jq (JSON parser) :

#!/bin/bash

token=YOUR_TOKEN
repo=username/your-repo

upload_url=$(curl -s -H "Authorization: token $token"  
     -d '{"tag_name": "test", "name":"release-0.0.1","body":"this is a test release"}'  
     "https://api.github.com/repos/$repo/releases" | jq -r '.upload_url')

upload_url="${upload_url%{*}"

echo "uploading asset to release to url : $upload_url"

curl -s -H "Authorization: token $token"  
        -H "Content-Type: application/zip" 
        --data-binary @test.zip  
        "$upload_url?name=test.zip&label=some-binary.zip"
Thursday, August 12, 2021
4

You can consider using GraphQL API v4 to perform commit count for multiple repositories at the same times using aliases. The following will fetch commit count for all branches of 3 distinct repositories (up to 100 branches per repo) :

{
  gson: repository(owner: "google", name: "gson") {
    ...RepoFragment
  }
  martian: repository(owner: "google", name: "martian") {
    ...RepoFragment
  }
  keyboard: repository(owner: "jasonrudolph", name: "keyboard") {
    ...RepoFragment
  }
}

fragment RepoFragment on Repository {
  name
  refs(first: 100, refPrefix: "refs/heads/") {
    edges {
      node {
        name
        target {
          ... on Commit {
            id
            history(first: 0) {
              totalCount
            }
          }
        }
      }
    }
  }
}

Try it in the explorer

RepoFragment is a fragment which helps to avoid the duplicate query fields for each of those repo

If you only need commit count on the default branch, it's more straightforward :

{
  gson: repository(owner: "google", name: "gson") {
    ...RepoFragment
  }
  martian: repository(owner: "google", name: "martian") {
    ...RepoFragment
  }
  keyboard: repository(owner: "jasonrudolph", name: "keyboard") {
    ...RepoFragment
  }
}

fragment RepoFragment on Repository {
  name
  defaultBranchRef {
    name
    target {
      ... on Commit {
        id
        history(first: 0) {
          totalCount
        }
      }
    }
  }
}

Try it in the explorer

Wednesday, July 28, 2021
 
1

I had missed the paragraph on setting credentials on the github readme, so here is some sample code in case anybody else needs it.

var googleOauth2Client = new OAuth2Client(googleClientId,googleClientSecret, googleCallbackUrl);
googleOauth2Client.setCredentials({
  refresh_token: saved_refresh_token
});
googleOauth2Client.refreshAccessToken(function(err, tokens){
  response.send({
    access_token: tokens.access_token
  });
});
Wednesday, August 25, 2021
 
Antonio
 
4

It turned out to be an odd permission issue between the .gitconfig file that Github for Mac created with root privileges and Tower wasn't able to access.

A simple change of ownership privileges fixed the problem. Ownership can be changed like so:

sudo chown -R username [file|directory]

Explanation:

  • sudo - grant root privileges
  • chown - changes the ownership
  • -R - for recursive changing of files
  • username - username of new owner
  • [file|directory] - file or directory for change to occur (if directory is specified it's going to recursively change all the files inside)
Monday, October 11, 2021
 
Null
 
3
git ls-remote --heads <repo-url>

Man page of git ls-remote.

For example, to git the branches of git's git repo use

$git ls-remote --heads git://github.com/git/git.git      
121f71f0da1bc9a4e1e96be2c3e683191a82a354    refs/heads/maint
f623ca1cae600e97cb0b38131fdd33e4fb669cf8    refs/heads/master
8e148144574e6c6511b591286e44a677a260d760    refs/heads/next
fcdb578342aeaf355c296026af08093b20aab9b4    refs/heads/pu
5321cb29c8f709669c5e4a04f502cd984623592c    refs/heads/todo
Friday, December 17, 2021
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :