Read release notes from the default branch; changelog (1.4.1)
Notes still only attach to tagged versions, so they can be written ahead of a release or corrected afterwards without tagging a new version. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Generated
+2
-2
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "events-hub-backend",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "events-hub-backend",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"hasInstallScript": true,
|
||||
"dependencies": {
|
||||
"@prisma/adapter-pg": "^7.10.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "events-hub-backend",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"private": true,
|
||||
"description": "Cross Events Hub — API for managing Cross Events installs, licences and heartbeats",
|
||||
"main": "src/index.js",
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
/**
|
||||
* Releases from git (Gitea): every v1.2.3 tag of the Cross Events repo is a release, dated by its
|
||||
* commit, and the notes come from the repo's WHATS-NEW.md as of the newest tag ("## 1.2.3" sections;
|
||||
* "urgent" or "security" in the heading marks an urgent release). Runs every 15 minutes and from
|
||||
* commit, and the notes come from the repo's WHATS-NEW.md on its default branch ("## 1.2.3" sections;
|
||||
* "urgent" or "security" in the heading marks an urgent release). Notes only attach to tagged
|
||||
* versions, so a section written ahead of a release stays hidden until it's tagged, and a note can be
|
||||
* corrected after release without a new version. Runs every 15 minutes and from
|
||||
* "Sync now" on the Releases page, when a repo is set; git is then the only source of releases.
|
||||
*/
|
||||
|
||||
const prisma = require('../config/db');
|
||||
const { compareVersions } = require('./alerts');
|
||||
const { getSettings, setSettings, releaseRepoToken } = require('./settings');
|
||||
const { syncLatestVersion } = require('./releases');
|
||||
|
||||
@@ -111,9 +112,8 @@ async function syncReleases() {
|
||||
const token = await releaseRepoToken();
|
||||
const tags = await fetchTags(repo, token);
|
||||
if (!tags.length) throw new Error('The repository has no version tags (v1.2.3) yet.');
|
||||
const newest = tags.reduce((a, b) => (compareVersions(b.version, a.version) > 0 ? b : a));
|
||||
const path = (settings.release_notes_path || 'WHATS-NEW.md').replace(/^\/+/, '').split('/').map(encodeURIComponent).join('/');
|
||||
const markdown = await get(`${repo.api}/raw/${path}?ref=v${newest.version}`, token, { raw: true });
|
||||
const markdown = await get(`${repo.api}/raw/${path}`, token, { raw: true });
|
||||
const notes = parseNotes(markdown || '');
|
||||
|
||||
const existing = new Map((await prisma.release.findMany()).map(r => [r.version, r]));
|
||||
@@ -138,7 +138,7 @@ async function syncReleases() {
|
||||
const gone = [...existing.values()].filter(r => !tagged.has(r.version)).map(r => r.id);
|
||||
if (gone.length) await prisma.release.deleteMany({ where: { id: { in: gone } } });
|
||||
const latest = await syncLatestVersion();
|
||||
await setSettings({ release_synced_at: new Date().toISOString(), release_sync_error: markdown === null ? `${settings.release_notes_path} was not found at v${newest.version}, so there are no notes.` : '' });
|
||||
await setSettings({ release_synced_at: new Date().toISOString(), release_sync_error: markdown === null ? `${settings.release_notes_path} was not found on the default branch, so there are no notes.` : '' });
|
||||
return { tags: tags.length, added, updated, removed: gone.length, latest };
|
||||
} catch (e) {
|
||||
await setSettings({ release_sync_error: `${new Date().toISOString()} ${e.message}`.slice(0, 500) });
|
||||
|
||||
Reference in New Issue
Block a user