Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Skip drafting release notes for versions older than the latest release.
Browse files Browse the repository at this point in the history
RELNOTES: n/a
PiperOrigin-RevId: 569297630
Change-Id: Iaa270fbfd2c6acfb0f2e1f34f2efad58561c497b
  • Loading branch information
12wrigja authored and copybara-github committed Sep 28, 2023
1 parent 66e2c1f commit 68de51e
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/release/create_closure_releases.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* is simply invoked immediately.
*/

import * as semver from 'semver';

import {Change, GitClient} from './git_client';
import {DraftReleaseOptions, GitHubClient} from './github_client';

Expand Down Expand Up @@ -247,6 +249,7 @@ export async function createClosureReleases(gitHubApiToken: string) {
// Get the tag of the latest GitHub release.
const from = await github.getLatestReleaseTag();
const versionAtLastRelease = await getMajorVersionAtCommit(git, from);
const lastReleaseSemver = semver.coerce(versionAtLastRelease);

// Get the list of commits since `from`.
const commits = await git.listCommits({from, to: 'HEAD'});
Expand All @@ -260,6 +263,13 @@ export async function createClosureReleases(gitHubApiToken: string) {
for (const commit of commits) {
const version = await getMajorVersionAtCommit(git, commit.hash);
seenCommits.push(commit);
if (lastReleaseSemver) {
const semverV = semver.coerce(version);
if (semverV && semver.lt(semverV, lastReleaseSemver)) {
// Skip versions that are older than the last version we released.
continue;
}
}
if (!pJsonVersions.some((entry) => entry.version === version)) {
pJsonVersions.push({
version,
Expand Down
65 changes: 65 additions & 0 deletions scripts/release/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions scripts/release/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@
"version": "1.0.0",
"scripts": {
"start": "ts-node create_closure_releases",
"debug": "node --inspect --inspect-brk -r ts-node/register create_closure_releases.ts",
"test": "ts-node $(npm bin)/jasmine *_test.ts"
},
"dependencies": {
"@octokit/rest": "^18.0.6",
"semver": "^7.5.4",
"simple-git": "^3.16.0"
},
"devDependencies": {
"@types/jasmine": "^3.6.0",
"@types/node": "^14.11.2",
"@types/semver": "^7.5.3",
"jasmine": "^3.6.2",
"ts-node": "^10.9.1",
"typescript": "^4.7.4"
Expand Down

0 comments on commit 68de51e

Please sign in to comment.