Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ if (args.dry_run) {
process.exit(1);
}

// ensure git is on the main branch
// ensure git is on the correct remote and branch
await ensureUpstreamRemote();
await ensureMainBranch();

// run linting and unit tests
Expand Down Expand Up @@ -136,6 +137,30 @@ function parseArguments() {
};
}

async function ensureUpstreamRemote() {
try {
const upstreamRemote = execSync('git config --get remote.upstream.url')
.toString()
.trim();
if (
!(
upstreamRemote.endsWith(':elastic/eui.git') || // : for SSH, / for HTTPS
upstreamRemote.endsWith('/elastic/eui.git')
)
) {
console.error(
'Your `upstream` remote must be pointed to https://github.com/elastic/eui.\nPlease run `git remote -v` to ensure you have an `upstream` remote pointed at the correct repo.\n'
);
process.exit(1);
}
} catch {
console.error(
'No `upstream` remote found.\nPlease run: `git remote add upstream [email protected]:elastic/eui.git`\n'
);
process.exit(1);
}
}

async function ensureMainBranch() {
// ignore main check in CI since it's checking out the HEAD commit instead
if (process.env.CI === 'true') {
Expand Down