Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) |
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
24 changes: 17 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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);
}

Expand All @@ -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) {
Expand All @@ -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;
}

Expand Down
Loading