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

allow getting latest dev version #1051

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## HEAD (Unreleased)

**(none)**
- feat: allow installing the latest dev release automatically

---

Expand Down
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,13 @@ The action can be configured with the following arguments:
- `policyPacks` - (optional) Run one or more policy packs with the provided
`command`. Multiple values can be specified one per line (example: `<value | string>,...`).

- `policyPackConfigs` - (optional) Path(s) to JSON file(s) containing the
config for the policy pack with the corresponding "policy-pack" argument.
Multiple values can be specified one per line (example: `<value | string>,...`).
- `policyPackConfigs` - (optional) Path(s) to JSON file(s) containing the config
for the policy pack with the corresponding "policy-pack" argument. Multiple
values can be specified one per line (example: `<value | string>,...`).

- `pulumi-version` - (optional) Install a specific version of the Pulumi CLI.
Defaults to "^3"
Defaults to "^3". Allows a "dev" argument to download the latest unreleased
version.

- `remove` - (optional) Removes the target stack if all resources are destroyed.
Used only with `destroy` command.
Expand Down
16 changes: 16 additions & 0 deletions src/libs/libs/get-version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ export type Version = rt.Static<typeof VersionRt>;
const VersionsRt = rt.Array(VersionRt);

export async function getVersionObject(range: string): Promise<Version> {
if (range == 'dev') {
const result = await got('https://www.pulumi.com/latest-dev-version');
const version = 'v' + result.body.trim();
const date = new Date().toISOString();
const downloads = {
'linux-x64': `https://get.pulumi.com/releases/sdk/pulumi-${version}-linux-x64.tar.gz`,
'linux-arm64': `https://get.pulumi.com/releases/sdk/pulumi-${version}-linux-arm64.tar.gz`,
'darwin-x64': `https://get.pulumi.com/releases/sdk/pulumi-${version}-darwin-x64.tar.gz`,
'darwin-arm64': `https://get.pulumi.com/releases/sdk/pulumi-${version}-darwin-arm64.tar.gz`,
'windows-x64': `https://get.pulumi.com/releases/sdk/pulumi-${version}-windows-x64.zip`,
};
const checksums = 'https://get.pulumi.com/releases/sdk/pulumi-${version}-checksums.txt';
const latest = false;
return { version, date, downloads, checksums, latest };
}

const result = await got(
'https://raw.githubusercontent.com/pulumi/docs/master/data/versions.json',
{ responseType: 'json' },
Expand Down
7 changes: 6 additions & 1 deletion src/libs/pulumi-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ export async function downloadCli(range: string): Promise<void> {

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

const isUnsupportedVersion = semver.lt(version, '3.0.0');
let isUnsupportedVersion;
if (range == 'dev') {
isUnsupportedVersion = false;
} else {
isUnsupportedVersion = semver.lt(version, '3.0.0');
}

if (isUnsupportedVersion) {
core.warning(
Expand Down
Loading