Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
29960d0f5f |
@ -1,9 +1,5 @@
|
|||||||
# Change Log
|
# 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
|
## [4.0.0] - 2024-02-12
|
||||||
|
|
||||||
- #121 update to node20 as node16 is deprecated
|
- #121 update to node20 as node16 is deprecated
|
||||||
|
@ -4,17 +4,18 @@ Install a specific version of helm binary on the runner.
|
|||||||
|
|
||||||
## Example
|
## 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
|
```yaml
|
||||||
- uses: azure/setup-helm@v4.1.0
|
- uses: azure/setup-helm@v3
|
||||||
with:
|
with:
|
||||||
version: '<version>' # default is latest (stable)
|
version: '<version>' # default is latest (stable)
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest'
|
||||||
id: install
|
id: install
|
||||||
```
|
```
|
||||||
|
|
||||||
> [!NOTE]
|
> [!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.
|
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
|
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
|
required: true
|
||||||
default: 'latest'
|
default: 'latest'
|
||||||
token:
|
token:
|
||||||
description: GitHub token. Used to be required to fetch the latest version
|
description: GitHub token. Required only if 'version' == 'latest'
|
||||||
required: false
|
required: false
|
||||||
deprecationMessage: 'GitHub token is no longer required'
|
|
||||||
default: '${{ github.token }}'
|
default: '${{ github.token }}'
|
||||||
downloadBaseURL:
|
downloadBaseURL:
|
||||||
description: 'Set the download base URL'
|
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",
|
"name": "setuphelm",
|
||||||
"version": "4.1.0",
|
"version": "0.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "setuphelm",
|
"name": "setuphelm",
|
||||||
"version": "4.1.0",
|
"version": "0.0.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.0",
|
"@actions/core": "^1.10.0",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "setuphelm",
|
"name": "setuphelm",
|
||||||
"version": "4.1.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Setup helm",
|
"description": "Setup helm",
|
||||||
"author": "Anumita Shenoy",
|
"author": "Anumita Shenoy",
|
||||||
|
@ -86,18 +86,7 @@ describe('run.ts', () => {
|
|||||||
expect(os.type).toHaveBeenCalled()
|
expect(os.type).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
test('getLatestHelmVersion() - return the latest version of HELM', async () => {
|
test('getLatestHelmVersion() - return the stable version of HELM since its not authenticated', 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))
|
|
||||||
expect(await run.getLatestHelmVersion()).toBe('v3.13.3')
|
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 toolCache from '@actions/tool-cache'
|
||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
|
import {Octokit} from '@octokit/action'
|
||||||
|
|
||||||
const helmToolName = 'helm'
|
const helmToolName = 'helm'
|
||||||
const stableHelmVersion = 'v3.13.3'
|
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
|
// Gets the latest helm version or returns a default stable if getting latest fails
|
||||||
export async function getLatestHelmVersion(): Promise<string> {
|
export async function getLatestHelmVersion(): Promise<string> {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('https://get.helm.sh/helm-latest-version')
|
const octokit = new Octokit()
|
||||||
const release = (await response.text()).trim()
|
const response = await octokit.rest.repos.listReleases({
|
||||||
return release
|
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) {
|
} catch (err) {
|
||||||
core.warning(
|
core.warning(
|
||||||
`Error while fetching latest Helm release: ${err.toString()}. Using default version ${stableHelmVersion}`
|
`Error while fetching latest Helm release: ${err.toString()}. Using default version ${stableHelmVersion}`
|
||||||
)
|
)
|
||||||
return 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 {
|
export function getExecutableExtension(): string {
|
||||||
|
Reference in New Issue
Block a user