actions-setup-docker-compose
actions-setup-docker-compose copied to clipboard
[Proposal] Deduce the latest version from the URL redirect
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.
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.