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

Provide a plain text file with the latest version of Camel K for easier automation of downloading via the tooling #1009

Closed
bfitzpat opened this issue Oct 11, 2019 · 7 comments

Comments

@bfitzpat
Copy link
Contributor

We have been working on setting up the VS Code extension to automatically download the Camel K CLI. For example, the Kubernetes extension provides this file: https://storage.googleapis.com/kubernetes-release/release/stable.txt. It simply provides the version number as a string (v1.16.1) that is then used in a generated URL - https://storage.googleapis.com/kubernetes-release/release/${version.result.trim()}/bin/${osString}/amd64/${binFile}

It would be great if we could do the same thing for the Camel K CLI - https://github.com/apache/camel-k/releases/download/${version}/camel-k-client-${version}-${platformString}-64bit.tar.gz

Maybe a simple text file in the github repo with "1.0.0-M2" in it?

@lburgazzoli
Copy link
Contributor

You can eventually use github api like:

curl -s https://api.github.com/repos/apache/camel-k/releases/latest

Which gives you a json with information about the assets included in latest release.

@bfitzpat
Copy link
Contributor Author

Which gives you a json with information about the assets included in latest release.

That spits out a ton of detail in that json file, but we could certainly go that route. I was just looking for something simple. :)

@lburgazzoli
Copy link
Contributor

I usually do something like that do download releases:

curl -s https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/releases/latest \
    | jq --raw-output ".assets[] | select(.name | startswith(\"${BINARY_NAME}\")) \
    | .browser_download_url"

@bfitzpat
Copy link
Contributor Author

I don't know that I can rely on curl for Windows machines, which is a problem.

@lburgazzoli
Copy link
Contributor

I meant that you can probably use a json path like the one I shown from your extension

@bfitzpat
Copy link
Contributor Author

bfitzpat commented Oct 11, 2019

That works. :)

async function getLatestCamelKVersion(): Promise<Errorable<string>> {
	const latestURL = 'https://api.github.com/repos/apache/camel-k/releases/latest';
	const downloadResult = await downloader.toTempFile(latestURL);
	if (failed(downloadResult)) {
		return { succeeded: false, error: [`Failed to establish kubectl stable version: ${downloadResult.error[0]}`] };
	}
	const rawtext = fs.readFileSync(downloadResult.result, 'utf-8');
	let latestJSON = JSON.parse(rawtext);
	let tagName = latestJSON.tag_name;
	if (tagName) {
		return { succeeded: true, result: tagName };		
	}
	return { succeeded: false, error: [`Failed to retrieve latest Apache Camel K version tag from : ${latestURL}`] };
}

@bfitzpat
Copy link
Contributor Author

Thanks Luca! Considering this one resolved. :)

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

2 participants