Skip to content

Commit 5fce490

Browse files
committed
Simply fetch latest version from the dedicated file
It gets updated as part of the helm release workflow: https://github.com/helm/helm/blob/c5698e5e51949c4ab86a22c5566fac20e13d6f73/.github/workflows/release.yml#L49 This means the github token is no longer required, making it much nicer for composite actions wanting to leverage this one.
1 parent 859dc38 commit 5fce490

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

action.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ inputs:
66
required: true
77
default: 'latest'
88
token:
9-
description: GitHub token. Required only if 'version' == 'latest'
9+
description: GitHub token. Used to be reuired to fetch the latest version
1010
required: false
11+
deprecationMessage: 'GitHub token is no longer required'
1112
default: '${{ github.token }}'
1213
downloadBaseURL:
1314
description: 'Set the download base URL'

src/run.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ describe('run.ts', () => {
8686
expect(os.type).toHaveBeenCalled()
8787
})
8888

89-
test('getLatestHelmVersion() - return the stable version of HELM since its not authenticated', async () => {
90-
expect(await run.getLatestHelmVersion()).toBe('v3.13.3')
89+
test('getLatestHelmVersion() - return the stable version of HELM', async () => {
90+
expect(await run.getLatestHelmVersion()).toBe('v3.14.2')
9191
})
9292

9393
test('walkSync() - return path to the all files matching fileToFind in dir', () => {

src/run.ts

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import * as fs from 'fs'
99

1010
import * as toolCache from '@actions/tool-cache'
1111
import * as core from '@actions/core'
12-
import {Octokit} from '@octokit/action'
1312

1413
const helmToolName = 'helm'
1514
const stableHelmVersion = 'v3.13.3'
@@ -51,38 +50,15 @@ export function getValidVersion(version: string): string {
5150
// Gets the latest helm version or returns a default stable if getting latest fails
5251
export async function getLatestHelmVersion(): Promise<string> {
5352
try {
54-
const octokit = new Octokit()
55-
const response = await octokit.rest.repos.listReleases({
56-
owner: 'helm',
57-
repo: 'helm',
58-
per_page: 100,
59-
order: 'desc',
60-
sort: 'created'
61-
})
62-
63-
const releases = response.data
64-
const latestValidRelease: string = releases.find(
65-
({tag_name, draft, prerelease}) =>
66-
isValidVersion(tag_name) && !draft && !prerelease
67-
)?.tag_name
68-
69-
if (latestValidRelease) return latestValidRelease
53+
const response = await fetch('https://get.helm.sh/helm-latest-version')
54+
const release = (await response.text()).trim()
55+
return release
7056
} catch (err) {
7157
core.warning(
7258
`Error while fetching latest Helm release: ${err.toString()}. Using default version ${stableHelmVersion}`
7359
)
7460
return stableHelmVersion
7561
}
76-
77-
core.warning(
78-
`Could not find valid release. Using default version ${stableHelmVersion}`
79-
)
80-
return stableHelmVersion
81-
}
82-
83-
// isValidVersion checks if verison is a stable release
84-
function isValidVersion(version: string): boolean {
85-
return version.indexOf('rc') == -1
8662
}
8763

8864
export function getExecutableExtension(): string {

0 commit comments

Comments
 (0)