Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Harden release script to check for correct upstream remote #6528

Merged
merged 1 commit into from
Jan 17, 2023
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