mirror of
https://github.com/audacity/audacity-actions.git
synced 2025-12-10 03:56:07 -06:00
82 lines
2.3 KiB
JavaScript
82 lines
2.3 KiB
JavaScript
const core = require('@actions/core');
|
|
const artifact = require('@actions/artifact');
|
|
const toolCache = require('@actions/tool-cache');
|
|
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const helpers = require('../lib/helpers.js');
|
|
|
|
const offlineCacheLocation = path.join(workspaceDir, '.offline');
|
|
const bin_path = path.join(offlineCacheLocation, 'bin');
|
|
|
|
const conanCacheLocation = path.join(offlineCacheLocation, 'conan');
|
|
const conanDownloadCacheLocation = path.join(conanCacheLocation, 'download_cache');
|
|
|
|
|
|
async function downloadConan(version) {
|
|
const cached_path = await toolCache.downloadTool(`https://github.com/audacity/conan-appimage/releases/download/v${version}/conan-${version}-x86_64.AppImage`)
|
|
|
|
if (!fs.existsSync(bin_path)) {
|
|
fs.mkdirSync(bin_path, { recursive: true });
|
|
}
|
|
|
|
const conan_path = path.join(bin_path, 'conan');
|
|
|
|
fs.copyFileSync(cached_path, conan_path);
|
|
|
|
console.log(`Copied ${cached_path} to ${conan_path}`);
|
|
fs.chmodSync(conan_path, '755');
|
|
return conan_path;
|
|
}
|
|
|
|
async function prepareEnvironment() {
|
|
conan = await downloadConan('2.0.7');
|
|
|
|
core.exportVariable('CONAN_HOME', conanCacheLocation);
|
|
core.addPath(bin_path);
|
|
|
|
await helpers.execWithLog(conan, [
|
|
'config', 'init'
|
|
]);
|
|
|
|
await helpers.execWithLog(conan, [
|
|
'config', 'set',
|
|
`storage.download_cache=${conanDownloadCacheLocation}`
|
|
]);
|
|
|
|
const compiler = (await helpers.getExecOutput(conan, ['profile', 'get', 'settings.compiler', 'default'])).stdout.trim();
|
|
|
|
if (compiler === 'gcc') {
|
|
await helpers.execWithLog(conan, [
|
|
'profile',
|
|
'update',
|
|
'settings.compiler.libcxx=libstdc++11',
|
|
'default',
|
|
]);
|
|
}
|
|
|
|
return conanDownloadCacheLocation;
|
|
}
|
|
|
|
async function upload() {
|
|
const revision = (await helpers.getExecOutput('git', ['show', '-s', '--format=%h'])).stdout.trim();
|
|
|
|
const name = `audacity-dependencies-${helpers.getDateString()}+${revision}`;
|
|
const tarball = `${name}.tar.gz`
|
|
|
|
await helpers.execWithLog('tar', [
|
|
'czf', tarball,
|
|
'-C', workspaceDir,
|
|
'.offline'
|
|
]);
|
|
|
|
const artifactClient = artifact.create();
|
|
await artifactClient.uploadArtifact(name, [ tarball ], workspaceDir);
|
|
}
|
|
|
|
module.exports = {
|
|
prepareEnvironment: prepareEnvironment,
|
|
upload: upload
|
|
}
|