Add Changelog To Release

This commit is contained in:
TheBrokenRail 2025-02-19 11:34:40 -05:00
parent da55fda07a
commit 00414e2250
2 changed files with 49 additions and 3 deletions

View File

@ -114,8 +114,11 @@ jobs:
- example-mods
name: Release
runs-on: ubuntu-latest
container: node:lts-bullseye
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: false
# Dependencies
- name: Install Go
uses: actions/setup-go@v5
@ -126,11 +129,15 @@ jobs:
uses: actions/download-artifact@v3
with:
path: out
# Get Changelog
- name: Get Changelog
id: release-info
run: ./scripts/get-changelog.mjs >> "${GITHUB_OUTPUT}"
# Create Release
- name: Create Release
uses: https://gitea.com/actions/release-action@main
with:
files: ./out/*/*.AppImage*
api_key: ${{ secrets.RELEASE_TOKEN }}
title: v${{ github.ref_name }}
body: '[View Changelog](https://gitea.thebrokenrail.com/minecraft-pi-reborn/minecraft-pi-reborn/src/branch/master/docs/CHANGELOG.md)'
title: v${{ steps.release-info.outputs.version }}
body: ${{ steps.release-info.outputs.changelog }}

39
scripts/get-changelog.mjs Executable file
View File

@ -0,0 +1,39 @@
#!/usr/bin/env node
import * as path from 'node:path';
import * as fs from 'node:fs';
import { getScriptsDir } from './lib/util.mjs';
// Read Files
function readFile(...args) {
const __dirname = getScriptsDir();
const root = path.join(__dirname, '..');
return fs.readFileSync(path.join(root, ...args), 'utf8').trim();
}
const version = readFile('VERSION');
const changelog = readFile('docs', 'CHANGELOG.md');
// Print Version
console.log('version=' + version);
// Parse Changelog
const out = [];
let foundStart = false;
const lines = changelog.split('\n');
for (const line of lines) {
if (!foundStart) {
// Found Start Of Version Info
foundStart = line.includes(`**${version}**`);
} else if (line.trim().length === 0) {
// Found End
break;
} else {
// Found Entry
out.push(line);
}
}
// Print
const delimiter = 'CHANGELOG_EOF';
console.log('changelog<<' + delimiter);
console.log(out.join('\n'));
console.log(delimiter);