Skip to content

Commit

Permalink
Use latest cs launcher (#148)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexarchambault authored Nov 16, 2021
1 parent 7c70461 commit 4fd675b
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 15 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
jvm: ['', 'openjdk:11']
jvm: ['8', '11']
steps:
- uses: actions/checkout@v2
- run: |
Expand All @@ -35,6 +35,10 @@ jobs:
- run: java -version
- run: cs java -version
# test installed apps
- run: sbtn.bat show name </dev/null
shell: bash
if: runner.os == 'Windows'
- run: sbtn show name
if: runner.os != 'Windows'
- run: amm --help
- run: bloop about
45 changes: 31 additions & 14 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import * as tc from '@actions/tool-cache'
import * as path from 'path'
import * as os from 'os'

const coursierVersionSpec = `^2.0`
const csVersion = '2.0.16-200-ge888c6dea'
const coursierVersionSpec = csVersion

async function execOutput(cmd: string, ...args: string[]): Promise<string> {
let output = ''
Expand All @@ -20,26 +21,43 @@ async function execOutput(cmd: string, ...args: string[]): Promise<string> {
}

async function downloadCoursier(): Promise<string> {
const baseUrl = 'https://git.io/coursier-cli'
const baseUrl = `https://github.com/coursier/coursier/releases/download/v${csVersion}/cs-x86_64`
let csBinary = ''
switch (process.platform) {
case 'linux':
csBinary = await tc.downloadTool(`${baseUrl}-linux`)
case 'linux': {
const guid = await tc.downloadTool(`${baseUrl}-pc-linux.gz`)
const arc = `${guid}.gz`
await cli.exec('mv', [guid, arc])
csBinary = arc
break
case 'darwin':
csBinary = await tc.downloadTool(`${baseUrl}-macos`)
}
case 'darwin': {
const guid = await tc.downloadTool(`${baseUrl}-apple-darwin.gz`)
const arc = `${guid}.gz`
await cli.exec('mv', [guid, arc])
csBinary = arc
break
}
case 'win32': {
const guid = await tc.downloadTool(`${baseUrl}-windows-exe`)
const exe = `${guid}.exe`
await cli.exec('mv', [guid, exe])
csBinary = exe
const guid = await tc.downloadTool(`${baseUrl}-pc-win32.zip`)
const arc = `${guid}.zip`
await cli.exec('mv', [guid, arc])
csBinary = arc
break
}
default:
core.setFailed(`Unknown process.platform: ${process.platform}`)
}
if (!csBinary) core.setFailed(`Couldn't download Coursier`)
if (csBinary.endsWith('.gz')) {
await cli.exec('gzip', ['-d', csBinary])
csBinary = csBinary.slice(0, csBinary.length - '.gz'.length)
}
if (csBinary.endsWith('.zip')) {
const destDir = csBinary.slice(0, csBinary.length - '.zip'.length)
await cli.exec('unzip', ['-j', csBinary, 'cs-x86_64-pc-win32.exe', '-d', destDir])
csBinary = `${destDir}\\cs-x86_64-pc-win32.exe`
}
await cli.exec('chmod', ['+x', csBinary])
return csBinary
}
Expand All @@ -50,9 +68,8 @@ async function cs(...args: string[]): Promise<string> {
core.addPath(previous)
} else {
const csBinary = await downloadCoursier()
const version = await execOutput(csBinary, '--version')
const binaryName = process.platform === 'win32' ? 'cs.exe' : 'cs'
const csCached = await tc.cacheFile(csBinary, binaryName, 'cs', version)
const csCached = await tc.cacheFile(csBinary, binaryName, 'cs', csVersion)
core.addPath(csCached)
}
return execOutput('cs', ...args)
Expand All @@ -61,8 +78,8 @@ async function cs(...args: string[]): Promise<string> {
async function run(): Promise<void> {
try {
await core.group('Install Coursier', async () => {
const version = await cs('--version')
core.setOutput('cs-version', version)
await cs('--help')
core.setOutput('cs-version', csVersion)
})

await core.group('Install JVM', async () => {
Expand Down

0 comments on commit 4fd675b

Please sign in to comment.