Skip to content

Commit

Permalink
Merge pull request #1 from RosemanLabs/esteban-test-release
Browse files Browse the repository at this point in the history
Change to add `release` branches (and any other branch with a `/`)
  • Loading branch information
estebanlanderreche-rl authored Jul 10, 2024
2 parents 6848b3b + 2552718 commit a9f6549
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async function downloadSplitsh(): Promise<void> {
async function promiseAllInBatches(subtreeSplits: subtreeSplit[], batchSize: number, handler: any): Promise<void> {
let position = 0;
while (position < subtreeSplits.length) {
core.info('Processing batch ' + (position / batchSize + 1) + '/'+(Math.round(subtreeSplits.length / batchSize)));
core.info('Processing batch ' + (position / batchSize + 1) + '/' + (Math.round(subtreeSplits.length / batchSize)));

const itemsForBatch = subtreeSplits.slice(position, position + batchSize);

Expand Down Expand Up @@ -83,16 +83,18 @@ async function promiseAllInBatches(subtreeSplits: subtreeSplit[], batchSize: num
await ensureRemoteExists(split.name, split.target);
}

if (context.eventName === 'push' ) {
if (context.eventName === 'push') {
if (!context.ref.includes('refs/heads')) {
core.info('Push event was for a tag, skipping...');

return;
}

const branch = context.ref.split('/').pop();
if (typeof branch == 'undefined') {
core.error('Unable to get branch name from event data. Got ref "'+context.ref+'"');
let branch = '';
if (context.ref.startsWith("origin/heads")) {
branch = context.ref.split('/').slice(2).join("/")
}
else {
core.error('Unable to get branch name from event data. Got ref "' + context.ref + '"');

return;
}
Expand All @@ -116,14 +118,14 @@ async function promiseAllInBatches(subtreeSplits: subtreeSplit[], batchSize: num
let hash = await getExecOutput(splitshPath, [`--prefix=${split.directory}`, `--origin=tags/${tag}`]);
let clonePath = `./.repositories/${split.name}/`;

fs.mkdirSync(clonePath, { recursive: true});
fs.mkdirSync(clonePath, { recursive: true });

await exec('git', ['clone', split.target, '.'], { cwd: clonePath});
await exec('git', ['clone', split.target, '.'], { cwd: clonePath });

// TODO: smart tag skipping (skip patch releases where commit was previously tagged) minor and major releases should always get a tag

if (!await tagExists(tag, clonePath)) {
await exec('git', ['tag', '-a', tag, hash, '-m', `"Tag ${tag}"`], {cwd: clonePath});
await exec('git', ['tag', '-a', tag, hash, '-m', `"Tag ${tag}"`], { cwd: clonePath });
}
await exec('git', ['push', '--tags'], { cwd: clonePath });
});
Expand All @@ -140,12 +142,12 @@ async function promiseAllInBatches(subtreeSplits: subtreeSplit[], batchSize: num

await promiseAllInBatches(subtreeSplits, batchSize, async (split: subtreeSplit) => {
let clonePath = `./.repositories/${split.name}/`;
fs.mkdirSync(clonePath, { recursive: true});
fs.mkdirSync(clonePath, { recursive: true });

await exec('git', ['clone', split.target, '.'], { cwd: clonePath});
await exec('git', ['clone', split.target, '.'], { cwd: clonePath });

if (await tagExists(tag, clonePath)) {
await exec('git', ['push', '--delete', 'origin', tag], { cwd: clonePath});
await exec('git', ['push', '--delete', 'origin', tag], { cwd: clonePath });
}
});
}
Expand Down

0 comments on commit a9f6549

Please sign in to comment.