mirror of
https://github.com/ruby/setup-ruby.git
synced 2026-09-13 06:34:19 +02:00
Add token input and pass it to release assets download.
This commit is contained in:
committed by
Benoit Daloze
parent
be19563477
commit
7f50f6e3b3
@@ -152,6 +152,23 @@ and the [condition and expression syntax](https://help.github.com/en/actions/ref
|
||||
The `working-directory` input can be set to resolve `.ruby-version`, `.tool-versions`, `mise.toml` and `Gemfile.lock`
|
||||
if they are not at the root of the repository, see [action.yml](action.yml) for details.
|
||||
|
||||
### Authentication Token
|
||||
|
||||
By default, this action uses `${{ github.token }}` to authenticate when downloading Ruby release assets from GitHub.
|
||||
This helps avoid rate limiting issues.
|
||||
|
||||
If you're running this action on a GitHub Enterprise Server (GHES) instance, or if you're experiencing rate limiting,
|
||||
you can provide a custom token:
|
||||
|
||||
```yaml
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: '3.4'
|
||||
token: ${{ secrets.MY_GITHUB_TOKEN }}
|
||||
```
|
||||
|
||||
In most cases, you don't need to set this input as the default value is sufficient for use on github.com.
|
||||
|
||||
### RubyGems
|
||||
|
||||
By default, the default RubyGems version that comes with each Ruby is used.
|
||||
|
||||
@@ -44,6 +44,13 @@ inputs:
|
||||
It also sets environment variables using 'ridk' or 'vcvars64.bat' based on the selected Ruby.
|
||||
At present, the only other setting than 'default' is 'none', which only adds Ruby to PATH.
|
||||
No build tools or packages are installed, nor are any ENV setting changed to activate them.
|
||||
token:
|
||||
description: |
|
||||
Used to authenticate with GitHub when downloading Ruby release assets.
|
||||
Since there is a default, this is typically not supplied by the user.
|
||||
When running this action on github.com, the default value is sufficient.
|
||||
When running on GHES, you can pass a personal access token for github.com if you are experiencing rate limiting.
|
||||
default: ${{ github.server_url == 'https://github.com' && github.token || '' }}
|
||||
|
||||
outputs:
|
||||
ruby-prefix:
|
||||
|
||||
@@ -16,7 +16,8 @@ export const drive = (windows ? (process.env['RUNNER_TEMP'] || 'C')[0] : undefin
|
||||
const PATH_ENV_VAR = windows ? 'Path' : 'PATH'
|
||||
|
||||
export const inputs = {
|
||||
selfHosted: undefined
|
||||
selfHosted: undefined,
|
||||
token: undefined
|
||||
}
|
||||
|
||||
export function partition(string, separator) {
|
||||
|
||||
+14
-6
@@ -348,7 +348,8 @@ const drive = (windows ? (process.env['RUNNER_TEMP'] || 'C')[0] : undefined)
|
||||
const PATH_ENV_VAR = windows ? 'Path' : 'PATH'
|
||||
|
||||
const inputs = {
|
||||
selfHosted: undefined
|
||||
selfHosted: undefined,
|
||||
token: undefined
|
||||
}
|
||||
|
||||
function partition(string, separator) {
|
||||
@@ -71373,8 +71374,9 @@ async function downloadAndExtract(platform, engine, version, rubyPrefix) {
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
const url = getDownloadURL(platform, engine, version)
|
||||
console.log(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
try {
|
||||
return await tc.downloadTool(url)
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
} catch (error) {
|
||||
if (error.message.includes('404')) {
|
||||
throw new Error(`Unavailable version ${version} for ${engine} on ${platform}
|
||||
@@ -71599,7 +71601,8 @@ async function install(platform, engine, version) {
|
||||
async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
})
|
||||
|
||||
const extractPath = process.env.RUNNER_TEMP
|
||||
@@ -71631,7 +71634,8 @@ async function installJRubyTools() {
|
||||
async function installMSYS2(url, rubyPrefix = process.env.RUNNER_TEMP) {
|
||||
const downloadPath = await common.measure('Downloading msys2 build tools', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
})
|
||||
|
||||
const extractPath = path.join(process.env.RUNNER_TEMP, 'msys64')
|
||||
@@ -71678,7 +71682,8 @@ async function installMSYS1(url) {
|
||||
|
||||
const downloadPath = await common.measure('Downloading msys1 build tools', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
})
|
||||
|
||||
const msys1Path = `${common.drive}:\\DevKit64`
|
||||
@@ -71714,7 +71719,8 @@ async function installMSYS1(url) {
|
||||
async function installVCPKG(url) {
|
||||
const downloadPath = await common.measure('Downloading mswin vcpkg packages', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
})
|
||||
|
||||
const extractPath = process.env.VCPKG_INSTALLATION_ROOT
|
||||
@@ -85300,6 +85306,7 @@ const inputDefaults = {
|
||||
'cache-version': bundler.DEFAULT_CACHE_VERSION,
|
||||
'self-hosted': 'false',
|
||||
'windows-toolchain': 'default',
|
||||
'token': '',
|
||||
}
|
||||
|
||||
// entry point when this action is run on its own
|
||||
@@ -85327,6 +85334,7 @@ async function setupRuby(options = {}) {
|
||||
}
|
||||
}
|
||||
common.inputs.selfHosted = inputs['self-hosted']
|
||||
common.inputs.token = inputs['token']
|
||||
|
||||
process.chdir(inputs['working-directory'])
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ const inputDefaults = {
|
||||
'cache-version': bundler.DEFAULT_CACHE_VERSION,
|
||||
'self-hosted': 'false',
|
||||
'windows-toolchain': 'default',
|
||||
'token': '',
|
||||
}
|
||||
|
||||
// entry point when this action is run on its own
|
||||
@@ -45,6 +46,7 @@ export async function setupRuby(options = {}) {
|
||||
}
|
||||
}
|
||||
common.inputs.selfHosted = inputs['self-hosted']
|
||||
common.inputs.token = inputs['token']
|
||||
|
||||
process.chdir(inputs['working-directory'])
|
||||
|
||||
|
||||
+2
-1
@@ -74,8 +74,9 @@ async function downloadAndExtract(platform, engine, version, rubyPrefix) {
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
const url = getDownloadURL(platform, engine, version)
|
||||
console.log(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
try {
|
||||
return await tc.downloadTool(url)
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
} catch (error) {
|
||||
if (error.message.includes('404')) {
|
||||
throw new Error(`Unavailable version ${version} for ${engine} on ${platform}
|
||||
|
||||
+8
-4
@@ -81,7 +81,8 @@ export async function install(platform, engine, version) {
|
||||
async function downloadAndExtract(engine, version, url, base, rubyPrefix) {
|
||||
const downloadPath = await common.measure('Downloading Ruby', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
})
|
||||
|
||||
const extractPath = process.env.RUNNER_TEMP
|
||||
@@ -113,7 +114,8 @@ export async function installJRubyTools() {
|
||||
async function installMSYS2(url, rubyPrefix = process.env.RUNNER_TEMP) {
|
||||
const downloadPath = await common.measure('Downloading msys2 build tools', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
})
|
||||
|
||||
const extractPath = path.join(process.env.RUNNER_TEMP, 'msys64')
|
||||
@@ -160,7 +162,8 @@ async function installMSYS1(url) {
|
||||
|
||||
const downloadPath = await common.measure('Downloading msys1 build tools', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
})
|
||||
|
||||
const msys1Path = `${common.drive}:\\DevKit64`
|
||||
@@ -196,7 +199,8 @@ async function installMSYS1(url) {
|
||||
async function installVCPKG(url) {
|
||||
const downloadPath = await common.measure('Downloading mswin vcpkg packages', async () => {
|
||||
console.log(url)
|
||||
return await tc.downloadTool(url)
|
||||
const auth = common.inputs.token ? `token ${common.inputs.token}` : undefined
|
||||
return await tc.downloadTool(url, undefined, auth)
|
||||
})
|
||||
|
||||
const extractPath = process.env.VCPKG_INSTALLATION_ROOT
|
||||
|
||||
Reference in New Issue
Block a user