Skip to content

Github API /repos/<repo>/releases/latest not working #2824

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pierwill opened this issue Jul 13, 2021 · 9 comments
Open

Github API /repos/<repo>/releases/latest not working #2824

pierwill opened this issue Jul 13, 2021 · 9 comments
Labels

Comments

@pierwill
Copy link
Member

I am trying to get the number of the latest rustup release with the following:

curl --silent "https://api.github.com/repos/rust-lang/rustup/releases/latest" | # Get latest release from GitHub api
    grep '"tag_name":' |                                                 # Get tag line
    sed -E 's/.*"([^"]+)".*/\1/'                                         # Pluck JSON value

This is currently not working with the rustup repository, although it does work with rust-lang/rust:

$ curl --silent "https://api.github.com/repos/rust-lang/rust/releases/latest" | 
    grep '"tag_name":' |                                           
    sed -E 's/.*"([^"]+)".*/\1/'                                   
1.53.0

This API would be great to have enabled for this repository!

@pierwill pierwill added the bug label Jul 13, 2021
@pierwill pierwill changed the title Github /repos/<repo>/releases/latest API not working Github API /repos/<repo>/releases/latest not working Jul 13, 2021
@rbtcollins
Copy link
Contributor

Can I ask what you are trying to accomplish@

@pierwill
Copy link
Member Author

pierwill commented Jul 13, 2021

I'm looking here: https://gist.github.com/lukechilds/a83e1d7127b78fef38c2914c4ececc3c

Turns out the tags endpoint does work:

curl --silent "https://api.github.com/repos/rust-lang/rustup/tags" |\
  grep '"name":' |\
  sed -E 's/.*"([^"]+)".*/\1/' |\
  head -n 1

@pierwill
Copy link
Member Author

pierwill commented Jul 13, 2021

Example script:

get_latest_release() {
    curl --silent "https://api.github.com/repos/rust-lang/rustup/tags" |\
        grep '"name":' |\
        sed -E 's/.*"([^"]+)".*/\1/' |\
        head -n 1
}

RUSTUP_VERSION=1.24.3
RUSTUP_LATEST_VERSION="$(get_latest_release)"
OUR_RUSTUP_SHA="a3cb081f88a6789d104518b30d4aa410009cd08c3822a1226991d6cf0442a0f8"

if [ $RUSTUP_VERSION != $RUSTUP_LATEST_VERSION ]; then
    echo "${RUSTUP_VERSION} is not the latest rustup version (${RUSTUP_LATEST_VERSION})"
    exit 1
fi

curl --proto '=https' --tlsv1.2 -sSf -O \
  https://raw.githubusercontent.com/rust-lang/rustup/${RUSTUP_VERSION}/rustup-init.sh

echo "${OUR_RUSTUP_SHA}  rustup-init.sh" | sha256sum --check --

@rbtcollins
Copy link
Contributor

rbtcollins commented Jul 13, 2021 via email

@kinnison
Copy link
Contributor

What problem are you trying to solve @pierwill ? Note, I'm not asking what you're trying to do, since that's pretty clear. I'm trying to work out why and what problem you're trying to solve, in case there's an easier way we can do that.

@pierwill
Copy link
Member Author

I've been working on ways to increase security when using rustup in environments like CI/CD, where we want to use a specific version of the install script and verify its checksum. As part of this, it might be nice to add a check/notification when a new version of the install script is available (i.e., a new rustup release), hence the call to the Github API. I thought there was a chance others might want to do something similar, so I figured I'd open the issue here. :)

@kinnison
Copy link
Contributor

I can find no setting about this, do you know where the config would be? Is it possible you need an API token which has rust-lang access to use that API?

@jyn514
Copy link
Member

jyn514 commented Jul 22, 2021

@pierwill rustup uses tags, not 'releases'. I think releases are a github thing and aren't tied into git. @pietroalbini set this up for rust-lang/rust in rust-lang/rust#76516, so it looks like you can configure triagebot to sync it automatically.

@pietroalbini
Copy link
Member

Yes, but triagebot doesn't support this style of changelog yet (which seems https://keepachangelog.com/en/1.0.0/). It'd need to be added to https://github.com/rust-lang/triagebot/tree/master/src/changelogs first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants