Skip to content

Commit

Permalink
only install new pulumi version when there's a newer one available (#…
Browse files Browse the repository at this point in the history
…1225)

Users can pass 'latest' as the 'pulumi-version' configuration setting.
This currently means that they always download the latest version of
the CLI, regardless of whether that's already installed or not.

We can do better here and check if the latest version matches the one
already installed on the runner, and in that case skip the download.
  • Loading branch information
tgummerer committed Jul 11, 2024
1 parent fa38144 commit 50acd71
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

## HEAD (Unreleased)

- fix: download latest version only when necessary when 'pulumi-version: latest'
is specified ((#1225)[https://github.com/pulumi/actions/pull/1225])

- fix: make `pulumi-version-file` work in non-install mode as well
((#1216)[https://github.com/pulumi/actions/pull/1216])

Expand Down
12 changes: 11 additions & 1 deletion src/libs/pulumi-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export async function downloadCli(range: string): Promise<void> {

const isPulumiInstalled = await io.which('pulumi');

if (isPulumiInstalled) {
if (isPulumiInstalled && range != 'latest') {
// Check for version of Pulumi CLI installed on the runner
const runnerVersion = await getVersion();

Expand Down Expand Up @@ -98,6 +98,16 @@ export async function downloadCli(range: string): Promise<void> {
}

const { version, downloads } = await getVersionObject(range);
if (isPulumiInstalled && range === 'latest') {
const runnerVersion = await getVersion();
if (runnerVersion && runnerVersion === version) {
core.info(
`Pulumi version ${runnerVersion} is already installed on this machine, and is the latest available. Skipping download`
);
return;
}
}


core.info(`Matched version: ${version}`);

Expand Down

0 comments on commit 50acd71

Please sign in to comment.