Skip to content

Commit

Permalink
clear logs
Browse files Browse the repository at this point in the history
  • Loading branch information
mbarre committed Mar 17, 2023
1 parent d73065e commit f96363f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
21 changes: 12 additions & 9 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ const axios = __nccwpck_require__(5192);

module.exports = async function () {
try {
let version = core.getInput('version');
const inputVersion = core.getInput('version');
let latestVersion;
const url = `https://github.com/duckdb/duckdb/releases/download/${version}/duckdb_cli-linux-amd64.zip`
let selectedVersion;

const wgetCmd = `wget ${url}`
const unzipCmd = `unzip duckdb_cli-linux-amd64.zip`
const installCmd = 'mkdir /opt/duckdb && mv duckdb /opt/duckdb && chmod +x /opt/duckdb/duckdb && sudo ln -s /opt/duckdb/duckdb /usr/bin/duckdb'
const checkVersionCmd = 'duckdb --version'
const cleanupCmd = 'rm duckdb_cli-linux-amd64.zip'

core.info(`🔍 looking for the latest DuckDB version.`);
const headers = {'Accept': 'application/vnd.github+json', 'X-GitHub-Api-Version': '2022-11-28'}
const res = await axios.get('https://api.github.com/repos/duckdb/duckdb/releases/latest', {headers: headers});
Expand All @@ -31,16 +31,19 @@ module.exports = async function () {
latestVersion = res.data.tag_name;
}

if (version === 'latest') {
if (inputVersion === 'latest') {
core.info(`📦 DuckDb latest version requested : ${latestVersion} will be installed.`);
selectedVersion = latestVersion;
}
else {
core.info(`📦 DuckDb ${version} requested.`);
if (version != latestVersion)
core.warning(`🆕 DuckDb ${version} is available.`);
selectedVersion = inputVersion;
core.info(`📦 DuckDb ${inputVersion} requested.`);
if (inputVersion != latestVersion)
core.warning(`🆕 DuckDb ${latestVersion} is available.`);
}

core.info(`📥 Install DuckDB version : ${version}`);
core.info(`📥 Install DuckDB version : ${selectedVersion}`);
const url = `https://github.com/duckdb/duckdb/releases/download/${selectedVersion}/duckdb_cli-linux-amd64.zip`
exec(`${wgetCmd} && ${unzipCmd} && ${installCmd} && ${cleanupCmd} && ${checkVersionCmd}`, (error, stdout, stderr) => {
if (error) {
core.error(`❌ ${error.message}`);
Expand All @@ -51,7 +54,7 @@ module.exports = async function () {
core.error(`❌ ${stderr}`);
return;
}
core.info(`🚀 DuckDB ${version} successfully installed.`);
core.info(`🚀 DuckDB ${selectedVersion} successfully installed.`);
});
} catch (error) {
core.setFailed(error.message);
Expand Down
21 changes: 12 additions & 9 deletions lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const axios = require('axios');

module.exports = async function () {
try {
let version = core.getInput('version');
const inputVersion = core.getInput('version');
let latestVersion;
const url = `https://github.com/duckdb/duckdb/releases/download/${version}/duckdb_cli-linux-amd64.zip`
let selectedVersion;

const wgetCmd = `wget ${url}`
const unzipCmd = `unzip duckdb_cli-linux-amd64.zip`
const installCmd = 'mkdir /opt/duckdb && mv duckdb /opt/duckdb && chmod +x /opt/duckdb/duckdb && sudo ln -s /opt/duckdb/duckdb /usr/bin/duckdb'
const checkVersionCmd = 'duckdb --version'
const cleanupCmd = 'rm duckdb_cli-linux-amd64.zip'

core.info(`🔍 looking for the latest DuckDB version.`);
const headers = {'Accept': 'application/vnd.github+json', 'X-GitHub-Api-Version': '2022-11-28'}
const res = await axios.get('https://api.github.com/repos/duckdb/duckdb/releases/latest', {headers: headers});
Expand All @@ -25,16 +25,19 @@ module.exports = async function () {
latestVersion = res.data.tag_name;
}

if (version === 'latest') {
if (inputVersion === 'latest') {
core.info(`📦 DuckDb latest version requested : ${latestVersion} will be installed.`);
selectedVersion = latestVersion;
}
else {
core.info(`📦 DuckDb ${version} requested.`);
if (version != latestVersion)
core.warning(`🆕 DuckDb ${version} is available.`);
selectedVersion = inputVersion;
core.info(`📦 DuckDb ${inputVersion} requested.`);
if (inputVersion != latestVersion)
core.warning(`🆕 DuckDb ${latestVersion} is available.`);
}

core.info(`📥 Install DuckDB version : ${version}`);
core.info(`📥 Install DuckDB version : ${selectedVersion}`);
const url = `https://github.com/duckdb/duckdb/releases/download/${selectedVersion}/duckdb_cli-linux-amd64.zip`
exec(`${wgetCmd} && ${unzipCmd} && ${installCmd} && ${cleanupCmd} && ${checkVersionCmd}`, (error, stdout, stderr) => {
if (error) {
core.error(`❌ ${error.message}`);
Expand All @@ -45,7 +48,7 @@ module.exports = async function () {
core.error(`❌ ${stderr}`);
return;
}
core.info(`🚀 DuckDB ${version} successfully installed.`);
core.info(`🚀 DuckDB ${selectedVersion} successfully installed.`);
});
} catch (error) {
core.setFailed(error.message);
Expand Down

0 comments on commit f96363f

Please sign in to comment.