create tar.gz from source

This commit is contained in:
Naveenraj M
2020-03-30 02:15:32 +05:30
parent ab399dde5d
commit 9019e7252b
2 changed files with 43 additions and 41 deletions

View File

@ -24,34 +24,21 @@ function run() {
console.log(`We can even get context data, like the owner: ${owner}, repo: ${repo}, ref: ${ref}`); console.log(`We can even get context data, like the owner: ${owner}, repo: ${repo}, ref: ${ref}`);
const specFile = core.getInput('specFile'); const specFile = core.getInput('specFile');
console.log(`Hello ${specFile} from inside a container`); console.log(`Hello ${specFile} from inside a container`);
// setup rpm tree
yield exec.exec('rpmdev-setuptree'); yield exec.exec('rpmdev-setuptree');
// Get repo files from /github/workspace/
yield exec.exec('ls -la ');
// Copy spec file from path specFile to /root/rpmbuild/SPECS/ // Copy spec file from path specFile to /root/rpmbuild/SPECS/
yield io.cp('/github/workspace/cello.spec', '/github/home/rpmbuild/SPECS/'); yield io.cp(`/github/workspace/${specFile}`, '/github/home/rpmbuild/SPECS/');
// Get tar.gz file of release yield exec.exec(`cp -R /github/workspace/ /tmp/${repo}`);
// await download_tar( yield exec.exec(`cd /tmp/ && tar -czvf ${repo}.tar.gz ${repo}`);
// owner,
// repo,
// ref
// ).then( function(filePath){
// console.log(`Tar Path for copy : ${filePath}`);
// io.cp(`${repo}-1.0.tar.gz`, '/github/home/rpmbuild/SOURCES/');
// }).catch(function(error){
// console.log(error);
// });
yield exec.exec('curl -L --output cello-1.0.0.tar.gz https://github.com/naveenrajm7/cello/archive/v1.0.0.tar.gz');
//console.log(`Tar Path for copy : ${tarBallPath}`);
yield exec.exec('echo "$HOME"');
// Get repo files from /github/workspace/ // Get repo files from /github/workspace/
yield exec.exec('ls -la '); yield exec.exec('ls -la ');
yield io.cp(`${repo}-1.0.0.tar.gz`, '/github/home/rpmbuild/SOURCES/'); yield io.cp(`/tmp/${repo}.tar.gz`, '/github/home/rpmbuild/SOURCES/');
// Copy tar.gz file to /root/rpmbuild/SOURCES // Copy tar.gz file to /root/rpmbuild/SOURCES
// make sure the name of tar.gz is same as given in Source of spec file // make sure the name of tar.gz is same as given in Source of spec file
//await io.cp(tarBallPath, '/root/rpmbuild/SOURCES'); //await io.cp(tarBallPath, '/root/rpmbuild/SOURCES');
// Execute rpmbuild // Execute rpmbuild
try { try {
yield exec.exec(`rpmbuild -ba /github/home/rpmbuild/SPECS/cello.spec`); yield exec.exec(`rpmbuild -ba /github/home/rpmbuild/SPECS/${specFile}`);
} }
catch (err) { catch (err) {
core.setFailed(`action failed with error: ${err}`); core.setFailed(`action failed with error: ${err}`);
@ -63,7 +50,20 @@ function run() {
// actions/upload-release-asset // actions/upload-release-asset
// If you want to upload yourself , need to write api call to upload as asset // If you want to upload yourself , need to write api call to upload as asset
//core.setOutput("rpmPath", rpmPath) //core.setOutput("rpmPath", rpmPath)
core.setOutput("source_rpm_path", "/github/home/rpmbuild/SRPMS"); // make option to upload source rpm let myOutput = '';
let myError = '';
const options = {};
options.listeners = {
stdout: (data) => {
myOutput += data.toString();
},
stderr: (data) => {
myError += data.toString();
}
};
options.cwd = '/github/home/rpmbuild/SRPMS/';
yield exec.exec('ls', options);
core.setOutput("source_rpm_path", `/github/home/rpmbuild/SRPMS/${myOutput}`); // make option to upload source rpm
} }
catch (error) { catch (error) {
core.setFailed(error.message); core.setFailed(error.message);

View File

@ -19,33 +19,19 @@ async function run() {
const specFile = core.getInput('specFile'); const specFile = core.getInput('specFile');
console.log(`Hello ${specFile} from inside a container`); console.log(`Hello ${specFile} from inside a container`);
// setup rpm tree
await exec.exec('rpmdev-setuptree'); await exec.exec('rpmdev-setuptree');
// Get repo files from /github/workspace/
await exec.exec('ls -la ');
// Copy spec file from path specFile to /root/rpmbuild/SPECS/ // Copy spec file from path specFile to /root/rpmbuild/SPECS/
await io.cp('/github/workspace/cello.spec', '/github/home/rpmbuild/SPECS/'); await io.cp(`/github/workspace/${specFile}`, '/github/home/rpmbuild/SPECS/');
// Get tar.gz file of release await exec.exec(`cp -R /github/workspace/ /tmp/${repo}`);
// await download_tar(
// owner,
// repo,
// ref
// ).then( function(filePath){
// console.log(`Tar Path for copy : ${filePath}`);
// io.cp(`${repo}-1.0.tar.gz`, '/github/home/rpmbuild/SOURCES/');
// }).catch(function(error){
// console.log(error);
// });
await exec.exec('curl -L --output cello-1.0.0.tar.gz https://github.com/naveenrajm7/cello/archive/v1.0.0.tar.gz') await exec.exec(`cd /tmp/ && tar -czvf ${repo}.tar.gz ${repo}`);
//console.log(`Tar Path for copy : ${tarBallPath}`);
await exec.exec('echo "$HOME"');
// Get repo files from /github/workspace/ // Get repo files from /github/workspace/
await exec.exec('ls -la '); await exec.exec('ls -la ');
await io.cp(`${repo}-1.0.0.tar.gz`, '/github/home/rpmbuild/SOURCES/'); await io.cp(`/tmp/${repo}.tar.gz`, '/github/home/rpmbuild/SOURCES/');
// Copy tar.gz file to /root/rpmbuild/SOURCES // Copy tar.gz file to /root/rpmbuild/SOURCES
// make sure the name of tar.gz is same as given in Source of spec file // make sure the name of tar.gz is same as given in Source of spec file
@ -54,7 +40,7 @@ async function run() {
// Execute rpmbuild // Execute rpmbuild
try { try {
await exec.exec( await exec.exec(
`rpmbuild -ba /github/home/rpmbuild/SPECS/cello.spec` `rpmbuild -ba /github/home/rpmbuild/SPECS/${specFile}`
); );
} catch (err) { } catch (err) {
core.setFailed(`action failed with error: ${err}`); core.setFailed(`action failed with error: ${err}`);
@ -68,7 +54,23 @@ async function run() {
// actions/upload-release-asset // actions/upload-release-asset
// If you want to upload yourself , need to write api call to upload as asset // If you want to upload yourself , need to write api call to upload as asset
//core.setOutput("rpmPath", rpmPath) //core.setOutput("rpmPath", rpmPath)
core.setOutput("source_rpm_path", "/github/home/rpmbuild/SRPMS") // make option to upload source rpm let myOutput = '';
let myError = '';
const options: any = { };
options.listeners = {
stdout: (data: Buffer) => {
myOutput += data.toString();
},
stderr: (data: Buffer) => {
myError += data.toString();
}
};
options.cwd = '/github/home/rpmbuild/SRPMS/';
await exec.exec('ls', options);
core.setOutput("source_rpm_path", `/github/home/rpmbuild/SRPMS/${myOutput}`); // make option to upload source rpm
} catch (error) { } catch (error) {
core.setFailed(error.message); core.setFailed(error.message);