Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
29960d0f5f |
@ -1,9 +1,5 @@
|
||||
# Change Log
|
||||
|
||||
## [4.1.0] - 2024-03-01
|
||||
|
||||
- #130 switches to use Helm published file to read latest version instead of using GitHub releases
|
||||
|
||||
## [4.0.0] - 2024-02-12
|
||||
|
||||
- #121 update to node20 as node16 is deprecated
|
||||
|
@ -4,17 +4,18 @@ Install a specific version of helm binary on the runner.
|
||||
|
||||
## Example
|
||||
|
||||
Acceptable values are latest or any semantic version string like v3.5.0 Use this action in workflow to define which version of helm will be used. v2+ of this action only support Helm3.
|
||||
Acceptable values are latest or any semantic version string like v3.5.0 Use this action in workflow to define which version of helm will be used. v2 and v3 of this action only support Helm3.
|
||||
|
||||
```yaml
|
||||
- uses: azure/setup-helm@v4.1.0
|
||||
- uses: azure/setup-helm@v3
|
||||
with:
|
||||
version: '<version>' # default is latest (stable)
|
||||
token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest'
|
||||
id: install
|
||||
```
|
||||
|
||||
> [!NOTE]
|
||||
> If something goes wrong with fetching the latest version the action will use the hardcoded default stable version (currently v3.13.3). If you rely on a certain version higher than the default, you should explicitly use that version instead of latest.
|
||||
> When using latest version you might hit the GitHub GraphQL API hourly rate limit of 5,000. The action will then return the hardcoded default stable version (currently v3.13.3). If you rely on a certain version higher than the default, you should use that version instead of latest.
|
||||
|
||||
The cached helm binary path is prepended to the PATH environment variable as well as stored in the helm-path output variable.
|
||||
Refer to the action metadata file for details about all the inputs https://github.com/Azure/setup-helm/blob/master/action.yml
|
||||
|
@ -6,9 +6,8 @@ inputs:
|
||||
required: true
|
||||
default: 'latest'
|
||||
token:
|
||||
description: GitHub token. Used to be required to fetch the latest version
|
||||
description: GitHub token. Required only if 'version' == 'latest'
|
||||
required: false
|
||||
deprecationMessage: 'GitHub token is no longer required'
|
||||
default: '${{ github.token }}'
|
||||
downloadBaseURL:
|
||||
description: 'Set the download base URL'
|
||||
|
27858
lib/index.js
27858
lib/index.js
File diff suppressed because one or more lines are too long
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "setuphelm",
|
||||
"version": "4.1.0",
|
||||
"version": "0.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "setuphelm",
|
||||
"version": "4.1.0",
|
||||
"version": "0.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "setuphelm",
|
||||
"version": "4.1.0",
|
||||
"version": "0.0.0",
|
||||
"private": true,
|
||||
"description": "Setup helm",
|
||||
"author": "Anumita Shenoy",
|
||||
|
@ -86,18 +86,7 @@ describe('run.ts', () => {
|
||||
expect(os.type).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
test('getLatestHelmVersion() - return the latest version of HELM', async () => {
|
||||
const res = {
|
||||
status: 200,
|
||||
text: async () => 'v9.99.999'
|
||||
} as Response
|
||||
global.fetch = jest.fn().mockReturnValue(res)
|
||||
expect(await run.getLatestHelmVersion()).toBe('v9.99.999')
|
||||
})
|
||||
|
||||
test('getLatestHelmVersion() - return the stable version of HELM when simulating a network error', async () => {
|
||||
const errorMessage: string = 'Network Error'
|
||||
global.fetch = jest.fn().mockRejectedValueOnce(new Error(errorMessage))
|
||||
test('getLatestHelmVersion() - return the stable version of HELM since its not authenticated', async () => {
|
||||
expect(await run.getLatestHelmVersion()).toBe('v3.13.3')
|
||||
})
|
||||
|
||||
|
30
src/run.ts
30
src/run.ts
@ -9,6 +9,7 @@ import * as fs from 'fs'
|
||||
|
||||
import * as toolCache from '@actions/tool-cache'
|
||||
import * as core from '@actions/core'
|
||||
import {Octokit} from '@octokit/action'
|
||||
|
||||
const helmToolName = 'helm'
|
||||
const stableHelmVersion = 'v3.13.3'
|
||||
@ -50,15 +51,38 @@ export function getValidVersion(version: string): string {
|
||||
// Gets the latest helm version or returns a default stable if getting latest fails
|
||||
export async function getLatestHelmVersion(): Promise<string> {
|
||||
try {
|
||||
const response = await fetch('https://get.helm.sh/helm-latest-version')
|
||||
const release = (await response.text()).trim()
|
||||
return release
|
||||
const octokit = new Octokit()
|
||||
const response = await octokit.rest.repos.listReleases({
|
||||
owner: 'helm',
|
||||
repo: 'helm',
|
||||
per_page: 100,
|
||||
order: 'desc',
|
||||
sort: 'created'
|
||||
})
|
||||
|
||||
const releases = response.data
|
||||
const latestValidRelease: string = releases.find(
|
||||
({tag_name, draft, prerelease}) =>
|
||||
isValidVersion(tag_name) && !draft && !prerelease
|
||||
)?.tag_name
|
||||
|
||||
if (latestValidRelease) return latestValidRelease
|
||||
} catch (err) {
|
||||
core.warning(
|
||||
`Error while fetching latest Helm release: ${err.toString()}. Using default version ${stableHelmVersion}`
|
||||
)
|
||||
return stableHelmVersion
|
||||
}
|
||||
|
||||
core.warning(
|
||||
`Could not find valid release. Using default version ${stableHelmVersion}`
|
||||
)
|
||||
return stableHelmVersion
|
||||
}
|
||||
|
||||
// isValidVersion checks if verison is a stable release
|
||||
function isValidVersion(version: string): boolean {
|
||||
return version.indexOf('rc') == -1
|
||||
}
|
||||
|
||||
export function getExecutableExtension(): string {
|
||||
|
Reference in New Issue
Block a user