diff --git a/.github/workflows/test-action.yml b/.github/workflows/test-action.yml index a6e6bdc..d30d46a 100644 --- a/.github/workflows/test-action.yml +++ b/.github/workflows/test-action.yml @@ -30,6 +30,16 @@ jobs: INTERNAL=$((MINOR + VERSION_OFFSET)) func version | grep -q "v0.${INTERNAL}" + test-nightly-version: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Setup func CLI with nightly version + uses: ./ + with: + version: 'nightly' + - run: func version + test-custom-name: runs-on: ubuntu-latest steps: diff --git a/README.md b/README.md index 82255b6..df4fb16 100644 --- a/README.md +++ b/README.md @@ -14,8 +14,8 @@ GitHub Action to download and setup the func CLI. Automatically detects OS and a | Input | Description | Default | |-------|-------------|---------| -| `version` | Version to download (e.g. `v1.20.0`) | latest | -| `name` | Binary name | `func` | +| `version` | Version to download (e.g. `v1.20.0`, `nightly`) | latest | +| `name` | Filename for downloaded binary | `func` | | `binary` | Specific binary to download from GitHub release | auto-detected | | `destination` | Download directory | cwd | | `binarySource` | Full URL for the func binary | empty (uses GitHub releases) | diff --git a/action.yml b/action.yml index bdf1ce2..904ed62 100644 --- a/action.yml +++ b/action.yml @@ -6,7 +6,7 @@ inputs: binary: description: '(optional) Binary you want to download (exact string expected), otherwise will be determined via the OS of GH Runner' version: - description: '(optional) Version to download. Use "latest" or specify a version from release pages https://github.com/knative/func/tags' + description: '(optional) Version to download. Use "latest", "nightly", or specify a version from release pages https://github.com/knative/func/tags' destination: description: '(optional) Path where to move the desired downloaded binary, otherwise cwd is used' binarySource: diff --git a/index.js b/index.js index 134809d..9ebd611 100644 --- a/index.js +++ b/index.js @@ -3,7 +3,12 @@ const exec = require('@actions/exec'); const path = require('path'); const fs = require('fs'); -const LATEST = 'latest'; +// Using latest as default +const DEFAULT_VERSION = 'latest'; +const NIGHTLY_VERSION = 'nightly'; +const DEFAULT_BINARY_SOURCE = 'https://github.com/knative/func/releases/download'; +const DEFAULT_LATEST_BINARY_SOURCE = 'https://github.com/knative/func/releases/latest/download'; +const DEFAULT_NIGHTLY_BINARY_SOURCE = 'https://storage.googleapis.com/knative-nightly/func/latest'; function getOsBinName() { const osBinName = core.getInput('binary'); @@ -50,8 +55,9 @@ function smartVersionUpdate(version) { } function resolveVersion() { - const version = core.getInput('version') || LATEST; - if (version.toLowerCase().trim() === LATEST) return LATEST; + const version = core.getInput('version') || DEFAULT_VERSION; + if (version.toLowerCase().trim() === DEFAULT_VERSION) return DEFAULT_VERSION; + if (version.toLowerCase().trim() === NIGHTLY_VERSION) return NIGHTLY_VERSION; return smartVersionUpdate(version); } @@ -62,12 +68,16 @@ function resolveDownloadUrl(version, binName) { return binarySource; } - if (version === LATEST) { + if (version === NIGHTLY_VERSION) { + core.info('Using nightly version...'); + return `${DEFAULT_NIGHTLY_BINARY_SOURCE}/${binName}`; + } + if (version === DEFAULT_VERSION) { core.info('Using latest version...'); - return `https://github.com/knative/func/releases/latest/download/${binName}`; + return `${DEFAULT_LATEST_BINARY_SOURCE}/${binName}`; } core.info(`Using specific version ${version}`); - return `https://github.com/knative/func/releases/download/${version}/${binName}`; + return `${DEFAULT_BINARY_SOURCE}/${version}/${binName}`; } async function downloadFuncBinary(url, binPath) { @@ -93,7 +103,7 @@ function addBinToPath(binPath) { async function warnStaleVersion(version) { // Skip version check for 'latest' or custom binary source - if (version === LATEST || core.getInput('binarySource')) { + if (version === DEFAULT_VERSION || core.getInput('binarySource')) { return; }