Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
eunjae-lee committed Feb 3, 2022
1 parent 1160d7b commit 703d47f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 16 deletions.
8 changes: 8 additions & 0 deletions scripts/release/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// eslint-disable-next-line import/no-commonjs
module.exports = {
RELEASED_TAG: 'released',
MAIN_BRANCH: 'main',
OWNER: 'eunjae-lee', // TODO: change this later
REPO: 'api-clients-automation',
LANGS: new Set(['javascript', 'php', 'java']),
};
26 changes: 13 additions & 13 deletions scripts/release/create-release-issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,10 @@ const dotenv = require('dotenv');
const execa = require('execa'); // https://github.com/sindresorhus/execa/tree/v5.1.1
const semver = require('semver');

const RELEASED_TAG = 'released';

const MAIN_BRANCH = 'main';

const OWNER = 'eunjae-lee'; // TODO: change this later
const REPO = 'api-clients-automation';
const { RELEASED_TAG, MAIN_BRANCH, OWNER, REPO, LANGS } = require('./common');

dotenv.config();

const LANG_NAME_ALIAS = {
js: 'javascript',
};

function run(command, errorMessage = undefined) {
let result;
try {
Expand Down Expand Up @@ -89,6 +80,7 @@ run(`git push origin ${MAIN_BRANCH}`);
const header = [`## Summary`].join('\n');

const skippedCommits = [];
const wronglyScopedCommits = [];
const latestCommits = run(`git log --oneline ${RELEASED_TAG}..${MAIN_BRANCH}`)
.split('\n')
.filter(Boolean)
Expand All @@ -105,8 +97,12 @@ const latestCommits = run(`git log --oneline ${RELEASED_TAG}..${MAIN_BRANCH}`)
}
message = message.slice(message.indexOf(':') + 2);
type = matchResult[1];
let lang = matchResult[2];
lang = LANG_NAME_ALIAS[lang] || lang;
const lang = matchResult[2];

if (!LANGS.has(lang)) {
wronglyScopedCommits.push(commit);
return undefined;
}

return {
hash,
Expand All @@ -118,9 +114,13 @@ const latestCommits = run(`git log --oneline ${RELEASED_TAG}..${MAIN_BRANCH}`)
})
.filter(Boolean);

console.warn('Skipping these commits due to lack of language scope:');
console.log('[INFO] Skipping these commits due to lack of language scope:');
console.log(skippedCommits.map((commit) => ` ${commit}`).join('\n'));

console.log('');
console.log('[INFO] Skipping these commits due to wrong scopes:');
console.log(wronglyScopedCommits.map((commit) => ` ${commit}`).join('\n'));

langs.forEach((lang) => {
const commits = latestCommits.filter(
(lastestCommit) => lastestCommit.lang === lang
Expand Down
4 changes: 1 addition & 3 deletions scripts/release/process-release.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ dotenv.config();

const execa = require('execa');

const MAIN_BRANCH = 'main';
const OWNER = 'eunjae-lee'; // TODO: change this later
const REPO = 'api-clients-automation';
const { MAIN_BRANCH, OWNER, REPO } = require('./common');

function run(command) {
const result = execa.commandSync(command);
Expand Down

0 comments on commit 703d47f

Please sign in to comment.