Skip to content

Commit

Permalink
Additional try at using tool-cache
Browse files Browse the repository at this point in the history
Signed-off-by: John Kjell <[email protected]>
  • Loading branch information
jkjell committed Apr 13, 2024
1 parent 2ae7f93 commit de3213c
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 27 deletions.
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ inputs:
description: "Enable tracing for the command"
required: false
default: "false"
version:
description: "Version of Witness CLI"
required: false
default: "0.4.0-beta"
workingdir:
description: "Directory from which commands will run"
required: false
Expand Down
26 changes: 0 additions & 26 deletions ci/download-compress-witness.sh

This file was deleted.

Binary file removed dist/witness
Binary file not shown.
32 changes: 31 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,38 @@ const process = require("process");
const fs = require("fs");
const os = require("os");
const path = require("path");
const tc = require('@actions/tool-cache');

async function run() {
// Download Witness
const version = core.getInput("version");
const witnessExtractPath = '/witness/'

const witnessPath = tc.find('witness', version);
console.log('Cached Witness Path: ' + witnessPath);
core.addPath(witnessPath);
console.log('Witness Directory: ' + witnessPath);

if (!witnessPath) {
console.log('Witness not found in cache, downloading now');

if (process.platform === 'win32') {
const witnessTar = await tc.downloadTool('https://github.com/in-toto/witness/releases/download/v' + version + '/witness_' + version + '_windows_amd64.tar.gz"');
witnessPath = await tc.extractZip(witnessPath, witnessExtractPath);
}
else if (process.platform === 'darwin') {
const witnessTar = await tc.downloadTool('https://github.com/in-toto/witness/releases/download/v' + version + '/witness_' + version + '_darwin_amd64.tar.gz"');
witnessPath = await tc.extractXar(witnessPath, witnessExtractPath);
}
else {
const witnessTar = await tc.downloadTool('https://github.com/in-toto/witness/releases/download/v' + version + '/witness_' + version + '_linux_amd64.tar.gz"');
witnessPath = await tc.extractTar(witnessPath, witnessExtractPath);
}

const cachedPath = await tc.cacheFile(witnessPath + 'witness', 'witness', 'witness', version);

}

const step = core.getInput("step");
const archivistaServer = core.getInput("archivista-server");
const attestations = core.getInput("attestations").split(" ");
Expand Down Expand Up @@ -100,7 +130,7 @@ async function run() {
const commandArray = command.match(/(?:[^\s"]+|"[^"]*")+/g);

// Execute the command and capture its output
const runArray = ["witness", ...cmd, "--", ...commandArray],
const runArray = [witnessPath, ...cmd, "--", ...commandArray],
commandString = runArray.join(" ");

let output = "";
Expand Down

0 comments on commit de3213c

Please sign in to comment.