@@ -3,10 +3,11 @@ const fs = require('fs')
33const path = require ( 'path' )
44const core = require ( '@actions/core' )
55const exec = require ( '@actions/exec' )
6+ const common = require ( './common' )
67
78export async function run ( ) {
89 try {
9- const platform = getVirtualEnvironmentName ( )
10+ const platform = common . getVirtualEnvironmentName ( )
1011 const [ engine , version ] = parseRubyEngineAndVersion ( core . getInput ( 'ruby-version' ) )
1112
1213 let installer
@@ -171,27 +172,4 @@ function isHeadVersion(rubyVersion) {
171172 return rubyVersion === 'head' || rubyVersion === 'mingw' || rubyVersion === 'mswin'
172173}
173174
174- function getVirtualEnvironmentName ( ) {
175- const platform = os . platform ( )
176- if ( platform === 'linux' ) {
177- return `ubuntu-${ findUbuntuVersion ( ) } `
178- } else if ( platform === 'darwin' ) {
179- return 'macos-latest'
180- } else if ( platform === 'win32' ) {
181- return 'windows-latest'
182- } else {
183- throw new Error ( `Unknown platform ${ platform } ` )
184- }
185- }
186-
187- function findUbuntuVersion ( ) {
188- const lsb_release = fs . readFileSync ( '/etc/lsb-release' , 'utf8' )
189- const match = lsb_release . match ( / ^ D I S T R I B _ R E L E A S E = ( \d + \. \d + ) $ / m)
190- if ( match ) {
191- return match [ 1 ]
192- } else {
193- throw new Error ( 'Could not find Ubuntu version' )
194- }
195- }
196-
197175if ( __filename . endsWith ( 'index.js' ) ) { run ( ) }
0 commit comments