spring-cloud / spring-cloud-cli

Spring Cloud CLI features
Apache License 2.0
155 stars 80 forks source link

Make https://github.com/spring-cloud/spring-cloud-cli/releases/latest redirect to latest Tag #163

Open gasrios opened 3 years ago

gasrios commented 3 years ago

Enhancement

This is not code related. Several GitHub projects, including https://github.com/spring-projects/spring-boot , implement behavior that redirects "latest" URLs to their latest release, e.g.

https://github.com/spring-projects/spring-boot/releases/latest

as of now redirects to

https://github.com/spring-projects/spring-boot/releases/tag/v2.3.4.RELEASE

This does not happen for https://github.com/spring-cloud/spring-cloud-cli/releases/latest , which currently redirects to

https://github.com/spring-cloud/spring-cloud-cli/releases

This redirect feature is extremely useful when implementing automated installation scripts, and it would be great to have it working for Spring Cloud CLI, too.

spencergibb commented 3 years ago

Is this a feature of GitHub?

gasrios commented 3 years ago

I think so, but it is triggered by actions taken by maintainers when a new release is created. See https://stackoverflow.com/questions/24827437/github-latest-release-button-capability

"If you define releases without ever attaching a binary to any of them, then 'latest' redirects you to the releases page of your project indeed."

gasrios commented 3 years ago

@spencergibb This might help: https://docs.github.com/en/free-pro-team@latest/github/administering-a-repository/linking-to-releases

And also: https://gist.github.com/steinwaywhw/a4cd19cda655b8249d908261a62687f8#gistcomment-2602381

I did some testing and looks like GitHub can create releases from tags you create (git tag -m "${MESSAGE}" -a "${TAG}" && git push origin "${TAG}"), but, unless you create releases directly on GitHub (which in turn will create the tag for you), the redirect behavior will not work.

I also tried retrieving the same information using the API, and got an error:

$ curl -s https://api.github.com/repos/spring-cloud/spring-cloud-cli/releases/latest
{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/repos#get-the-latest-release"
}

All this suggests your current process creates and pushes tags to GitHub. Would it be possible to support creating releases instead, for example using GitHub CLI (https://cli.github.com/manual/gh_release_create)?

spencergibb commented 3 years ago

"If you define releases without ever attaching a binary to any of them, then 'latest' redirects you to the releases page of your project indeed".

We don't do binary releases to GitHub at all. I'm not sure we want to change our release process right now, but I'll mark it to discuss.

gasrios commented 3 years ago

"If you define releases without ever attaching a binary to any of them, then 'latest' redirects you to the releases page of your project indeed".

We don't do binary releases to GitHub at all. I'm not sure we want to change our release process right now, but I'll mark it to discuss.

It's likely this feedback was incorrect (sorry about that, I was still in the middle of my research), please see my other comment, just after that one.

My own tests have shown that the issue probably is your current release process creates tags, then pushes them to GitHub. GitHub will create a release associated to the new tag, but not a redirect from "latest" to it.

The fix would be to change that process, so you create releases, and delegate creating the associated tag to GitHub, which happens automatically.

spencergibb commented 3 years ago

Either way it's a change in release process