Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 24 additions & 32 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29820,73 +29820,65 @@ var toolCacheExports = requireToolCache();

try {
if (process.arch != 'x64') {
throw Error(`Unsupported architecture ${process.arch}`)
throw Error(`Unsupported architecture ${process.arch}`);
}

let pathPrefix;
switch (process.platform) {
case 'darwin':
pathPrefix = 'macosx-amd64';
break
break;
case 'linux':
pathPrefix = 'linux-amd64';
break
break;
default:
throw Error(`Unsupported platform ${process.platform}`);
}

const constructURL = (fileName) => `https://binaries.soliditylang.org/${pathPrefix}/${fileName}`;
const list = await fetch(constructURL('list.json')).then(res => res.json());

const list = (await fetch(constructURL('list.json')).then(res => res.json()));
const destDir = path.join(process.cwd(), 'setup-solc_downloads');
await fs.mkdir(destDir);
coreExports.addPath(destDir);

for (const [version, outs] of Object.entries(parseVersionInputs())) {
for (const [version, outs] of parseVersionInputs().entries()) {
coreExports.info(`Setting up solc version ${version}`);

const build = list.builds.find((build) => build.version == version);
if (build === undefined) {
throw Error(`Version ${version} not found`);
}

const downloaded = await toolCacheExports.downloadTool(constructURL(build.path));
await fs.chmod(downloaded, 0o555);

await Promise.all(
outs.map((out) => fs.copyFile(
downloaded,
path.join(destDir, out)
))
);
await Promise.all(outs.map((out) => fs.copyFile(downloaded, path.join(destDir, out))));
console.info(`${version} at ${outs}`);
}

} catch (error) {
coreExports.setFailed(error.message);
;
console.info(list);
}
catch (error) {
if (error instanceof Error) {
coreExports.setFailed(error.message);
}
else {
throw error;
}
}

function parseVersionInputs() {
let versions = {};

const versions = new Map();
const v = coreExports.getInput('version');
if (v != '') {
versions[v] = ['solc'];
versions.set(v, ['solc']);
}

const multi = coreExports.getInput('versions');
if (multi == '') {
return versions
return versions;
}
multi.split(',').forEach((v) => {
const out = `solc-v${v}`;
if (v in versions) {
versions[v].push(out);
} else {
versions[v] = [out];
if (versions.has(v)) {
versions.get(v)?.push(out);
}
else {
versions.set(v, [out]);
}
});

return versions;
}
//# sourceMappingURL=index.js.map
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

70 changes: 67 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 9 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
{
"name": "setup-solc",
"version": "0.2.0",
"version": "0.2.1",
"type": "module",
"author": "github.com/arr4n",
"license": "MIT",
"description": "A GitHub action for installing the Solidity compiler, solc.",
"scripts": {
"package": "npx rollup --config rollup.config.js --configPlugin @rollup/plugin-typescript"
},
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/tool-cache": "^2.0.2"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^28.0.6",
"@rollup/plugin-node-resolve": "^16.0.2",
"rollup": "^4.52.4"
"@rollup/plugin-typescript": "^12.1.4",
"@types/node": "^24.7.0",
"rollup": "^4.52.4",
"tslib": "^2.8.1",
"typescript": "^5.9.3"
}
}
15 changes: 8 additions & 7 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import commonjs from "@rollup/plugin-commonjs";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import typescript from '@rollup/plugin-typescript';

const config = {
input: "src/index.js",
input: 'src/index.ts',
output: {
esModule: true,
file: "dist/index.js",
format: "es",
sourcemap: true,
file: 'dist/index.js',
format: 'es',
sourcemap: true
},
plugins: [commonjs(), nodeResolve({ preferBuiltins: true })],
plugins: [typescript(), nodeResolve({ preferBuiltins: true }), commonjs()]
};

export default config;
43 changes: 27 additions & 16 deletions src/index.js → src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as fs from 'node:fs/promises'
import * as path from 'node:path';
import * as core from "@actions/core";
import * as tc from "@actions/tool-cache";
import * as core from '@actions/core';
import * as tc from '@actions/tool-cache';

try {
if (process.arch != 'x64') {
throw Error(`Unsupported architecture ${process.arch}`)
}

let pathPrefix;
let pathPrefix: string;
switch (process.platform) {
case 'darwin':
pathPrefix = 'macosx-amd64';
Expand All @@ -20,14 +20,19 @@ try {
throw Error(`Unsupported platform ${process.platform}`);
}

const constructURL = (fileName) => `https://binaries.soliditylang.org/${pathPrefix}/${fileName}`;
const list = await fetch(constructURL('list.json')).then(res => res.json());
const constructURL = (fileName: string) => `https://binaries.soliditylang.org/${pathPrefix}/${fileName}`;
const list = (await fetch(constructURL('list.json')).then(res => res.json())) as {
builds: {
version: string;
path: string;
}[];
};

const destDir = path.join(process.cwd(), 'setup-solc_downloads');
await fs.mkdir(destDir);
core.addPath(destDir);

for (const [version, outs] of Object.entries(parseVersionInputs())) {
for (const [version, outs] of parseVersionInputs().entries()) {
core.info(`Setting up solc version ${version}`);

const build = list.builds.find((build) => build.version == version);
Expand All @@ -45,18 +50,24 @@ try {
))
);
console.info(`${version} at ${outs}`);
}
};

console.info(list);

} catch (error) {
core.setFailed(error.message)
} catch (error: any) {
if (error instanceof Error) {
core.setFailed(error.message)
} else {
throw error;
}
}

function parseVersionInputs() {
let versions = {};
function parseVersionInputs(): Map<string, string[]> {
const versions = new Map<string, string[]>();

const v = core.getInput('version');
if (v != '') {
versions[v] = ['solc'];
versions.set(v, ['solc']);
}

const multi = core.getInput('versions');
Expand All @@ -65,12 +76,12 @@ function parseVersionInputs() {
}
multi.split(',').forEach((v) => {
const out = `solc-v${v}`;
if (v in versions) {
versions[v].push(out);
if (versions.has(v)) {
versions.get(v)?.push(out);
} else {
versions[v] = [out];
versions.set(v, [out]);
}
})

return versions;
}
}
25 changes: 25 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"$schema": "https://json.schemastore.org/tsconfig",
"compilerOptions": { // Source: https://github.com/actions/typescript-action under MIT
"allowSyntheticDefaultImports": true,
"declaration": false,
"declarationMap": false,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"isolatedModules": true,
"lib": [
"ES2022"
],
"module": "NodeNext",
"moduleResolution": "NodeNext",
"newLine": "lf",
"noImplicitAny": true,
"noUnusedLocals": true,
"noUnusedParameters": false,
"pretty": true,
"resolveJsonModule": true,
"strict": true,
"strictNullChecks": true,
"target": "ES2022"
}
}