Skip to content

Commit 156a3cf

Browse files
authored
Add action input for scala-cli version, default to latest (#7)
* 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.
1 parent 7848386 commit 156a3cf

File tree

6 files changed

+36
-5
lines changed

6 files changed

+36
-5
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,5 @@ Thumbs.db
9797
# Ignore built ts files
9898
__tests__/runner/*
9999
lib/**/*
100+
101+
.idea

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ A GitHub Action to install Scala CLI.
1111

1212
## Inputs
1313

14+
- `scala-cli-version` (optional): scala-cli version to install
15+
- "latest" to install the latest version.
1416
- `jvm` (optional): JVM to install
1517
- one of the options from `cs java --available`.
1618
- if left empty either the existing JVM will be used or Coursier will install its default JVM.

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ branding:
55
icon: 'anchor'
66
color: 'green'
77
inputs:
8+
scala-cli-version:
9+
description: 'Version of scala-cli to install ("latest" to install the latest version)'
10+
required: false
811
jvm:
912
description: 'JVM to install (leave empty to use default)'
1013
required: false

dist/index.js

Lines changed: 15 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,24 @@ async function run(): Promise<void> {
9898

9999
await core.group('Install Apps', async () => {
100100
const apps: string[] = core.getInput('apps').split(' ')
101-
apps.push(`scala-cli:${scalaCLIVersion}`)
101+
const scalaCLIVersionInput = core.getInput('scala-cli-version')
102+
let version
103+
if (scalaCLIVersionInput) {
104+
if (scalaCLIVersionInput === 'latest') {
105+
version = ''
106+
} else {
107+
version = scalaCLIVersionInput
108+
}
109+
} else {
110+
version = scalaCLIVersion
111+
}
112+
apps.push(`scala-cli${version ? `:${version}` : ''}`)
102113
if (apps.length) {
103114
const coursierBinDir = path.join(os.homedir(), 'cs', 'bin')
104115
core.exportVariable('COURSIER_BIN_DIR', coursierBinDir)
105116
core.addPath(coursierBinDir)
106117
await cs('install', '--contrib', ...apps)
107-
core.setOutput('scala-cli-version', scalaCLIVersion)
118+
core.setOutput('scala-cli-version', await execOutput('scala-cli', 'version'))
108119
}
109120
})
110121
} catch (error: any) {

0 commit comments

Comments
 (0)