Skip to content

Commit

Permalink
feat: Add support for riscv64
Browse files Browse the repository at this point in the history
  • Loading branch information
prantlf committed Aug 11, 2024
1 parent b842c92 commit 7121c78
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ where:
* `{name}` is the name of the tool (executable)
* `{platform}` is the name of the target platform: `linux`, `macos` or `windows`
* `{architecture}` is the name of the target architecture: `aarch64` or `arm64` (64-bit ARM), `amd64`, `x86_64`, `x64` or `x86` (64-bit AMD)
* `{architecture}` is the name of the target architecture: `aarch64` or `arm64` (64-bit ARM), `riscv64` (RISC-V), `amd64`, `x86_64`, `x64` (64-bit AMD) or `x86` (32-bit Intel)

## Inputs

Expand Down Expand Up @@ -79,6 +79,7 @@ Type: `Map{String, String[]}`<br>
Default:

arm64:aarch64
riscv64:
x64:amd64,x86_64,x86

A map where keys are Node.js architectures and values are their aliases which will be recognised in names of the installation archives. The Node.js architectures name itself doesn't have to be included in the aliases. This input is a multi-line string, where each line is a map entry. The kay is separated from the value by colon (:). Aliases are separated by commas (,).
Expand Down
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ inputs:
A map where keys are Node.js architectures and values are their aliases which will be recognised in names of the installation archives. The Node.js architectures name itself doesn't have to be included in the aliases. This input is a multi-line string, where each line is a map entry. The kay is separated from the value by colon (:). Aliases are separated by commas (,).
default: |-
arm64:aarch64
riscv64:
x64:amd64,x86_64,x86
use-cache:
description: >-
Expand Down
9 changes: 5 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@ if (typeof global.crypto.getRandomValues !== 'function') {
global.crypto.getRandomValues = getRandomValues
}

const { join, resolve } = require('path')
const { join, resolve } = require('node:path')
const core = require('@actions/core')
const { exec } = require("@actions/exec")
const io = require('@actions/io')
const httpm = require('@actions/http-client')
const tc = require('@actions/tool-cache')
const { access, symlink } = require('fs').promises
const { access, symlink } = require('node:fs').promises
const MersenneTwister = require('mersenne-twister')
const { clean, satisfies, valid } = require('semver')
const { getMapOfArrays, getArchiveSuffixes } = require('./lib')

const { platform } = process
let platformSuffixes, archSuffixes
let platformSuffixes
let archSuffixes

const twister = new MersenneTwister(Math.random() * Number.MAX_SAFE_INTEGER)
function getRandomValues(dest) {
Expand Down Expand Up @@ -173,7 +174,7 @@ async function run() {
if (cleanedVersion) version = cleanedVersion;
const name = core.getInput('name')
const useCache = core.getBooleanInput('use-cache')
core.info(`Download ${version} from ${repo}${name ? 'named ' + name : ''}${useCache ? '' : ', no cache'}`)
core.info(`Download ${version} from ${repo}${name ? `named ${name}` : ''}${useCache ? '' : ', no cache'}`)
platformSuffixes = getMapOfArrays('platforms')
archSuffixes = getMapOfArrays('architectures')

Expand Down
2 changes: 1 addition & 1 deletion src/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ exports.getArchiveSuffixes = function getArchiveSuffixes(platformSuffixes, archS
if (!plats.includes(platform)) plats.push(platform)
const archs = archSuffixes[arch] || []
if (!archs.includes(arch)) archs.push(arch)
return plats.map(plat => archs.map(arch => `-${plat}-${arch}.zip`)).flat()
return plats.flatMap(plat => archs.map(arch => `-${plat}-${arch}.zip`))
}
4 changes: 4 additions & 0 deletions test/getArchiveSuffixes.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const platforms = {

const archives = {
arm64: ['aarch64'],
riscv64: [],
x64: ['amd64', 'x86_64', 'x86']
}

Expand Down Expand Up @@ -42,6 +43,9 @@ const expected = {
'-linux-arm64.zip',
'-linux-aarch64.zip'
],
'linux-riscv64': [
'-linux-riscv64.zip'
],
'win32-x64': [
'-win-amd64.zip',
'-win-x86_64.zip',
Expand Down

0 comments on commit 7121c78

Please sign in to comment.