diff --git a/src/changelog.ts b/src/changelog.ts index 94958e7..780ac99 100644 --- a/src/changelog.ts +++ b/src/changelog.ts @@ -5,8 +5,9 @@ import { loadChangelogConfig, } from 'changelogen' -export async function generateChangelog (cwd: string, newVersion: string) { +export async function generateChangelog (cwd: string, from: string, newVersion: string) { const config = await loadChangelogConfig(cwd, { + from, newVersion, }) diff --git a/src/index.ts b/src/index.ts index 81f659b..f9d10ae 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,9 +18,16 @@ async function run() { const releaseName = core.getInput('release_name', { required: false }) || tag - console.log('Tag:', tag, 'Release name:', releaseName) + const releases = await github.repos.listReleases({ + owner, + repo, + per_page: 1, + }) + const previousTag = releases.data[0].tag_name + + console.log(`${previousTag} => ${tag}`) - let body = await generateChangelog(process.cwd(), tag.replace(/^v/, '')) + let body = await generateChangelog(process.cwd(), previousTag, tag.replace(/^v/, '')) let lines = body.split('\n') // Cleanup output