build: fix changelog generation

This commit is contained in:
Michael Kriese 2024-11-01 16:10:12 +01:00
parent 00df9b574c
commit 9eae9d2a6e
No known key found for this signature in database
GPG key ID: F8D7748549A5986A
4 changed files with 18 additions and 12 deletions

View file

@ -29,6 +29,8 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
show-progress: false
fetch-depth: 0 # Important for changelog
filter: blob:none # We don't need all blobs
- uses: ./.forgejo/actions/setup
- uses: ./.forgejo/actions/setup-node
@ -38,6 +40,10 @@ jobs:
- run: make readme
- run: git diff --exit-code --name-only README.md
- name: changelog
run: |
pnpm changelog ${{ github.ref_type == 'tag' && 'true' || '' }}
lint-helm:
runs-on: docker
steps:
@ -170,9 +176,6 @@ jobs:
fetch-depth: 0 # Important for changelog
filter: blob:none # We don't need all blobs
# required for proper changelogs
- run: git checkout -b "release/${GITHUB_REF_NAME#v}"
- uses: ./.forgejo/actions/setup
- uses: ./.forgejo/actions/setup-node

View file

@ -1,8 +1,12 @@
import { getChangelog } from './changelog/util.js';
import fs from 'node:fs';
const file = process.argv[3]
? fs.createWriteStream(process.argv[3])
: process.stdout;
const stream = getChangelog(!!process.argv[2]).setEncoding('utf8');
getChangelog(process.argv[2], !!process.argv[2]).pipe(file);
const changes = (await stream.toArray()).join('');
if (!changes.length) {
console.error('No changelog found');
process.exit(1);
}
process.stdout.write(changes);

View file

@ -56,17 +56,16 @@ export const config = conventionalChangelogPreset({
/**
*
* @param {string|undefined} version
* @param {boolean|undefined} onTag
* @returns
*/
export function getChangelog(version = undefined, onTag = false) {
export function getChangelog(onTag = false) {
return conventionalChangelogCore(
{
config,
releaseCount: onTag ? 2 : 1,
},
{ version, linkCompare: false },
undefined,
undefined,
undefined,
{ headerPartial: '' },

View file

@ -68,7 +68,7 @@ class GiteaReleaseCommand extends Command {
return 1;
}
const stream = getChangelog(tag, true).setEncoding('utf8');
const stream = getChangelog(true).setEncoding('utf8');
const changes = (await stream.toArray()).join('');
this.context.stdout.write(`Creating release ${tag}.\n`);