Skip to content

Commit

Permalink
Select channel and or version (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
garbas committed Aug 26, 2024
1 parent 21843ca commit 3ab1757
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ jobs:
- name: "Test Local Action"
uses: "./"
with:
base-url: "https://downloads.flox.dev/by-env/${{ matrix.release-env }}"
channel: "${{ matrix.release-env }}"

- name: "Test: flox --version"
run: |
Expand Down
11 changes: 10 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@ branding:

inputs:

version:
description: "Select a specific version from a channel."
default: ""

channel:
description: "One of the following: stable, qa, nightly or specify a commit."
default: "stable"

base-url:
deprecationMessage: "Please use channel option"
description: "Download base URL of flox installer"
default: "https://downloads.flox.dev/by-env/stable"
default: ""

runs:
using: 'node20'
Expand Down
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 20 additions & 7 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 20 additions & 7 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,57 @@ export function scriptPath(name) {
}

const INSTALL_FLOX_SCRIPT = scriptPath('install-flox.sh')
const CHANNELS = ['stable', 'qa', 'nightly']

export async function getDownloadUrl() {
const rpm = await which('rpm', { nothrow: true })
const dpkg = await which('dpkg', { nothrow: true })

const BASE_URL = core.getInput('base-url')
let BASE_URL = 'https://downloads.flox.dev'
if (core.getInput('base-url') !== '') {
BASE_URL = core.getInput('base-url')
} else if (CHANNELS.includes(core.getInput('channel'))) {
BASE_URL = `${BASE_URL}/by-env/${core.getInput('channel')}`
} else {
BASE_URL = `${BASE_URL}/by-commit/${core.getInput('channel')}`
}
core.debug(`Base URL is: ${BASE_URL}`)

let version = ''
if (core.getInput('version') !== '') {
version = '-' + core.getInput('version')
}

let downloadUrl

if (process.platform === 'darwin' && process.arch === 'x64') {
downloadUrl = `${BASE_URL}/osx/flox.x86_64-darwin.pkg`
downloadUrl = `${BASE_URL}/osx/flox${version}.x86_64-darwin.pkg`
} else if (process.platform === 'darwin' && process.arch === 'arm64') {
downloadUrl = `${BASE_URL}/osx/flox.aarch64-darwin.pkg`
downloadUrl = `${BASE_URL}/osx/flox${version}.aarch64-darwin.pkg`
} else if (
dpkg !== null &&
process.platform === 'linux' &&
process.arch === 'x64'
) {
downloadUrl = `${BASE_URL}/deb/flox.x86_64-linux.deb`
downloadUrl = `${BASE_URL}/deb/flox${version}.x86_64-linux.deb`
} else if (
dpkg !== null &&
process.platform === 'linux' &&
process.arch === 'arm64'
) {
downloadUrl = `${BASE_URL}/deb/flox.aarch64-linux.deb`
downloadUrl = `${BASE_URL}/deb/flox${version}.aarch64-linux.deb`
} else if (
rpm !== null &&
process.platform === 'linux' &&
process.arch === 'x64'
) {
downloadUrl = `${BASE_URL}/rpm/flox.x86_64-linux.rpm`
downloadUrl = `${BASE_URL}/rpm/flox${version}.x86_64-linux.rpm`
} else if (
rpm !== null &&
process.platform === 'linux' &&
process.arch === 'arm64'
) {
downloadUrl = `${BASE_URL}/rpm/flox.aarch64-linux.rpm`
downloadUrl = `${BASE_URL}/rpm/flox${version}.aarch64-linux.rpm`
} else {
core.setFailed(
`No platform (${process.platform}) or arch (${process.arch}) or OS matched.`
Expand Down

0 comments on commit 3ab1757

Please sign in to comment.