Skip to content

Commit

Permalink
Add action input for scala-cli version, default to latest (#7)
Browse files Browse the repository at this point in the history
* Add action input for scala-cli version, default to latest

* Not default to latest scala-cli version.

* Add scala-cli-version to action config, add "latest" as a possible value of scala-cli-version.
  • Loading branch information
ptrdom authored Apr 27, 2022
1 parent 7848386 commit 156a3cf
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,5 @@ Thumbs.db
# Ignore built ts files
__tests__/runner/*
lib/**/*

.idea
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ A GitHub Action to install Scala CLI.

## Inputs

- `scala-cli-version` (optional): scala-cli version to install
- "latest" to install the latest version.
- `jvm` (optional): JVM to install
- one of the options from `cs java --available`.
- if left empty either the existing JVM will be used or Coursier will install its default JVM.
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ branding:
icon: 'anchor'
color: 'green'
inputs:
scala-cli-version:
description: 'Version of scala-cli to install ("latest" to install the latest version)'
required: false
jvm:
description: 'JVM to install (leave empty to use default)'
required: false
Expand Down
17 changes: 15 additions & 2 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

15 changes: 13 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,24 @@ async function run(): Promise<void> {

await core.group('Install Apps', async () => {
const apps: string[] = core.getInput('apps').split(' ')
apps.push(`scala-cli:${scalaCLIVersion}`)
const scalaCLIVersionInput = core.getInput('scala-cli-version')
let version
if (scalaCLIVersionInput) {
if (scalaCLIVersionInput === 'latest') {
version = ''
} else {
version = scalaCLIVersionInput
}
} else {
version = scalaCLIVersion
}
apps.push(`scala-cli${version ? `:${version}` : ''}`)
if (apps.length) {
const coursierBinDir = path.join(os.homedir(), 'cs', 'bin')
core.exportVariable('COURSIER_BIN_DIR', coursierBinDir)
core.addPath(coursierBinDir)
await cs('install', '--contrib', ...apps)
core.setOutput('scala-cli-version', scalaCLIVersion)
core.setOutput('scala-cli-version', await execOutput('scala-cli', 'version'))
}
})
} catch (error: any) {
Expand Down

0 comments on commit 156a3cf

Please sign in to comment.