Skip to content

Commit

Permalink
Safe get compare links (AstarNetwork#1194)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dinonard authored Mar 2, 2024
1 parent 4ffdf07 commit 4f1b313
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions .github/scripts/generate-release-body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,15 @@ type Commits = Await<ReturnType<Octokit["rest"]["repos"]["compareCommits"]>>["da

function getCompareLink(packageName: string, previousTag: string, newTag: string) {
// Previous
const previousPackage = execSync(
`git show ${previousTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'`
).toString();
let previousPackage: string;
try {
previousPackage = execSync(
`git show ${previousTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'`
).toString();
} catch (error) {
console.error('An error occurred while executing the shell command:', error);
return ""
}

const previousCommitTmp = /#([0-9a-f]*)/g.exec(previousPackage);
if (previousCommitTmp == null) { // regexp didn't match
Expand All @@ -27,9 +33,16 @@ function getCompareLink(packageName: string, previousTag: string, newTag: string
const previousRepo = previousRepoTmp[1];

// New
const newPackage = execSync(
`git show ${newTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'`
).toString();
let newPackage: string;
try {
newPackage = execSync(
`git show ${newTag}:../../Cargo.lock | grep ${packageName}? | head -1 | grep -o '".*"'`
).toString();
} catch (error) {
console.error('An error occurred while executing the shell command:', error);
return ""
}

const newCommitTmp = /#([0-9a-f]*)/g.exec(newPackage)
if (newCommitTmp == null) {
return ""
Expand Down Expand Up @@ -255,7 +268,7 @@ async function main() {
getRuntimeInfo(argv["srtool-report-folder"], runtimeName)
);

const moduleLinks = ["substrate", "polkadot", "cumulus", "frontier"].map((repoName) => ({
const moduleLinks = ["polkadot-sdk", "frontier"].map((repoName) => ({
name: repoName,
link: getCompareLink(repoName, previousTag, newTag),
}));
Expand Down

0 comments on commit 4f1b313

Please sign in to comment.