mirror of
https://github.com/naveenrajm7/rpmbuild.git
synced 2025-07-12 04:13:50 +00:00
read values from spec file
This commit is contained in:
@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
const { Octokit } = require('@octokit/rest');
|
const { Octokit } = require('@octokit/rest');
|
||||||
const fs = require('fs');
|
//const fs = require('fs');
|
||||||
const tc = require('@actions/tool-cache');
|
const tc = require('@actions/tool-cache');
|
||||||
function download_archive(owner, repo, ref) {
|
function download_archive(owner, repo, ref) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
29
lib/main.js
29
lib/main.js
@ -12,8 +12,8 @@ const core = require('@actions/core');
|
|||||||
const github = require('@actions/github');
|
const github = require('@actions/github');
|
||||||
const exec = require('@actions/exec');
|
const exec = require('@actions/exec');
|
||||||
const io = require('@actions/io');
|
const io = require('@actions/io');
|
||||||
const download_tar = require('./download-release-archive');
|
|
||||||
const cp = require('child_process');
|
const cp = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
@ -22,25 +22,40 @@ function run() {
|
|||||||
const owner = context.repo.owner;
|
const owner = context.repo.owner;
|
||||||
const repo = context.repo.repo;
|
const repo = context.repo.repo;
|
||||||
const ref = context.ref;
|
const ref = context.ref;
|
||||||
const version = "1.0.0";
|
|
||||||
// get inputs from workflow
|
// get inputs from workflow
|
||||||
|
// specFile name
|
||||||
const specFile = core.getInput('spec_file');
|
const specFile = core.getInput('spec_file');
|
||||||
|
// Read spec file and get values
|
||||||
|
var data = fs.readFileSync('cello/cello.spec', 'utf8');
|
||||||
|
let name = '';
|
||||||
|
let version = '';
|
||||||
|
for (var line of data.split('\n')) {
|
||||||
|
var lineArray = line.split(/[ ]+/);
|
||||||
|
if (lineArray[0].includes('Name')) {
|
||||||
|
name = name + lineArray[1];
|
||||||
|
}
|
||||||
|
if (lineArray[0].includes('Version')) {
|
||||||
|
version = version + lineArray[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(`name: ${name}`);
|
||||||
|
console.log(`version: ${version}`);
|
||||||
// setup rpm tree
|
// setup rpm tree
|
||||||
yield exec.exec('rpmdev-setuptree');
|
yield exec.exec('rpmdev-setuptree');
|
||||||
// Copy spec file from path specFile to /root/rpmbuild/SPECS/
|
// Copy spec file from path specFile to /root/rpmbuild/SPECS/
|
||||||
yield exec.exec(`cp /github/workspace/${specFile} /github/home/rpmbuild/SPECS/`);
|
yield exec.exec(`cp /github/workspace/${specFile} /github/home/rpmbuild/SPECS/`);
|
||||||
// Dowload tar.gz file of source code
|
// Dowload tar.gz file of source code
|
||||||
yield exec.exec(`curl -L --output tmp.tar.gz https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`);
|
yield exec.exec(`curl -L --output tmp.tar.gz https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`);
|
||||||
// create directory to match source file - repo-version
|
// create directory to match source file - name-version
|
||||||
yield exec.exec(`mkdir ${repo}-${version}`);
|
yield exec.exec(`mkdir ${name}-${version}`);
|
||||||
// Extract source code to directory
|
// Extract source code to directory
|
||||||
yield exec.exec(`tar xvf tmp.tar.gz -C ${repo}-${version} --strip-components 1`);
|
yield exec.exec(`tar xvf tmp.tar.gz -C ${name}-${version} --strip-components 1`);
|
||||||
// Create Source tar.gz file
|
// Create Source tar.gz file
|
||||||
yield exec.exec(`tar -czvf ${repo}-${version}.tar.gz ${repo}-${version}`);
|
yield exec.exec(`tar -czvf ${name}-${version}.tar.gz ${name}-${version}`);
|
||||||
// Get repo files from /github/workspace/
|
// Get repo files from /github/workspace/
|
||||||
yield exec.exec('ls -la ');
|
yield exec.exec('ls -la ');
|
||||||
// Copy tar.gz file to source
|
// Copy tar.gz file to source
|
||||||
yield exec.exec(`cp ${repo}-${version}.tar.gz /github/home/rpmbuild/SOURCES/`);
|
yield exec.exec(`cp ${name}-${version}.tar.gz /github/home/rpmbuild/SOURCES/`);
|
||||||
// Execute rpmbuild
|
// Execute rpmbuild
|
||||||
try {
|
try {
|
||||||
yield exec.exec(`rpmbuild -ba /github/home/rpmbuild/SPECS/${specFile}`);
|
yield exec.exec(`rpmbuild -ba /github/home/rpmbuild/SPECS/${specFile}`);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
const { Octokit } = require('@octokit/rest');
|
const { Octokit } = require('@octokit/rest');
|
||||||
const fs = require('fs');
|
//const fs = require('fs');
|
||||||
const tc = require('@actions/tool-cache');
|
const tc = require('@actions/tool-cache');
|
||||||
|
|
||||||
|
|
||||||
|
34
src/main.ts
34
src/main.ts
@ -2,8 +2,8 @@ const core = require('@actions/core');
|
|||||||
const github = require('@actions/github');
|
const github = require('@actions/github');
|
||||||
const exec = require('@actions/exec');
|
const exec = require('@actions/exec');
|
||||||
const io = require('@actions/io');
|
const io = require('@actions/io');
|
||||||
const download_tar = require('./download-release-archive');
|
|
||||||
const cp = require('child_process');
|
const cp = require('child_process');
|
||||||
|
const fs = require('fs');
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
@ -15,11 +15,29 @@ async function run() {
|
|||||||
const repo = context.repo.repo
|
const repo = context.repo.repo
|
||||||
const ref = context.ref
|
const ref = context.ref
|
||||||
|
|
||||||
const version = "1.0.0"
|
|
||||||
|
|
||||||
// get inputs from workflow
|
// get inputs from workflow
|
||||||
|
// specFile name
|
||||||
const specFile = core.getInput('spec_file');
|
const specFile = core.getInput('spec_file');
|
||||||
|
|
||||||
|
// Read spec file and get values
|
||||||
|
var data = fs.readFileSync('cello/cello.spec', 'utf8');
|
||||||
|
|
||||||
|
let name = '';
|
||||||
|
let version = '';
|
||||||
|
|
||||||
|
for (var line of data.split('\n')){
|
||||||
|
var lineArray = line.split(/[ ]+/);
|
||||||
|
if(lineArray[0].includes('Name')){
|
||||||
|
name = name+lineArray[1];
|
||||||
|
}
|
||||||
|
if(lineArray[0].includes('Version')){
|
||||||
|
version = version+lineArray[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`name: ${name}`);
|
||||||
|
console.log(`version: ${version}`);
|
||||||
|
|
||||||
// setup rpm tree
|
// setup rpm tree
|
||||||
await exec.exec('rpmdev-setuptree');
|
await exec.exec('rpmdev-setuptree');
|
||||||
|
|
||||||
@ -29,19 +47,19 @@ async function run() {
|
|||||||
// Dowload tar.gz file of source code
|
// Dowload tar.gz file of source code
|
||||||
await exec.exec(`curl -L --output tmp.tar.gz https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`)
|
await exec.exec(`curl -L --output tmp.tar.gz https://api.github.com/repos/${owner}/${repo}/tarball/${ref}`)
|
||||||
|
|
||||||
// create directory to match source file - repo-version
|
// create directory to match source file - name-version
|
||||||
await exec.exec(`mkdir ${repo}-${version}`);
|
await exec.exec(`mkdir ${name}-${version}`);
|
||||||
|
|
||||||
// Extract source code to directory
|
// Extract source code to directory
|
||||||
await exec.exec(`tar xvf tmp.tar.gz -C ${repo}-${version} --strip-components 1`);
|
await exec.exec(`tar xvf tmp.tar.gz -C ${name}-${version} --strip-components 1`);
|
||||||
|
|
||||||
// Create Source tar.gz file
|
// Create Source tar.gz file
|
||||||
await exec.exec(`tar -czvf ${repo}-${version}.tar.gz ${repo}-${version}`);
|
await exec.exec(`tar -czvf ${name}-${version}.tar.gz ${name}-${version}`);
|
||||||
|
|
||||||
// Get repo files from /github/workspace/
|
// Get repo files from /github/workspace/
|
||||||
await exec.exec('ls -la ');
|
await exec.exec('ls -la ');
|
||||||
// Copy tar.gz file to source
|
// Copy tar.gz file to source
|
||||||
await exec.exec(`cp ${repo}-${version}.tar.gz /github/home/rpmbuild/SOURCES/`);
|
await exec.exec(`cp ${name}-${version}.tar.gz /github/home/rpmbuild/SOURCES/`);
|
||||||
|
|
||||||
// Execute rpmbuild
|
// Execute rpmbuild
|
||||||
try {
|
try {
|
||||||
|
Reference in New Issue
Block a user