This repository has been archived by the owner on Sep 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
653d65a
commit 9cbbe7a
Showing
5 changed files
with
316 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { defineConfig } from 'changelogithub' | ||
import { execaCommandSync } from 'execa' | ||
import { readPackageSync } from 'read-pkg' | ||
|
||
const { version } = readPackageSync() | ||
|
||
const { stdout: tagsResult } = execaCommandSync( | ||
'git tag --sort=version:refname', | ||
) | ||
|
||
const betaReleaseRegexp = /^v.*-beta\.?\d?/ | ||
const mainReleaseRegexp = /^v.*(?<!-beta\.?\d?)$/ | ||
|
||
const isBetaRelease = betaReleaseRegexp.test(`v${version}`) | ||
const isMainRelease = mainReleaseRegexp.test(`v${version}`) | ||
|
||
// Tags from most recent -> oldest | ||
const tags = tagsResult.split('\n').reverse() | ||
|
||
// prettier-ignore | ||
const from = isMainRelease | ||
? tags.find((tag) => mainReleaseRegexp.test(tag)) | ||
: isBetaRelease | ||
? tags.find((tag) => mainReleaseRegexp.test(tag) || betaReleaseRegexp.test(tag)) | ||
: undefined | ||
|
||
if (!from) { | ||
throw new Error('Unable to find previous release.') | ||
} | ||
|
||
export default defineConfig({ | ||
/** | ||
* When pushing a new main release, the `from` should be the last main release tag (and not a beta version) | ||
* When pushing a new beta release, the `from` should be the last release (beta or main) | ||
*/ | ||
from, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.