Compare commits

..

4 Commits

Author SHA1 Message Date
Vidya Reddy
2caaa2f023 updated the description 2022-08-06 09:33:46 +05:30
Vidya Reddy
79266a2b40 fixes 2022-08-04 12:08:02 +05:30
Vidya Reddy
6b0e7a31f6 added runner info to bug report 2022-08-03 12:27:53 +05:30
Vidya Reddy
85664e9295 Added the bug report and feature req form 2022-08-02 12:06:37 +05:30
14 changed files with 9009 additions and 1664 deletions

View File

@@ -1,24 +1,17 @@
name: Bug Report name: Bug Report
description: File a bug report specifying all inputs you provided for the action, we will respond to this thread with any questions. description: File a bug report, we will respond to this thread with any questions.
title: 'Bug: ' title: 'Bug: '
labels: ['bug', 'triage'] labels: ['bug', 'triage']
assignees: '@Azure/aks-atlanta' assignees: '@Azure/aks-atlanta'
body: body:
- type: textarea - type: input
id: What-happened id: What-happened
attributes: attributes:
label: What happened? label: What happened?
description: Tell us what happened and how is it different from the expected? description: Tell us what happened and how is it different form the expected?
placeholder: Tell us what you see! placeholder: Tell us what you see!
validations: validations:
required: true required: true
- type: checkboxes
id: Version
attributes:
label: Version
options:
- label: I am using the latest version
required: true
- type: input - type: input
id: Runner id: Runner
attributes: attributes:
@@ -27,10 +20,9 @@ body:
placeholder: Mention the runner info (self-hosted, operating system) placeholder: Mention the runner info (self-hosted, operating system)
validations: validations:
required: true required: true
- type: textarea - type: input
id: Logs id: Logs
attributes: attributes:
label: Relevant log output label: Relevant log output
description: Run in debug mode for the most verbose logs. Please feel free to attach a screenshot of the logs description: Run in debug mode for the most verbose logs. Please feel free to attach a screenshot of the logs
validations: render: shell
required: true

View File

@@ -1,6 +1,6 @@
blank_issues_enabled: false blank_issues_enabled: false
contact_links: contact_links:
- name: GitHub Action "setup-helm" Support - name: GitHub Action "aks-set-context" Support
url: https://github.com/Azure/setup-helm url: https://github.com/Azure/aks-set-context
security: https://github.com/Azure/setup-helm/blob/main/SECURITY.md security: https://github.com/Azure/aks-set-context/blob/main/SECURITY.md
about: Please ask and answer questions here. about: Please ask and answer questions here.

View File

@@ -4,8 +4,8 @@ title: 'Feature Request: '
labels: ['Feature'] labels: ['Feature']
assignees: '@Azure/aks-atlanta' assignees: '@Azure/aks-atlanta'
body: body:
- type: textarea - type: input
id: Feature_request id: Feature request
attributes: attributes:
label: Feature request label: Feature request
description: Provide example functionality and links to relevant docs description: Provide example functionality and links to relevant docs

View File

@@ -13,7 +13,7 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job # Steps represent a sequence of tasks that will be executed as part of the job
steps: steps:
- uses: actions/stale@v9 - uses: actions/stale@v3
name: Setting issue as idle name: Setting issue as idle
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}
@@ -24,7 +24,7 @@ jobs:
operations-per-run: 100 operations-per-run: 100
exempt-issue-labels: 'backlog' exempt-issue-labels: 'backlog'
- uses: actions/stale@v9 - uses: actions/stale@v3
name: Setting PR as idle name: Setting PR as idle
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} repo-token: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -15,7 +15,7 @@ jobs:
PR_BASE_REF: ${{ github.event.pull_request.base.ref }} PR_BASE_REF: ${{ github.event.pull_request.base.ref }}
steps: steps:
- name: Check out repository - name: Check out repository
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: npm install and build - name: npm install and build
id: action-npm-build id: action-npm-build
run: | run: |
@@ -63,25 +63,3 @@ jobs:
else else
echo "HELM VERSION $HELM_3_5_0 INSTALLED SUCCESSFULLY" echo "HELM VERSION $HELM_3_5_0 INSTALLED SUCCESSFULLY"
fi fi
- name: Setup helm latest version
uses: ./
with:
version: latest
token: ${{ secrets.GITHUB_TOKEN }}
- name: Validate latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
HELM_LATEST=$(gh release list \
--repo helm/helm \
--exclude-drafts \
--exclude-pre-releases \
--limit 1 | awk '{print $4}')
if [[ $(helm version) != *$HELM_LATEST* ]]; then
echo "HELM VERSION INCORRECT: HELM VERSION DOES NOT CONTAIN $HELM_LATEST"
echo "HELM VERSION OUTPUT: $(helm version)"
exit 1
else
echo "HELM VERSION $HELM_LATEST INSTALLED SUCCESSFULLY"
fi

View File

@@ -10,9 +10,9 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout Repository - name: Checkout Repository
uses: actions/checkout@v4 uses: actions/checkout@v2
- name: Enforce Prettier - name: Enforce Prettier
uses: actionsx/prettier@v3 uses: actionsx/prettier@v2
with: with:
args: --check . args: --check .

View File

@@ -9,8 +9,6 @@ on:
jobs: jobs:
release-pr: release-pr:
uses: Azure/action-release-workflows/.github/workflows/release_js_project.yaml@a705b2ab6a3ee889f2b0d925ad0bd2f9eb733ce6 uses: OliverMKing/javascript-release-workflow/.github/workflows/release-pr.yml@main
permissions:
contents: write
with: with:
changelogPath: ./CHANGELOG.md release: ${{ github.event.inputs.release }}

View File

@@ -13,7 +13,7 @@ jobs:
build: # make sure build/ci works properly build: # make sure build/ci works properly
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v1
- name: Run L0 tests. - name: Run L0 tests.
run: | run: |

View File

@@ -14,8 +14,7 @@ Acceptable values are latest or any semantic version string like v3.5.0 Use this
id: install id: install
``` ```
> [!NOTE] > Note: 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.9.0). If you rely on a certain version higher than the default, you should 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
@@ -33,7 +32,3 @@ provided by the bot. You will only need to do this once across all repos using o
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
## Support
setup-helm is an open source project that is [**not** covered by the Microsoft Azure support policy](https://support.microsoft.com/en-us/help/2941892/support-for-linux-and-open-source-technology-in-azure). [Please search open issues here](https://github.com/Azure/setup-helm/issues), and if your issue isn't already represented please [open a new one](https://github.com/Azure/setup-helm/issues/new/choose). The project maintainers will respond to the best of their abilities.

View File

@@ -8,16 +8,11 @@ inputs:
token: token:
description: GitHub token. Required only if 'version' == 'latest' description: GitHub token. Required only if 'version' == 'latest'
required: false required: false
default: '${{ github.token }}'
downloadBaseURL:
description: 'Set the download base URL'
required: false
default: 'https://get.helm.sh'
outputs: outputs:
helm-path: helm-path:
description: 'Path to the cached helm binary' description: 'Path to the cached helm binary'
branding: branding:
color: 'blue' color: 'blue'
runs: runs:
using: 'node20' using: 'node16'
main: 'lib/index.js' main: 'lib/index.js'

10353
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,12 +6,13 @@
"author": "Anumita Shenoy", "author": "Anumita Shenoy",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.2.6",
"@actions/exec": "^1.1.1", "@actions/exec": "^1.0.0",
"@actions/io": "^1.1.2", "@actions/io": "^1.0.0",
"@actions/tool-cache": "2.0.1", "@actions/tool-cache": "1.1.2",
"@octokit/action": "^6.0.7", "@octokit/auth-action": "^2.0.0",
"semver": "^7.5.4" "@octokit/graphql": "^4.6.1",
"semver": "^6.1.0"
}, },
"main": "lib/index.js", "main": "lib/index.js",
"scripts": { "scripts": {
@@ -22,12 +23,11 @@
"format-check": "prettier --check ." "format-check": "prettier --check ."
}, },
"devDependencies": { "devDependencies": {
"@types/jest": "^29.5.11", "@types/jest": "^26.0.0",
"@types/node": "^20.11.8", "@types/node": "^12.0.10",
"@vercel/ncc": "^0.38.1", "@vercel/ncc": "^0.34.0",
"jest": "^29.7.0", "jest": "^26.0.1",
"prettier": "^3.2.5", "ts-jest": "^26.0.0",
"ts-jest": "^29.1.2", "typescript": "^3.5.2"
"typescript": "^5.3.3"
} }
} }

View File

@@ -10,64 +10,55 @@ describe('run.ts', () => {
jest.spyOn(os, 'type').mockReturnValue('Windows_NT') jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
expect(run.getExecutableExtension()).toBe('.exe') expect(run.getExecutableExtension()).toBe('.exe')
expect(os.type).toHaveBeenCalled() expect(os.type).toBeCalled()
}) })
test('getExecutableExtension() - return empty string for non-windows OS', () => { test('getExecutableExtension() - return empty string for non-windows OS', () => {
jest.spyOn(os, 'type').mockReturnValue('Darwin') jest.spyOn(os, 'type').mockReturnValue('Darwin')
expect(run.getExecutableExtension()).toBe('') expect(run.getExecutableExtension()).toBe('')
expect(os.type).toHaveBeenCalled() expect(os.type).toBeCalled()
}) })
test('getHelmDownloadURL() - return the URL to download helm for Linux', () => { test('getHelmDownloadURL() - return the URL to download helm for Linux', () => {
const downloadBaseURL = 'https://test.tld'
jest.spyOn(os, 'type').mockReturnValue('Linux') jest.spyOn(os, 'type').mockReturnValue('Linux')
jest.spyOn(os, 'arch').mockReturnValueOnce('unknown') jest.spyOn(os, 'arch').mockReturnValueOnce('unknown')
const helmLinuxUrl = 'https://test.tld/helm-v3.8.0-linux-amd64.zip' const kubectlLinuxUrl = 'https://get.helm.sh/helm-v3.8.0-linux-amd64.zip'
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe( expect(run.getHelmDownloadURL('v3.8.0')).toBe(kubectlLinuxUrl)
helmLinuxUrl expect(os.type).toBeCalled()
) expect(os.arch).toBeCalled()
expect(os.type).toHaveBeenCalled()
expect(os.arch).toHaveBeenCalled()
// arm64 // arm64
jest.spyOn(os, 'type').mockReturnValue('Linux') jest.spyOn(os, 'type').mockReturnValue('Linux')
jest.spyOn(os, 'arch').mockReturnValueOnce('arm64') jest.spyOn(os, 'arch').mockReturnValueOnce('arm64')
const helmLinuxArm64Url = 'https://test.tld/helm-v3.8.0-linux-arm64.zip' const kubectlLinuxArm64Url =
'https://get.helm.sh/helm-v3.8.0-linux-arm64.zip'
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe( expect(run.getHelmDownloadURL('v3.8.0')).toBe(kubectlLinuxArm64Url)
helmLinuxArm64Url expect(os.type).toBeCalled()
) expect(os.arch).toBeCalled()
expect(os.type).toHaveBeenCalled()
expect(os.arch).toHaveBeenCalled()
}) })
test('getHelmDownloadURL() - return the URL to download helm for Darwin', () => { test('getHelmDownloadURL() - return the URL to download helm for Darwin', () => {
const downloadBaseURL = 'https://test.tld'
jest.spyOn(os, 'type').mockReturnValue('Darwin') jest.spyOn(os, 'type').mockReturnValue('Darwin')
jest.spyOn(os, 'arch').mockReturnValueOnce('unknown') jest.spyOn(os, 'arch').mockReturnValueOnce('unknown')
const helmDarwinUrl = 'https://test.tld/helm-v3.8.0-darwin-amd64.zip' const kubectlDarwinUrl =
'https://get.helm.sh/helm-v3.8.0-darwin-amd64.zip'
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe( expect(run.getHelmDownloadURL('v3.8.0')).toBe(kubectlDarwinUrl)
helmDarwinUrl expect(os.type).toBeCalled()
) expect(os.arch).toBeCalled()
expect(os.type).toHaveBeenCalled()
expect(os.arch).toHaveBeenCalled()
// arm64 // arm64
jest.spyOn(os, 'type').mockReturnValue('Darwin') jest.spyOn(os, 'type').mockReturnValue('Darwin')
jest.spyOn(os, 'arch').mockReturnValueOnce('arm64') jest.spyOn(os, 'arch').mockReturnValueOnce('arm64')
const helmDarwinArm64Url = 'https://test.tld/helm-v3.8.0-darwin-arm64.zip' const kubectlDarwinArm64Url =
'https://get.helm.sh/helm-v3.8.0-darwin-arm64.zip'
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe( expect(run.getHelmDownloadURL('v3.8.0')).toBe(kubectlDarwinArm64Url)
helmDarwinArm64Url expect(os.type).toBeCalled()
) expect(os.arch).toBeCalled()
expect(os.type).toHaveBeenCalled()
expect(os.arch).toHaveBeenCalled()
}) })
test('getValidVersion() - return version with v prepended', () => { test('getValidVersion() - return version with v prepended', () => {
@@ -75,19 +66,16 @@ describe('run.ts', () => {
}) })
test('getHelmDownloadURL() - return the URL to download helm for Windows', () => { test('getHelmDownloadURL() - return the URL to download helm for Windows', () => {
const downloadBaseURL = 'https://test.tld'
jest.spyOn(os, 'type').mockReturnValue('Windows_NT') jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
const helmWindowsUrl = 'https://test.tld/helm-v3.8.0-windows-amd64.zip' const kubectlWindowsUrl =
expect(run.getHelmDownloadURL(downloadBaseURL, 'v3.8.0')).toBe( 'https://get.helm.sh/helm-v3.8.0-windows-amd64.zip'
helmWindowsUrl expect(run.getHelmDownloadURL('v3.8.0')).toBe(kubectlWindowsUrl)
) expect(os.type).toBeCalled()
expect(os.type).toHaveBeenCalled()
}) })
test('getLatestHelmVersion() - return the stable version of HELM since its not authenticated', async () => { test('getLatestHelmVersion() - return the stable version of HELM since its not authenticated', async () => {
expect(await run.getLatestHelmVersion()).toBe('v3.13.3') expect(await run.getLatestHelmVersion()).toBe('v3.9.0')
}) })
test('walkSync() - return path to the all files matching fileToFind in dir', () => { test('walkSync() - return path to the all files matching fileToFind in dir', () => {
@@ -120,8 +108,8 @@ describe('run.ts', () => {
expect(run.walkSync('mainFolder', null, 'file21')).toEqual([ expect(run.walkSync('mainFolder', null, 'file21')).toEqual([
path.join('mainFolder', 'folder2', 'file21') path.join('mainFolder', 'folder2', 'file21')
]) ])
expect(fs.readdirSync).toHaveBeenCalledTimes(3) expect(fs.readdirSync).toBeCalledTimes(3)
expect(fs.statSync).toHaveBeenCalledTimes(8) expect(fs.statSync).toBeCalledTimes(8)
}) })
test('walkSync() - return empty array if no file with name fileToFind exists', () => { test('walkSync() - return empty array if no file with name fileToFind exists', () => {
@@ -152,8 +140,8 @@ describe('run.ts', () => {
}) })
expect(run.walkSync('mainFolder', null, 'helm.exe')).toEqual([]) expect(run.walkSync('mainFolder', null, 'helm.exe')).toEqual([])
expect(fs.readdirSync).toHaveBeenCalledTimes(3) expect(fs.readdirSync).toBeCalledTimes(3)
expect(fs.statSync).toHaveBeenCalledTimes(8) expect(fs.statSync).toBeCalledTimes(8)
}) })
test('findHelm() - change access permissions and find the helm in given directory', () => { test('findHelm() - change access permissions and find the helm in given directory', () => {
@@ -207,18 +195,16 @@ describe('run.ts', () => {
return {isDirectory: () => isDirectory} as fs.Stats return {isDirectory: () => isDirectory} as fs.Stats
}) })
const baseURL = 'https://test.tld' expect(await run.downloadHelm('v4.0.0')).toBe(
expect(await run.downloadHelm(baseURL, 'v4.0.0')).toBe(
path.join('pathToCachedDir', 'helm.exe') path.join('pathToCachedDir', 'helm.exe')
) )
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v4.0.0') expect(toolCache.find).toBeCalledWith('helm', 'v4.0.0')
expect(toolCache.downloadTool).toHaveBeenCalledWith( expect(toolCache.downloadTool).toBeCalledWith(
'https://test.tld/helm-v4.0.0-windows-amd64.zip' 'https://get.helm.sh/helm-v4.0.0-windows-amd64.zip'
) )
expect(fs.chmodSync).toHaveBeenCalledWith('pathToTool', '777') expect(fs.chmodSync).toBeCalledWith('pathToTool', '777')
expect(toolCache.extractZip).toHaveBeenCalledWith('pathToTool') expect(toolCache.extractZip).toBeCalledWith('pathToTool')
expect(fs.chmodSync).toHaveBeenCalledWith( expect(fs.chmodSync).toBeCalledWith(
path.join('pathToCachedDir', 'helm.exe'), path.join('pathToCachedDir', 'helm.exe'),
'777' '777'
) )
@@ -231,14 +217,12 @@ describe('run.ts', () => {
}) })
jest.spyOn(os, 'type').mockReturnValue('Windows_NT') jest.spyOn(os, 'type').mockReturnValue('Windows_NT')
const baseURL = 'https://test.tld' await expect(run.downloadHelm('v3.2.1')).rejects.toThrow(
'Failed to download Helm from location https://get.helm.sh/helm-v3.2.1-windows-amd64.zip'
await expect(run.downloadHelm(baseURL, 'v3.2.1')).rejects.toThrow(
'Failed to download Helm from location https://test.tld/helm-v3.2.1-windows-amd64.zip'
) )
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1') expect(toolCache.find).toBeCalledWith('helm', 'v3.2.1')
expect(toolCache.downloadTool).toHaveBeenCalledWith( expect(toolCache.downloadTool).toBeCalledWith(
'https://test.tld/helm-v3.2.1-windows-amd64.zip' 'https://get.helm.sh/helm-v3.2.1-windows-amd64.zip'
) )
}) })
@@ -246,13 +230,11 @@ describe('run.ts', () => {
jest.spyOn(toolCache, 'find').mockReturnValue('pathToCachedDir') jest.spyOn(toolCache, 'find').mockReturnValue('pathToCachedDir')
jest.spyOn(fs, 'chmodSync').mockImplementation(() => {}) jest.spyOn(fs, 'chmodSync').mockImplementation(() => {})
const baseURL = 'https://test.tld' expect(await run.downloadHelm('v3.2.1')).toBe(
expect(await run.downloadHelm(baseURL, 'v3.2.1')).toBe(
path.join('pathToCachedDir', 'helm.exe') path.join('pathToCachedDir', 'helm.exe')
) )
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1') expect(toolCache.find).toBeCalledWith('helm', 'v3.2.1')
expect(fs.chmodSync).toHaveBeenCalledWith( expect(fs.chmodSync).toBeCalledWith(
path.join('pathToCachedDir', 'helm.exe'), path.join('pathToCachedDir', 'helm.exe'),
'777' '777'
) )
@@ -274,16 +256,14 @@ describe('run.ts', () => {
return {isDirectory: () => isDirectory} as fs.Stats return {isDirectory: () => isDirectory} as fs.Stats
}) })
const baseURL = 'https://test.tld' await expect(run.downloadHelm('v3.2.1')).rejects.toThrow(
await expect(run.downloadHelm(baseURL, 'v3.2.1')).rejects.toThrow(
'Helm executable not found in path pathToCachedDir' 'Helm executable not found in path pathToCachedDir'
) )
expect(toolCache.find).toHaveBeenCalledWith('helm', 'v3.2.1') expect(toolCache.find).toBeCalledWith('helm', 'v3.2.1')
expect(toolCache.downloadTool).toHaveBeenCalledWith( expect(toolCache.downloadTool).toBeCalledWith(
'https://test.tld/helm-v3.2.1-windows-amd64.zip' 'https://get.helm.sh/helm-v3.2.1-windows-amd64.zip'
) )
expect(fs.chmodSync).toHaveBeenCalledWith('pathToTool', '777') expect(fs.chmodSync).toBeCalledWith('pathToTool', '777')
expect(toolCache.extractZip).toHaveBeenCalledWith('pathToTool') expect(toolCache.extractZip).toBeCalledWith('pathToTool')
}) })
}) })

View File

@@ -9,10 +9,12 @@ 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' import {graphql} from '@octokit/graphql'
import {createActionAuth} from '@octokit/auth-action'
import {create} from 'domain'
const helmToolName = 'helm' const helmToolName = 'helm'
const stableHelmVersion = 'v3.13.3' const stableHelmVersion = 'v3.9.0'
export async function run() { export async function run() {
let version = core.getInput('version', {required: true}) let version = core.getInput('version', {required: true})
@@ -25,10 +27,8 @@ export async function run() {
version = await getLatestHelmVersion() version = await getLatestHelmVersion()
} }
const downloadBaseURL = core.getInput('downloadBaseURL', {required: false})
core.startGroup(`Downloading ${version}`) core.startGroup(`Downloading ${version}`)
const cachedPath = await downloadHelm(downloadBaseURL, version) const cachedPath = await downloadHelm(version)
core.endGroup() core.endGroup()
try { try {
@@ -51,21 +51,27 @@ 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 octokit = new Octokit() const auth = createActionAuth()
const response = await octokit.rest.repos.listReleases({ const graphqlAuthenticated = graphql.defaults({
owner: 'helm', request: {hook: auth.hook}
repo: 'helm',
per_page: 100,
order: 'desc',
sort: 'created'
}) })
const {repository} = await graphqlAuthenticated(
const releases = response.data `
const latestValidRelease: string = releases.find( {
({tag_name, draft, prerelease}) => repository(name: "helm", owner: "helm") {
isValidVersion(tag_name) && !draft && !prerelease releases(last: 100) {
)?.tag_name nodes {
tagName
}
}
}
}
`
)
const releases: string[] = repository.releases.nodes
.reverse()
.map((node: {tagName: string}) => node.tagName)
const latestValidRelease = releases.find((tag) => isValidVersion(tag))
if (latestValidRelease) return latestValidRelease if (latestValidRelease) return latestValidRelease
} catch (err) { } catch (err) {
core.warning( core.warning(
@@ -96,49 +102,53 @@ const LINUX = 'Linux'
const MAC_OS = 'Darwin' const MAC_OS = 'Darwin'
const WINDOWS = 'Windows_NT' const WINDOWS = 'Windows_NT'
const ARM64 = 'arm64' const ARM64 = 'arm64'
export function getHelmDownloadURL(baseURL: string, version: string): string { export function getHelmDownloadURL(version: string): string {
const arch = os.arch() const arch = os.arch()
const operatingSystem = os.type() const operatingSystem = os.type()
let urlPath = ''
switch (true) { switch (true) {
case operatingSystem == LINUX && arch == ARM64: case operatingSystem == LINUX && arch == ARM64:
urlPath = util.format(`/helm-%s-linux-arm64.zip`, version) return util.format(
break 'https://get.helm.sh/helm-%s-linux-arm64.zip',
version
)
case operatingSystem == LINUX: case operatingSystem == LINUX:
urlPath = util.format(`/helm-%s-linux-amd64.zip`, version) return util.format(
break 'https://get.helm.sh/helm-%s-linux-amd64.zip',
version
)
case operatingSystem == MAC_OS && arch == ARM64: case operatingSystem == MAC_OS && arch == ARM64:
urlPath = util.format(`/helm-%s-darwin-arm64.zip`, version) return util.format(
break 'https://get.helm.sh/helm-%s-darwin-arm64.zip',
version
)
case operatingSystem == MAC_OS: case operatingSystem == MAC_OS:
urlPath = util.format(`/helm-%s-darwin-amd64.zip`, version) return util.format(
break 'https://get.helm.sh/helm-%s-darwin-amd64.zip',
version
)
case operatingSystem == WINDOWS: case operatingSystem == WINDOWS:
default: default:
urlPath = util.format(`/helm-%s-windows-amd64.zip`, version) return util.format(
'https://get.helm.sh/helm-%s-windows-amd64.zip',
version
)
} }
const url = new URL(urlPath, baseURL)
return url.toString()
} }
export async function downloadHelm( export async function downloadHelm(version: string): Promise<string> {
baseURL: string,
version: string
): Promise<string> {
let cachedToolpath = toolCache.find(helmToolName, version) let cachedToolpath = toolCache.find(helmToolName, version)
if (!cachedToolpath) { if (!cachedToolpath) {
let helmDownloadPath let helmDownloadPath
try { try {
helmDownloadPath = await toolCache.downloadTool( helmDownloadPath = await toolCache.downloadTool(
getHelmDownloadURL(baseURL, version) getHelmDownloadURL(version)
) )
} catch (exception) { } catch (exception) {
throw new Error( throw new Error(
`Failed to download Helm from location ${getHelmDownloadURL( `Failed to download Helm from location ${getHelmDownloadURL(
baseURL,
version version
)}` )}`
) )