Skip to content

Commit ba0d1c8

Browse files
committed
Use the latest release files from ruby-install-builder
1 parent 0465980 commit ba0d1c8

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

dist/index.js

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

index.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ const io = require('@actions/io')
55
const tc = require('@actions/tool-cache')
66
const axios = require('axios')
77

8+
const releasesURL = 'https://github.com/eregon/ruby-install-builder/releases'
9+
const metadataURL = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata'
10+
811
async function run() {
912
try {
1013
const ruby = await getRubyEngineAndVersion(core.getInput('ruby-version'))
@@ -13,7 +16,8 @@ async function run() {
1316
await io.mkdirP(rubiesDir)
1417

1518
const platform = getVirtualEnvironmentName()
16-
const url = `https://github.com/eregon/ruby-install-builder/releases/download/builds/${ruby}-${platform}.tar.gz`
19+
const tag = await getLatestReleaseTag()
20+
const url = `${releasesURL}/download/${tag}/${ruby}-${platform}.tar.gz`
1721
console.log(url)
1822

1923
const downloadPath = await tc.downloadTool(url)
@@ -27,13 +31,17 @@ async function run() {
2731
}
2832
}
2933

34+
async function getLatestReleaseTag() {
35+
const response = await axios.get(`${metadataURL}/latest_release.tag`)
36+
return response.data.trim()
37+
}
38+
3039
async function getRubyEngineAndVersion(rubyVersion) {
3140
if (rubyVersion.match(/^\d+/)) { // X.Y.Z => ruby-X.Y.Z
3241
return 'ruby-' + rubyVersion
3342
} else if (!rubyVersion.includes('-')) { // myruby -> myruby-stableVersion
3443
const engine = rubyVersion
35-
const versionsUrl = 'https://raw.githubusercontent.com/eregon/ruby-install-builder/metadata/versions.json'
36-
const response = await axios.get(versionsUrl)
44+
const response = await axios.get(`${metadataURL}/versions.json`)
3745
const stableVersions = response.data[engine]
3846
const latestStableVersion = stableVersions[stableVersions.length-1]
3947
return engine + '-' + latestStableVersion

0 commit comments

Comments
 (0)