A local-first personal finance app
[AI] Remove AI-generated release notes workflow and support custom filenames (#7963)
Matiss Janis Aboltinsab35bd633b5b
diff --git a/.github/actions/ai-generated-release-notes/check-first-comment.js b/.github/actions/ai-generated-release-notes/check-first-comment.jsdeleted file mode 100755index 36a9023ba3..0000000000--- a/.github/actions/ai-generated-release-notes/check-first-comment.js+++ /dev/null@@ -1,76 +0,0 @@-#!/usr/bin/env node--import fs from 'fs';--import { Octokit } from '@octokit/rest';--const token = process.env.GITHUB_TOKEN;-const repo = process.env.GITHUB_REPOSITORY;-const issueNumber = process.env.GITHUB_EVENT_ISSUE_NUMBER;-const commentId = String(process.env.GITHUB_EVENT_COMMENT_ID);--if (!token || !repo || !issueNumber || !commentId) {- console.log('Missing required environment variables');- process.exit(1);-}--const [owner, repoName] = repo.split('/');-const octokit = new Octokit({ auth: token });--function setOutput(name, value) {- fs.appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${value}\n`);-}--async function checkFirstComment() {- try {- console.log('Fetching comments with Octokit...');-- // Get all comments with automatic pagination- const comments = await octokit.paginate(octokit.rest.issues.listComments, {- owner,- repo: repoName,- issue_number: issueNumber,- });-- console.log(`Total comments found: ${comments.length}`);-- // Filter for CodeRabbit summary comments (containing the specific marker)- const coderabbitSummaryComments = comments.filter(comment => {- const isCodeRabbit = comment.user.login === 'coderabbitai[bot]';- const hasSummaryMarker = comment.body.includes(- '<!-- This is an auto-generated comment: summarize by coderabbit.ai -->',- );-- if (isCodeRabbit) {- console.log(- `CodeRabbit comment found (ID: ${comment.id}), has summary marker: ${hasSummaryMarker}`,- );- }-- return isCodeRabbit && hasSummaryMarker;- });-- const isFirstSummaryComment =- coderabbitSummaryComments.length === 1 &&- String(coderabbitSummaryComments[0].id) === commentId;-- console.log(- `CodeRabbit summary comments found: ${coderabbitSummaryComments.length}`,- );- console.log(`Current comment ID: ${commentId}`);- console.log(`Is first summary comment: ${isFirstSummaryComment}`);- setOutput('result', isFirstSummaryComment);- } catch (error) {- console.log('Error checking CodeRabbit comment:', error.message);- console.log('Stack:', error.stack);- setOutput('result', 'false');- process.exit(1);- }-}--checkFirstComment().catch(error => {- console.log('Unhandled error:', error.message);- console.log('Stack:', error.stack);- setOutput('result', 'false');- process.exit(1);-});diff --git a/.github/actions/ai-generated-release-notes/check-release-notes-exists.js b/.github/actions/ai-generated-release-notes/check-release-notes-exists.jsdeleted file mode 100755index 5c21997748..0000000000--- a/.github/actions/ai-generated-release-notes/check-release-notes-exists.js+++ /dev/null@@ -1,77 +0,0 @@-#!/usr/bin/env node--import fs from 'fs';--import { Octokit } from '@octokit/rest';--const token = process.env.GITHUB_TOKEN;-const repo = process.env.GITHUB_REPOSITORY;-const issueNumber = process.env.GITHUB_EVENT_ISSUE_NUMBER;-const prDetailsJson = process.env.PR_DETAILS;--if (!token || !repo || !issueNumber || !prDetailsJson) {- console.log('Missing required environment variables');- process.exit(1);-}--const [owner, repoName] = repo.split('/');-const octokit = new Octokit({ auth: token });--function setOutput(name, value) {- fs.appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${value}\n`);-}--async function checkReleaseNotesExists() {- try {- const prDetails = JSON.parse(prDetailsJson);- if (!prDetails) {- console.log('No PR details available, skipping file check');- setOutput('result', 'false');- return;- }-- const fileName = `upcoming-release-notes/${prDetails.number}.md`;-- // Get PR info to get head SHA- const { data: pr } = await octokit.rest.pulls.get({- owner,- repo: repoName,- pull_number: issueNumber,- });-- const prHeadSha = pr.head.sha;- console.log(- `Checking for file on PR branch: ${pr.head.ref} (${prHeadSha})`,- );-- // Check if file exists- try {- await octokit.rest.repos.getContent({- owner,- repo: repoName,- path: fileName,- ref: prHeadSha,- });-- console.log(- `Release notes file already exists on PR branch: ${fileName}`,- );- setOutput('result', 'true');- } catch (error) {- if (error.status === 404) {- console.log(- `No existing release notes file found on PR branch: ${fileName}`,- );- setOutput('result', 'false');- } else {- console.log('Error checking file existence:', error.message);- setOutput('result', 'false');- }- }- } catch (error) {- console.log('Error in file existence check:', error.message);- setOutput('result', 'false');- }-}--void checkReleaseNotesExists();diff --git a/.github/actions/ai-generated-release-notes/comment-on-pr.js b/.github/actions/ai-generated-release-notes/comment-on-pr.jsdeleted file mode 100755index 36a5e4f28f..0000000000--- a/.github/actions/ai-generated-release-notes/comment-on-pr.js+++ /dev/null@@ -1,77 +0,0 @@-#!/usr/bin/env node--import { Octokit } from '@octokit/rest';--const token = process.env.GITHUB_TOKEN;-const repo = process.env.GITHUB_REPOSITORY;-const issueNumber = process.env.GITHUB_EVENT_ISSUE_NUMBER;-const summaryDataJson = process.env.SUMMARY_DATA;-const category = process.env.CATEGORY;--if (!token || !repo || !issueNumber || !summaryDataJson || !category) {- console.log('Missing required environment variables');- process.exit(1);-}--const [owner, repoName] = repo.split('/');-const octokit = new Octokit({ auth: token });--async function commentOnPR() {- try {- const summaryData = JSON.parse(summaryDataJson);-- if (!summaryData) {- console.log('No summary data available, skipping comment');- return;- }-- if (!category || category === 'null') {- console.log('No valid category available, skipping comment');- return;- }-- // Clean category for display- const cleanCategory =- typeof category === 'string'- ? category.replace(/^["']|["']$/g, '')- : category;-- // Get PR info for the file URL- const { data: pr } = await octokit.rest.pulls.get({- owner,- repo: repoName,- pull_number: issueNumber,- });-- const prBranch = pr.head.ref;- const headOwner = pr.head.repo.owner.login;- const headRepo = pr.head.repo.name;- const fileUrl = `https://github.com/${headOwner}/${headRepo}/blob/${prBranch}/upcoming-release-notes/${summaryData.prNumber}.md`;-- const commentBody = [- 'π€ **Auto-generated Release Notes**',- '',- `Hey @${summaryData.author}! I've automatically created a release notes file based on CodeRabbit's analysis:`,- '',- `**Category:** ${cleanCategory}`,- `**Summary:** ${summaryData.summary}`,- `**File:** [upcoming-release-notes/${summaryData.prNumber}.md](${fileUrl})`,- '',- // 'The release notes file has been committed to the repository. You can edit it if needed before merging.',- "If you're happy with this release note, you can add it to your pull request. If not, you'll need to add your own before a maintainer can review your change.",- ].join('\n');-- await octokit.rest.issues.createComment({- owner,- repo: repoName,- issue_number: issueNumber,- body: commentBody,- });-- console.log('β Successfully commented on PR');- } catch (error) {- console.log('Error commenting on PR:', error.message);- }-}--void commentOnPR();diff --git a/.github/actions/ai-generated-release-notes/create-release-notes-file.js b/.github/actions/ai-generated-release-notes/create-release-notes-file.jsdeleted file mode 100755index 4da0b7b862..0000000000--- a/.github/actions/ai-generated-release-notes/create-release-notes-file.js+++ /dev/null@@ -1,138 +0,0 @@-#!/usr/bin/env node--import { Octokit } from '@octokit/rest';--const token = process.env.GITHUB_TOKEN;-const repo = process.env.GITHUB_REPOSITORY;-const issueNumber = process.env.GITHUB_EVENT_ISSUE_NUMBER;-const summaryDataJson = process.env.SUMMARY_DATA;-const category = process.env.CATEGORY;--if (!token || !repo || !issueNumber || !summaryDataJson || !category) {- console.log('Missing required environment variables');- process.exit(1);-}--const [owner, repoName] = repo.split('/');-const octokit = new Octokit({ auth: token });--const VALID_CATEGORIES = [- 'Features',- 'Bugfixes',- 'Enhancements',- 'Maintenance',-];-const GITHUB_USERNAME_RE =- /^[a-zA-Z0-9](?:[a-zA-Z0-9]|-(?=[a-zA-Z0-9])){0,38}$/;--async function createReleaseNotesFile() {- try {- const summaryData = JSON.parse(summaryDataJson);-- if (!summaryData) {- console.log('No summary data available, cannot create file');- return;- }-- if (!category || category === 'null') {- console.log('No valid category available, cannot create file');- return;- }-- // Normalize category - strip surrounding quotes and validate against allow-list- const cleanCategory =- typeof category === 'string'- ? category.replace(/^["']|["']$/g, '')- : category;-- if (!VALID_CATEGORIES.includes(cleanCategory)) {- console.log(- `Invalid category "${cleanCategory}". Must be one of: ${VALID_CATEGORIES.join(', ')}`,- );- return;- }-- // Validate author is a plausible GitHub username- const author = String(summaryData.author || '');- if (!GITHUB_USERNAME_RE.test(author)) {- console.log(- `Invalid author "${author}", aborting release notes creation`,- );- return;- }-- // Normalize summary: collapse whitespace to a single line so it cannot- // introduce extra YAML frontmatter or break the markdown structure.- const cleanSummary = String(summaryData.summary || '')- .replace(/\s+/g, ' ')- .trim();- if (!cleanSummary) {- console.log('Empty summary, aborting release notes creation');- return;- }-- // Validate PR number - must be a positive integer. The value comes from- // the GitHub API, but we harden it because it's used to build a file path- // and a commit message.- const validatedPrNumber = Number(summaryData.prNumber);- if (!Number.isInteger(validatedPrNumber) || validatedPrNumber <= 0) {- console.log(- `Invalid PR number "${summaryData.prNumber}", aborting release notes creation`,- );- return;- }-- const fileContent = `----category: ${cleanCategory}-authors: [${author}]------${cleanSummary}-`;-- const fileName = `upcoming-release-notes/${validatedPrNumber}.md`;-- console.log(- `Creating release notes file: ${fileName} (category: ${cleanCategory}, author: ${author})`,- );-- // Get PR info- const { data: pr } = await octokit.rest.pulls.get({- owner,- repo: repoName,- pull_number: issueNumber,- });-- const prBranch = pr.head.ref;- const headOwner = pr.head.repo.owner.login;- const headRepo = pr.head.repo.name;-- console.log(- `Committing to PR branch: ${headOwner}/${headRepo}:${prBranch}`,- );-- // Create the file via GitHub API on the PR branch- await octokit.rest.repos.createOrUpdateFileContents({- owner: headOwner,- repo: headRepo,- path: fileName,- message: `Add release notes for PR #${validatedPrNumber}`,- content: Buffer.from(fileContent).toString('base64'),- branch: prBranch,- committer: {- name: 'github-actions[bot]',- email: 'github-actions[bot]@users.noreply.github.com',- },- author: {- name: 'github-actions[bot]',- email: 'github-actions[bot]@users.noreply.github.com',- },- });-- console.log(`β Successfully created release notes file: ${fileName}`);- } catch (error) {- console.log('Error creating release notes file:', error.message);- }-}--void createReleaseNotesFile();diff --git a/.github/actions/ai-generated-release-notes/determine-category.js b/.github/actions/ai-generated-release-notes/determine-category.jsdeleted file mode 100755index fef54d77c4..0000000000--- a/.github/actions/ai-generated-release-notes/determine-category.js+++ /dev/null@@ -1,118 +0,0 @@-#!/usr/bin/env node--const fs = require('fs');-const https = require('https');--const commentBody = process.env.GITHUB_EVENT_COMMENT_BODY;-const prDetailsJson = process.env.PR_DETAILS;-const summaryDataJson = process.env.SUMMARY_DATA;-const openaiApiKey = process.env.OPENAI_API_KEY;--if (!commentBody || !prDetailsJson || !summaryDataJson || !openaiApiKey) {- console.log('Missing required environment variables');- process.exit(1);-}--function setOutput(name, value) {- fs.appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${value}\n`);-}--try {- const prDetails = JSON.parse(prDetailsJson);- const summaryData = JSON.parse(summaryDataJson);-- if (!summaryData || !prDetails) {- console.log('Missing data for categorization');- setOutput('result', 'null');- process.exit(0);- }-- const data = JSON.stringify({- model: 'gpt-4o-mini',- messages: [- {- role: 'system',- content:- 'You are categorizing pull requests for release notes. You must respond with exactly one of these categories: "Features", "Enhancements", "Bugfixes", or "Maintenance". No other text or explanation.',- },- {- role: 'user',- content: `PR Title: ${prDetails.title}\n\nGenerated Summary: ${summaryData.summary}\n\nCodeRabbit Analysis:\n${commentBody}\n\nCategories:\n- Features: New functionality or capabilities\n- Bugfixes: Fixes for broken or incorrect behavior\n- Enhancements: Improvements to existing functionality\n- Maintenance: Code cleanup, refactoring, dependencies, etc.\n\nWhat category does this PR belong to?`,- },- ],- max_tokens: 10,- temperature: 0.1,- });-- const options = {- hostname: 'api.openai.com',- path: '/v1/chat/completions',- method: 'POST',- headers: {- Authorization: `Bearer ${openaiApiKey}`,- 'Content-Type': 'application/json',- },- };-- const req = https.request(options, res => {- let responseData = '';- res.on('data', chunk => (responseData += chunk));- res.on('end', () => {- if (res.statusCode !== 200) {- console.log('OpenAI API error for categorization');- setOutput('result', 'null');- return;- }-- try {- const response = JSON.parse(responseData);- console.log('OpenAI raw response:', JSON.stringify(response, null, 2));-- const rawContent = response.choices[0].message.content.trim();- console.log('Raw content from OpenAI:', rawContent);-- let category;- try {- category = JSON.parse(rawContent);- console.log('Parsed category:', category);- } catch (parseError) {- console.log(- 'JSON parse error, using raw content:',- parseError.message,- );- category = rawContent;- }-- // Validate the category response- const validCategories = [- 'Features',- 'Bugfixes',- 'Enhancements',- 'Maintenance',- ];- if (validCategories.includes(category)) {- console.log('OpenAI categorized as:', category);- setOutput('result', category);- } else {- console.log('Invalid category from OpenAI:', category);- console.log('Valid categories are:', validCategories);- setOutput('result', 'null');- }- } catch (error) {- console.log('Error parsing OpenAI response:', error.message);- setOutput('result', 'null');- }- });- });-- req.on('error', error => {- console.log('Error in categorization:', error.message);- setOutput('result', 'null');- });-- req.write(data);- req.end();-} catch (error) {- console.log('Error in categorization:', error.message);- setOutput('result', 'null');-}diff --git a/.github/actions/ai-generated-release-notes/generate-summary.js b/.github/actions/ai-generated-release-notes/generate-summary.jsdeleted file mode 100755index bc362fed8e..0000000000--- a/.github/actions/ai-generated-release-notes/generate-summary.js+++ /dev/null@@ -1,95 +0,0 @@-#!/usr/bin/env node--const fs = require('fs');-const https = require('https');--const commentBody = process.env.GITHUB_EVENT_COMMENT_BODY;-const prDetailsJson = process.env.PR_DETAILS;-const openaiApiKey = process.env.OPENAI_API_KEY;--if (!commentBody || !prDetailsJson || !openaiApiKey) {- console.log('Missing required environment variables');- process.exit(1);-}--function setOutput(name, value) {- fs.appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${value}\n`);-}--try {- const prDetails = JSON.parse(prDetailsJson);-- if (!prDetails) {- console.log('No PR details available, cannot generate summary');- setOutput('result', 'null');- process.exit(0);- }-- const data = JSON.stringify({- model: 'gpt-4o-mini',- messages: [- {- role: 'system',- content:- 'You are a technical writer helping to create concise release notes. Generate a maximum 15-word summary that describes what this PR does. Focus on the user-facing changes or bug fixes. Do not include "This PR" or similar phrases - just describe the change directly. Start with a base form verb (e.g., "Add" not "Adds", "Fix" not "Fixes", "Introduce" not "Introduces").',- },- {- role: 'user',- content: `PR Title: ${prDetails.title}\n\nCodeRabbit Analysis:\n${commentBody}\n\nPlease provide a concise summary (max 15 words) of what this PR accomplishes.`,- },- ],- max_tokens: 50,- temperature: 0.3,- });-- const options = {- hostname: 'api.openai.com',- path: '/v1/chat/completions',- method: 'POST',- headers: {- Authorization: `Bearer ${openaiApiKey}`,- 'Content-Type': 'application/json',- },- };-- const req = https.request(options, res => {- let responseData = '';- res.on('data', chunk => (responseData += chunk));- res.on('end', () => {- if (res.statusCode !== 200) {- console.log(`OpenAI API error: ${res.statusCode} ${res.statusMessage}`);- setOutput('result', 'null');- return;- }-- try {- const response = JSON.parse(responseData);- const summary = response.choices[0].message.content.trim();-- console.log('Generated summary:', summary);-- const result = {- summary,- prNumber: prDetails.number,- author: prDetails.author,- };-- setOutput('result', JSON.stringify(result));- } catch (error) {- console.log('Error parsing OpenAI response:', error.message);- setOutput('result', 'null');- }- });- });-- req.on('error', error => {- console.log('Error generating summary:', error.message);- setOutput('result', 'null');- });-- req.write(data);- req.end();-} catch (error) {- console.log('Error generating summary:', error.message);- setOutput('result', 'null');-}diff --git a/.github/actions/ai-generated-release-notes/pr-details.js b/.github/actions/ai-generated-release-notes/pr-details.jsdeleted file mode 100755index 39491c2082..0000000000--- a/.github/actions/ai-generated-release-notes/pr-details.js+++ /dev/null@@ -1,101 +0,0 @@-#!/usr/bin/env node--import fs from 'fs';--import { Octokit } from '@octokit/rest';--const token = process.env.GITHUB_TOKEN;-const repo = process.env.GITHUB_REPOSITORY;-const issueNumber = process.env.GITHUB_EVENT_ISSUE_NUMBER;--if (!token || !repo || !issueNumber) {- console.log('Missing required environment variables');- process.exit(1);-}--const [owner, repoName] = repo.split('/');-const octokit = new Octokit({ auth: token });--function setOutput(name, value) {- fs.appendFileSync(process.env.GITHUB_OUTPUT, `${name}=${value}\n`);-}--async function getPRDetails() {- try {- console.log(- `Fetching PR details for ${owner}/${repoName}#${issueNumber}...`,- );-- const { data: pr } = await octokit.rest.pulls.get({- owner,- repo: repoName,- pull_number: issueNumber,- });-- console.log('PR details fetched successfully');- console.log('- PR Number:', pr.number);- console.log('- PR Author:', pr.user.login);- console.log('- PR Title:', pr.title);- console.log('- Base Branch:', pr.base.ref);- console.log('- Head Branch:', pr.head.ref);-- // Fetch all changed files to detect docs-only PRs- const files = await octokit.paginate(octokit.rest.pulls.listFiles, {- owner,- repo: repoName,- pull_number: issueNumber,- per_page: 100,- });-- const changedFiles = files.map(f => f.filename);- const isDocsOnly =- changedFiles.length > 0 &&- changedFiles.every(file => file.startsWith('packages/docs/'));-- console.log('- Changed Files:', changedFiles.length);- console.log('- Is Docs Only:', isDocsOnly);-- const result = {- number: pr.number,- author: pr.user.login,- title: pr.title,- baseBranch: pr.base.ref,- headBranch: pr.head.ref,- };-- let eligible = true;- if (pr.base.ref !== 'master') {- console.log(- 'PR does not target master branch, skipping release notes generation',- );- eligible = false;- } else if (pr.head.ref.startsWith('release/')) {- console.log(- 'PR head branch is a release branch, skipping release notes generation',- );- eligible = false;- } else if (isDocsOnly) {- console.log(- 'PR only changes documentation, skipping release notes generation',- );- eligible = false;- }-- setOutput('result', JSON.stringify(result));- setOutput('eligible', JSON.stringify(eligible));- } catch (error) {- console.log('Error getting PR details:', error.message);- console.log('Stack:', error.stack);- setOutput('result', 'null');- setOutput('eligible', 'false');- process.exit(1);- }-}--getPRDetails().catch(error => {- console.log('Unhandled error:', error.message);- console.log('Stack:', error.stack);- setOutput('result', 'null');- setOutput('eligible', 'false');- process.exit(1);-});diff --git a/.github/actions/release-notes/check/action.yml b/.github/actions/release-notes/check/action.ymlindex 4bbac41d06..ead5ca983c 100644--- a/.github/actions/release-notes/check/action.yml+++ b/.github/actions/release-notes/check/action.yml@@ -12,6 +12,6 @@ runs:run: yarn workspaces focus @actual-app/ci-actions- name: Check release notesenv:- PR_NUMBER: ${{ github.event.pull_request.number }}+ BASE_REF: ${{ github.event.pull_request.base.ref }}shell: bashrun: node packages/ci-actions/bin/release-notes-check.mjsdiff --git a/.github/workflows/ai-generated-release-notes.yml b/.github/workflows/ai-generated-release-notes.ymldeleted file mode 100644index cc8745f2bc..0000000000--- a/.github/workflows/ai-generated-release-notes.yml+++ /dev/null@@ -1,94 +0,0 @@-name: Generate Release Notes from CodeRabbit summary--on:- issue_comment:- types: [created]--jobs:- generate-release-notes:- # Only run on PR comments from CodeRabbit bot- if: github.event.issue.pull_request && github.event.comment.user.login == 'coderabbitai[bot]'- runs-on: ubuntu-latest- environment: ai-release-notes- timeout-minutes: 10- permissions:- contents: write- pull-requests: write- issues: write-- steps:- - name: Checkout repository- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2- with:- persist-credentials: false- - name: Set up environment- uses: ./.github/actions/setup- with:- download-translations: 'false'-- - name: Check if this is CodeRabbit's first comment- id: check-first-comment- run: node .github/actions/ai-generated-release-notes/check-first-comment.js- env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- GITHUB_REPOSITORY: ${{ github.repository }}- GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}- GITHUB_EVENT_COMMENT_ID: ${{ github.event.comment.id }}-- - name: Get PR details- if: steps.check-first-comment.outputs.result == 'true'- id: pr-details- run: node .github/actions/ai-generated-release-notes/pr-details.js- env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- GITHUB_REPOSITORY: ${{ github.repository }}- GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}-- - name: Check if release notes file already exists- if: steps.pr-details.outputs.eligible == 'true'- id: check-release-notes-exists- run: node .github/actions/ai-generated-release-notes/check-release-notes-exists.js- env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- GITHUB_REPOSITORY: ${{ github.repository }}- GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}- PR_DETAILS: ${{ steps.pr-details.outputs.result }}-- - name: Generate summary with OpenAI- if: steps.check-release-notes-exists.outputs.result == 'false'- id: generate-summary- run: node .github/actions/ai-generated-release-notes/generate-summary.js- env:- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}- GITHUB_EVENT_COMMENT_BODY: ${{ github.event.comment.body }}- PR_DETAILS: ${{ steps.pr-details.outputs.result }}-- - name: Determine category with OpenAI- if: steps.generate-summary.outputs.result != 'null' && steps.generate-summary.outputs.result != ''- id: determine-category- run: node .github/actions/ai-generated-release-notes/determine-category.js- env:- OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}- GITHUB_EVENT_COMMENT_BODY: ${{ github.event.comment.body }}- PR_DETAILS: ${{ steps.pr-details.outputs.result }}- SUMMARY_DATA: ${{ steps.generate-summary.outputs.result }}-- - name: Create and commit release notes file via GitHub API- if: steps.determine-category.outputs.result != 'null' && steps.determine-category.outputs.result != ''- run: node .github/actions/ai-generated-release-notes/create-release-notes-file.js- env:- GITHUB_TOKEN: ${{ secrets.ACTIONS_UPDATE_TOKEN }}- GITHUB_REPOSITORY: ${{ github.repository }}- GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}- SUMMARY_DATA: ${{ steps.generate-summary.outputs.result }}- CATEGORY: ${{ steps.determine-category.outputs.result }}-- - name: Comment on PR- if: steps.determine-category.outputs.result != 'null' && steps.determine-category.outputs.result != ''- run: node .github/actions/ai-generated-release-notes/comment-on-pr.js- env:- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}- GITHUB_REPOSITORY: ${{ github.repository }}- GITHUB_EVENT_ISSUE_NUMBER: ${{ github.event.issue.number }}- SUMMARY_DATA: ${{ steps.generate-summary.outputs.result }}- CATEGORY: ${{ steps.determine-category.outputs.result }}diff --git a/bin/release-note-generator.ts b/bin/release-note-generator.tsindex 931e71c124..6c00073717 100644--- a/bin/release-note-generator.ts+++ b/bin/release-note-generator.ts@@ -15,7 +15,9 @@ async function run() {`Found potentially matching PR ${activePr.number}: ${activePr.title}`,);}- const initialPrNumber = activePr?.number ?? (await getNextPrNumber());++ const branchName = await execAsync('git rev-parse --abbrev-ref HEAD');+ const initialSlug = slugify(activePr?.title ?? branchName ?? '');const result = await prompts([{@@ -25,10 +27,14 @@ async function run() {initial: username,},{- name: 'pullRequestNumber',- message: 'PR Number',- type: 'number',- initial: initialPrNumber,+ name: 'filenameSlug',+ message: 'Filename slug (used as upcoming-release-notes/<slug>.md)',+ type: 'text',+ initial: initialSlug,+ validate: value =>+ /^[a-z0-9]+(-[a-z0-9]+)*$/.test(value)+ ? true+ : 'Use lowercase letters, digits, and single dashes between words',},{name: 'releaseNoteType',@@ -53,7 +59,7 @@ async function run() {!result.githubUsername ||!result.oneLineSummary ||!result.releaseNoteType ||- !result.pullRequestNumber+ !result.filenameSlug) {console.log('All questions must be answered. Exiting');exit(1);@@ -64,9 +70,8 @@ async function run() {result.githubUsername,result.oneLineSummary,);- const prNumber = result.pullRequestNumber;- const filepath = `./upcoming-release-notes/${prNumber}.md`;+ const filepath = `./upcoming-release-notes/${result.filenameSlug}.md`;if (existsSync(filepath)) {const { confirm } = await prompts({name: 'confirm',@@ -89,6 +94,15 @@ async function run() {});}+function slugify(input: string): string {+ const slug = input+ .toLowerCase()+ .replace(/[^a-z0-9]+/g, '-')+ .replace(/^-+|-+$/g, '')+ .slice(0, 80);+ return slug || 'untitled';+}+// makes an attempt to find an existing open PR from <username>:<branch>async function getActivePr(username: string,@@ -130,30 +144,6 @@ async function getPrNumberFromHead(}}-async function getNextPrNumber(): Promise<number> {- try {- const resp = await fetch(- 'https://api.github.com/repos/actualbudget/actual/issues?state=all&per_page=1',- );- if (!resp.ok) {- throw new Error(`API responded with status: ${resp.status}`);- }- const ghResponse = await resp.json();- const latestPrNumber = ghResponse?.[0]?.number;- if (!latestPrNumber) {- console.error(- 'Could not find latest issue number in GitHub API response',- ghResponse,- );- exit(1);- }- return latestPrNumber + 1;- } catch (error) {- console.error('Failed to fetch next PR number:', error);- exit(1);- }-}-function getFileContents(type: string, username: string, summary: string) {return `---category: ${type}diff --git a/packages/ci-actions/bin/release-notes-check.mjs b/packages/ci-actions/bin/release-notes-check.mjsindex cb600b5c85..3a02bd6d07 100644--- a/packages/ci-actions/bin/release-notes-check.mjs+++ b/packages/ci-actions/bin/release-notes-check.mjs@@ -1,4 +1,6 @@+import * as childProcess from 'node:child_process';import * as fs from 'node:fs';+import { promisify } from 'node:util';import matter from 'gray-matter';@@ -7,62 +9,98 @@ import {categoryOrder,} from '../src/release-notes/util.mjs';-console.log('Looking in ' + fs.realpathSync('upcoming-release-notes'));+const execFile = promisify(childProcess.execFile);-const expectedPath = `upcoming-release-notes/${process.env.PR_NUMBER}.md`;+const NOTES_DIR = 'upcoming-release-notes';++console.log('Looking in ' + fs.realpathSync(NOTES_DIR));++const baseRef = process.env.BASE_REF;+if (!baseRef) {+ console.log('::error::BASE_REF env var is not set');+ process.exit(1);+}function reportError(message) {console.log(`::error::${message}`);process.stdout.write('::notice::');- fs.createReadStream('upcoming-release-notes/README.md').pipe(process.stdout);+ fs.createReadStream(`${NOTES_DIR}/README.md`).pipe(process.stdout);- fs.createReadStream('upcoming-release-notes/README.md')+ fs.createReadStream(`${NOTES_DIR}/README.md`).pipe(fs.createWriteStream(process.env.GITHUB_STEP_SUMMARY)).on('close', () => {process.exit(1);});}-(() => {- if (!fs.existsSync(expectedPath)) {- reportError(`Release note file ${expectedPath} not found`);- return;- }-- const { data, content } = matter(fs.readFileSync(expectedPath, 'utf-8'));+function validateFile(path) {+ const { data, content } = matter(fs.readFileSync(path, 'utf-8'));if (!data.category) {- reportError(`Release note is missing a category.`);- return;+ reportError(`Release note ${path} is missing a category.`);+ return false;}- if (categoryAutocorrections[data.category]) {- data.category = categoryAutocorrections[data.category];- }- if (!categoryOrder.includes(data.category)) {+ const category = categoryAutocorrections[data.category] ?? data.category;+ if (!categoryOrder.includes(category)) {reportError(- `Release note category "${data.category}" is not one of ${categoryOrder+ `Release note ${path} category "${data.category}" is not one of ${categoryOrder.map(JSON.stringify).join(', ')}`,);- return;+ return false;}if (!data.authors) {- reportError(`Release note is missing authors.`);- return;+ reportError(`Release note ${path} is missing authors.`);+ return false;}if (!Array.isArray(data.authors)) {- reportError(`Release note authors should be a list.`);- return;+ reportError(`Release note ${path} authors should be a list.`);+ return false;}- if (content.trim().split('\n').length !== 1) {+ const trimmedContent = content.trim();+ if (!trimmedContent || trimmedContent.includes('\n')) {+ reportError(`Release note ${path} body should contain exactly one line`);+ return false;+ }++ return true;+}++void (async () => {+ await execFile('git', ['fetch', 'origin', baseRef]);+ const { stdout } = await execFile('git', [+ 'diff',+ '--name-only',+ '--diff-filter=A',+ `origin/${baseRef}...HEAD`,+ '--',+ `${NOTES_DIR}/`,+ ]);+ const added = stdout+ .split('\n')+ .map(s => s.trim())+ .filter(Boolean)+ .filter(p => p.endsWith('.md') && p !== `${NOTES_DIR}/README.md`);++ if (added.length === 0) {reportError(- `Release note file ${expectedPath} body should contain exactly one line`,+ `No release note added under ${NOTES_DIR}/. Add a *.md file describing your change.`,);return;}- console.log('Everything looks good! \u{1f389}');+ for (const path of added) {+ if (!fs.existsSync(path)) {+ reportError(`Release note ${path} was added but does not exist on HEAD.`);+ return;+ }+ if (!validateFile(path)) {+ return;+ }+ }++ console.log(`Validated ${added.length} release note(s). \u{1f389}`);})();diff --git a/packages/ci-actions/bin/release-notes-generate.mjs b/packages/ci-actions/bin/release-notes-generate.mjsindex 25cbd91a65..87edccac57 100644--- a/packages/ci-actions/bin/release-notes-generate.mjs+++ b/packages/ci-actions/bin/release-notes-generate.mjs@@ -7,6 +7,9 @@ import { formatNotes, parseReleaseNotes } from '../src/release-notes/util.mjs';const exec = promisify(childProcess.exec);+if (!process.env.GITHUB_REPOSITORY) {+ throw new Error('GITHUB_REPOSITORY env var is not set');+}const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');const releaseBranch = process.env.RELEASE_BRANCH;@@ -128,6 +131,7 @@ await group('Prepare branch', async () => {const { notesByCategory, files } = await parseReleaseNotes('upcoming-release-notes',+ owner,repo,);const categorizedNotes = formatNotes(notesByCategory);diff --git a/packages/ci-actions/src/release-notes/util.mjs b/packages/ci-actions/src/release-notes/util.mjsindex 5ccd13bb16..2970395b86 100644--- a/packages/ci-actions/src/release-notes/util.mjs+++ b/packages/ci-actions/src/release-notes/util.mjs@@ -1,9 +1,13 @@+import * as childProcess from 'node:child_process';import * as fs from 'node:fs/promises';import { join } from 'node:path';+import { promisify } from 'node:util';import matter from 'gray-matter';import listify from 'listify';+const execFile = promisify(childProcess.execFile);+export const categoryAutocorrections = {Feature: 'Features',Enhancement: 'Enhancements',@@ -17,19 +21,24 @@ export const categoryOrder = ['Maintenance',];-export async function parseReleaseNotes(dir, repo) {- const files = (await fs.readdir(dir)).filter(f => f.match(/^\d+\.md$/));+export async function parseReleaseNotes(dir, owner, repo) {+ const files = (await fs.readdir(dir)).filter(+ f => f.endsWith('.md') && f !== 'README.md',+ );const notes = files.map(async name => {const content = await fs.readFile(join(dir, name), 'utf-8');const { data, content: body } = matter(content);- const number = name.replace('.md', '');const authors = listify(data.authors.map(a => `@${a}`),{ finalWord: '&' },);+ const number = await resolvePrNumber(dir, name);+ const prefix = number+ ? `[#${number}](https://github.com/${owner}/${repo}/pull/${number}) `+ : '';return {category: categoryAutocorrections[data.category] ?? data.category,- value: `- [#${number}](https://github.com/actualbudget/${repo}/pull/${number}) ${body.trim()} β thanks ${authors}`,+ value: `- ${prefix}${body.trim()} β thanks ${authors}`,};});@@ -48,6 +57,42 @@ export async function parseReleaseNotes(dir, repo) {return { notesByCategory, files };}+async function resolvePrNumber(dir, name) {+ const basename = name.replace(/\.md$/, '');+ if (/^\d+$/.test(basename)) {+ return basename;+ }++ let subject;+ try {+ const { stdout } = await execFile('git', [+ 'log',+ '-1',+ '--diff-filter=A',+ '--format=%s',+ '--',+ join(dir, name),+ ]);+ subject = stdout.trim();+ } catch (e) {+ console.log(+ `WARNING: failed to read commit subject for ${name}: ${e.message}`,+ );+ return null;+ }++ // GitHub's squash-merge UI appends "(#NNNN)" to every commit subject,+ // so we can recover the PR number without touching the network.+ const match = subject.match(/\(#(\d+)\)\s*$/);+ if (!match) {+ console.log(+ `WARNING: no "(#N)" suffix in commit subject for ${name}; skipping PR link`,+ );+ return null;+ }+ return match[1];+}+export function formatNotes(notes) {return Object.entries(notes).filter(([_, values]) => values.length > 0)diff --git a/packages/docs/docs/contributing/index.md b/packages/docs/docs/contributing/index.mdindex 5f4c1e6024..30bd8eb086 100644--- a/packages/docs/docs/contributing/index.md+++ b/packages/docs/docs/contributing/index.md@@ -110,13 +110,13 @@ When you open a PR please remember to do the following:Before creating your pull request, run the command `yarn generate:release-notes`. This will guide you through the steps necessary for creating a release note for your change. You will be asked the following questions:1. Comma-separated GitHub username(s) - your GitHub username, or if multiple people are involved, you can specify them all (e.g. `username1, username2`)-2. PR Number - Auto-filled with the next available PR number. If you've already created a PR, then fill this in with that PR number.+2. Filename slug - a short descriptive slug used as `upcoming-release-notes/<slug>.md`. Auto-filled from your branch name (or PR title if one is detected).3. Release Note Type - this will give you a select field with 4 options from the "Valid categories" section below4. Brief Summary - this is a short summary of your changes.For a better experience with the release note generation script, consider installing [the official GitHub CLI](https://github.com/cli/cli) and running `gh auth login`. This will allow the script to automatically fill in some information like your GitHub username and current PR information if you've already opened one from a fork you created.-Create a Markdown file in the upcoming-release-notes directory of the repository you're contributing to named after the PR number. The file should contain front matter with a category key (defining which header to put the entry under) and an authors key (defining the author of the entry). The body of the file should contain the changelog entry. Keep it short and clear β ideally one sentence, and also non-technical (unless the category is "Maintenance"). Copy-paste the template below to get started!+Create a Markdown file in the upcoming-release-notes directory of the repository you're contributing to. Pick a short, descriptive filename (e.g. `add-payee-autocomplete.md`); the PR link in the published changelog is resolved automatically when the release is generated, so you don't need to know the PR number. Numeric filenames like `1234.md` also remain valid. The file should contain front matter with a category key (defining which header to put the entry under) and an authors key (defining the author of the entry). The body of the file should contain the changelog entry. Keep it short and clear β ideally one sentence, and also non-technical (unless the category is "Maintenance"). Copy-paste the template below to get started!```markdown---diff --git a/packages/docs/scripts/generate-upcoming-release-notes.mjs b/packages/docs/scripts/generate-upcoming-release-notes.mjsindex b6c3550c12..7818fcb268 100644--- a/packages/docs/scripts/generate-upcoming-release-notes.mjs+++ b/packages/docs/scripts/generate-upcoming-release-notes.mjs@@ -44,7 +44,11 @@ sidebar_label: Upcoming Release${intro}`;-const { notesByCategory, files } = await parseReleaseNotes(notesDir, 'actual');+const { notesByCategory, files } = await parseReleaseNotes(+ notesDir,+ 'actualbudget',+ 'actual',+);const body =files.length === 0diff --git a/upcoming-release-notes/relax-release-notes-filenames.md b/upcoming-release-notes/relax-release-notes-filenames.mdnew file mode 100644index 0000000000..85f9455633--- /dev/null+++ b/upcoming-release-notes/relax-release-notes-filenames.md@@ -0,0 +1,6 @@+---+category: Maintenance+authors: [MatissJanis]+---++Allow descriptive filenames for release notes (no longer required to be named after the PR number).