feat: Default docker-compose version to latest (#643)
* test: add expected behavior as a test case Signed-off-by: Kengo TODA <skypencil@gmail.com> * implement the necessary feature Signed-off-by: Kengo TODA <skypencil@gmail.com> * add a missing return type Signed-off-by: Kengo TODA <skypencil@gmail.com> * ci: try to run action without GITHUB_TOKEN env var Signed-off-by: Kengo TODA <skypencil@gmail.com> * input version is not required Signed-off-by: Kengo TODA <skypencil@gmail.com> * update the distributed package Signed-off-by: Kengo TODA <skypencil@gmail.com> * fix eslint warning Signed-off-by: Kengo TODA <skypencil@gmail.com> * provide GITHUB_TOKEN to create Octokit Signed-off-by: Kengo TODA <skypencil@gmail.com> * docs: update README.md Signed-off-by: Kengo TODA <skypencil@gmail.com> * docs: update README.md Signed-off-by: Kengo TODA <skypencil@gmail.com> * docs: update README.md Signed-off-by: Kengo TODA <skypencil@gmail.com> * docs: update README.md Signed-off-by: Kengo TODA <skypencil@gmail.com> * update distributions Signed-off-by: Kengo TODA <skypencil@gmail.com> Signed-off-by: Kengo TODA <skypencil@gmail.com>
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import {cacheFile, downloadTool} from '@actions/tool-cache'
|
||||
import {exec} from '@actions/exec'
|
||||
import * as core from '@actions/core'
|
||||
import {Octokit} from '@octokit/action'
|
||||
|
||||
export async function runCommand(command: string): Promise<string> {
|
||||
let output = ''
|
||||
@@ -34,7 +36,20 @@ async function installOnLinux(version: string): Promise<string> {
|
||||
return cachedPath
|
||||
}
|
||||
|
||||
async function findLatestVersion(): Promise<string> {
|
||||
const octokit = new Octokit()
|
||||
const response = await octokit.repos.getLatestRelease({
|
||||
owner: 'docker',
|
||||
repo: 'compose'
|
||||
})
|
||||
return response.data.tag_name
|
||||
}
|
||||
|
||||
export async function install(version: string): Promise<string> {
|
||||
if (version === 'latest') {
|
||||
version = await findLatestVersion()
|
||||
core.info(`Requested to use the latest version: ${version}`)
|
||||
}
|
||||
switch (process.platform) {
|
||||
case 'linux':
|
||||
return installOnLinux(version)
|
||||
|
||||
@@ -4,7 +4,7 @@ import {install} from './install'
|
||||
async function run(): Promise<void> {
|
||||
try {
|
||||
const version: string = core.getInput('version', {
|
||||
required: true
|
||||
trimWhitespace: true
|
||||
})
|
||||
const commandPath = await install(version)
|
||||
core.addPath(commandPath)
|
||||
|
||||
Reference in New Issue
Block a user