Skip to content
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

[Proposal] Deduce the latest version from the URL redirect #788

Open
i386x opened this issue Sep 1, 2023 · 1 comment
Open

[Proposal] Deduce the latest version from the URL redirect #788

i386x opened this issue Sep 1, 2023 · 1 comment

Comments

@i386x
Copy link

i386x commented Sep 1, 2023

Hello,

up to now the latest version of podman-compose is deduced using octokit:

async function findLatestVersion(): Promise<string> {
  const octokit = new Octokit()
  const response = await octokit.repos.getLatestRelease({
    owner: 'docker',
    repo: 'compose'
  })
  return response.data.tag_name
}

which requires GITHUB_TOKEN. This complicates things a bit when testing GitHub actions using act.

Today I just noticed that if the latest keyword is appended to https://github.com/docker/compose/releases/ then GitHub redirects to the latest version, e.g. https://github.com/docker/compose/releases/latest become https://github.com/docker/compose/releases/tag/v2.21.0 (at the time of writing this post) from which v2.21.0 can be easily extracted. In words of curl:

$ curl -Ls -o /dev/null -w '%{url_effective}\n' 'https://github.com/docker/compose/releases/latest'
https://github.com/docker/compose/releases/tag/v2.21.0

Its also possible to fetch the latest release anonymously:

$ curl -L https://api.github.com/repos/docker/compose/releases/latest
{
  "url": "https://api.github.com/repos/docker/compose/releases/119350941",
  "assets_url": "https://api.github.com/repos/docker/compose/releases/119350941/assets",
  "upload_url": "https://uploads.github.com/repos/docker/compose/releases/119350941/assets{?name,label}",
  "html_url": "https://github.com/docker/compose/releases/tag/v2.21.0",
  "id": 119350941,
  "author": {
    "login": "github-actions[bot]",
    "id": 41898282,
....
}

To be honest I have no idea why octokit needs GITHUB_TOKEN for this case.

@i386x
Copy link
Author

i386x commented Sep 1, 2023

The workaround:

jobs:
  tests:
    steps:
      - name: Determine the latest version of docker-compose
        id: vars
        run: |
          LATEST=$(curl -Ls -o /dev/null -w '%{url_effective}' 'https://github.com/docker/compose/releases/latest')
          echo "docker_compose_latest=${LATEST##*/}" >> $GITHUB_OUTPUT
      - uses: KengoTODA/actions-setup-docker-compose@v1
        with:
          version: '${{ steps.vars.outputs.docker_compose_latest }}'

Please feel free to close this if you don't wish to implement the feature.

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

No branches or pull requests

1 participant