Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #7 from clupprich/osx-support
Browse files Browse the repository at this point in the history
Support for macOS
  • Loading branch information
clupprich authored Nov 18, 2019
2 parents 14dd06b + 33c6b5b commit d297155
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 68 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-16.04, ubuntu-latest]
os: [ubuntu-16.04, ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v1
Expand Down
112 changes: 64 additions & 48 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,57 @@ class ExecState extends events.EventEmitter {
}
//# sourceMappingURL=toolrunner.js.map

/***/ }),

/***/ 63:
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "type", function() { return type; });
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "version", function() { return version; });
const fs = __webpack_require__(747)
const os = __webpack_require__(87)
const camelCase = __webpack_require__(177)

const LINE_MATCH = /^(\w+)=["']?([\w\s\.]+)["']?$/

function _lsbRelease() {
const content = fs.readFileSync('/etc/lsb-release', 'utf8')

const obj = {}

content.split("\n").forEach(function(line) {
const matches = line.match(LINE_MATCH)

if (matches) {
obj[camelCase(matches[1])] = matches[2]
}
})

return obj
}

function type() {
const type = os.type()
if (type == 'Linux') {
try {
const lsbRelease = _lsbRelease()
return lsbRelease.distribId
}
catch { }
}

return type
}

function version() {
if (type() == 'Ubuntu') {
return _lsbRelease().distribRelease
}
}


/***/ }),

/***/ 87:
Expand Down Expand Up @@ -1514,30 +1565,25 @@ function isUnixExecutable(stats) {
const core = __webpack_require__(470);
const exec = __webpack_require__(986);
const io = __webpack_require__(1);
const os = __webpack_require__(888)

function _dependenciesForPlatform(platform) {
return {
'ubuntu-16.04': 'autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev',
'ubuntu-18.04': 'autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev'
}[platform]
}
const platform = __webpack_require__(63)

function _getPlatform() {
const releaseInfo = os.releaseInfo()
function _dependenciesCmdForPlatformVersion(platform, version) {
if (platform == 'Ubuntu') {
const dependencies = {
'16.04': 'autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev',
'18.04': 'autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev'
}[version]

return `${releaseInfo.distribId.toLowerCase()}-${releaseInfo.distribRelease}`
return `sudo apt-get -qq install ${dependencies}`
}
}

async function _installDependencies() {
const platform = _getPlatform()
const dependencies = _dependenciesForPlatform(platform)
if (!dependencies) {
core.setFailed(`Cannot find dependencies for platform ${platform}`)
return
}
const dependenciesCmd = _dependenciesCmdForPlatformVersion(platform.type(), platform.version())

await exec.exec(`sudo apt-get -qq install ${dependencies}`)
if (dependenciesCmd) {
await exec.exec(dependenciesCmd)
}
}

async function _installRubyBuild() {
Expand Down Expand Up @@ -1592,36 +1638,6 @@ run()

module.exports = require("fs");

/***/ }),

/***/ 888:
/***/ (function(__unusedmodule, __webpack_exports__, __webpack_require__) {

"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "releaseInfo", function() { return releaseInfo; });
const fs = __webpack_require__(747)
const camelCase = __webpack_require__(177)

const LINE_MATCH = /^(\w+)=["']?([\w\s\.]+)["']?$/

function releaseInfo() {
const content = fs.readFileSync('/etc/lsb-release', 'utf8')

const obj = {}

content.split("\n").forEach(function(line) {
const matches = line.match(LINE_MATCH)

if (matches) {
obj[camelCase(matches[1])] = matches[2]
}
})

return obj
}


/***/ }),

/***/ 986:
Expand Down
31 changes: 13 additions & 18 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,25 @@
const core = require('@actions/core');
const exec = require('@actions/exec');
const io = require('@actions/io');
const os = require('./os')
const platform = require('./platform')

function _dependenciesForPlatform(platform) {
return {
'ubuntu-16.04': 'autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev',
'ubuntu-18.04': 'autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev'
}[platform]
}

function _getPlatform() {
const releaseInfo = os.releaseInfo()
function _dependenciesCmdForPlatformVersion(platform, version) {
if (platform == 'Ubuntu') {
const dependencies = {
'16.04': 'autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev',
'18.04': 'autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm5 libgdbm-dev'
}[version]

return `${releaseInfo.distribId.toLowerCase()}-${releaseInfo.distribRelease}`
return `sudo apt-get -qq install ${dependencies}`
}
}

async function _installDependencies() {
const platform = _getPlatform()
const dependencies = _dependenciesForPlatform(platform)
if (!dependencies) {
core.setFailed(`Cannot find dependencies for platform ${platform}`)
return
}
const dependenciesCmd = _dependenciesCmdForPlatformVersion(platform.type(), platform.version())

await exec.exec(`sudo apt-get -qq install ${dependencies}`)
if (dependenciesCmd) {
await exec.exec(dependenciesCmd)
}
}

async function _installRubyBuild() {
Expand Down
22 changes: 21 additions & 1 deletion src/os.js → src/platform.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const fs = require('fs')
const os = require('os')
const camelCase = require('camelcase')

const LINE_MATCH = /^(\w+)=["']?([\w\s\.]+)["']?$/

export function releaseInfo() {
function _lsbRelease() {
const content = fs.readFileSync('/etc/lsb-release', 'utf8')

const obj = {}
Expand All @@ -18,3 +19,22 @@ export function releaseInfo() {

return obj
}

export function type() {
const type = os.type()
if (type == 'Linux') {
try {
const lsbRelease = _lsbRelease()
return lsbRelease.distribId
}
catch { }
}

return type
}

export function version() {
if (type() == 'Ubuntu') {
return _lsbRelease().distribRelease
}
}

0 comments on commit d297155

Please sign in to comment.