mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-12-02 21:08:10 +01:00
Compare commits
21
Commits
No files matched your search
Generated
-354
@@ -1,354 +0,0 @@
|
||||
name: Archive Old Changelog Entries
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# Run every Sunday at 00:00 UTC
|
||||
- cron: '0 0 * * 0'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
archive-changelog:
|
||||
if: github.repository == 'community-scripts/ProxmoxVE'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
BRANCH_NAME: github-action-archive-changelog
|
||||
AUTOMATED_PR_LABEL: "automated pr"
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Generate a token
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@v3
|
||||
with:
|
||||
app-id: ${{ vars.GHAPP_PR_ID }}
|
||||
private-key: ${{ secrets.GHAPP_PR_PRIVATE_KEY }}
|
||||
|
||||
- name: Generate a token for PR approval and merge
|
||||
id: generate-token-merge
|
||||
uses: actions/create-github-app-token@v3
|
||||
with:
|
||||
app-id: ${{ vars.GHAPP_MERGEBOT_ID }}
|
||||
private-key: ${{ secrets.GHAPP_MERGEBOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Archive old changelog entries
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
|
||||
const KEEP_DAYS = 30;
|
||||
const ARCHIVE_PATH = '.github/changelogs';
|
||||
const CHANGELOG_PATH = 'CHANGELOG.md';
|
||||
|
||||
// Calculate cutoff date
|
||||
const cutoffDate = new Date();
|
||||
cutoffDate.setDate(cutoffDate.getDate() - KEEP_DAYS);
|
||||
cutoffDate.setHours(0, 0, 0, 0);
|
||||
|
||||
console.log(`Cutoff date: ${cutoffDate.toISOString().split('T')[0]}`);
|
||||
|
||||
// Read changelog and normalize line endings
|
||||
let content = await fs.readFile(CHANGELOG_PATH, 'utf-8');
|
||||
content = content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||
const lines = content.split('\n');
|
||||
|
||||
// Parse entries
|
||||
const datePattern = /^## (\d{4})-(\d{2})-(\d{2})$/;
|
||||
let header = [];
|
||||
let recentEntries = [];
|
||||
let archiveData = {};
|
||||
let currentDate = null;
|
||||
let currentContent = [];
|
||||
let inHeader = true;
|
||||
let inOldHistory = false;
|
||||
let historyDetailsDepth = 0;
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
const match = line.match(datePattern);
|
||||
|
||||
// Detect the start of History section: <details> followed by line with 📜 History
|
||||
if (inHeader && !inOldHistory && line.trim() === '<details>') {
|
||||
// Look ahead to see if this is the History section
|
||||
const nextLine = lines[i + 1] || '';
|
||||
if (nextLine.includes('📜 History')) {
|
||||
inOldHistory = true;
|
||||
historyDetailsDepth = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Track nested details tags to find the end of History section
|
||||
if (inOldHistory) {
|
||||
if (line.trim() === '<details>') {
|
||||
historyDetailsDepth++;
|
||||
}
|
||||
if (line.trim() === '</details>') {
|
||||
historyDetailsDepth--;
|
||||
if (historyDetailsDepth === 0) {
|
||||
// We've closed the main History details tag
|
||||
inOldHistory = false;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inHeader = false;
|
||||
|
||||
// Save previous entry
|
||||
if (currentDate && currentContent.length > 0) {
|
||||
const entryText = currentContent.join('\n').trim();
|
||||
const dateObj = new Date(`${currentDate}T00:00:00Z`);
|
||||
|
||||
// Always add to archive (by month)
|
||||
const year = currentDate.substring(0, 4);
|
||||
const month = currentDate.substring(5, 7);
|
||||
|
||||
if (!archiveData[year]) archiveData[year] = {};
|
||||
if (!archiveData[year][month]) archiveData[year][month] = [];
|
||||
|
||||
archiveData[year][month].push(`## ${currentDate}\n\n${entryText}`);
|
||||
|
||||
// Also add to recent entries if within cutoff
|
||||
if (dateObj >= cutoffDate) {
|
||||
recentEntries.push(`## ${currentDate}\n\n${entryText}`);
|
||||
}
|
||||
}
|
||||
|
||||
currentDate = `${match[1]}-${match[2]}-${match[3]}`;
|
||||
currentContent = [];
|
||||
} else if (inHeader) {
|
||||
header.push(line);
|
||||
} else if (currentDate) {
|
||||
currentContent.push(line);
|
||||
}
|
||||
}
|
||||
|
||||
// Don't forget the last entry
|
||||
if (currentDate && currentContent.length > 0) {
|
||||
const entryText = currentContent.join('\n').trim();
|
||||
const dateObj = new Date(`${currentDate}T00:00:00Z`);
|
||||
|
||||
// Always add to archive (by month)
|
||||
const year = currentDate.substring(0, 4);
|
||||
const month = currentDate.substring(5, 7);
|
||||
|
||||
if (!archiveData[year]) archiveData[year] = {};
|
||||
if (!archiveData[year][month]) archiveData[year][month] = [];
|
||||
|
||||
archiveData[year][month].push(`## ${currentDate}\n\n${entryText}`);
|
||||
|
||||
// Also add to recent entries if within cutoff
|
||||
if (dateObj >= cutoffDate) {
|
||||
recentEntries.push(`## ${currentDate}\n\n${entryText}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Recent entries: ${recentEntries.length}`);
|
||||
console.log(`Years to archive: ${Object.keys(archiveData).length}`);
|
||||
|
||||
// Month names in English
|
||||
const monthNames = {
|
||||
'01': 'January', '02': 'February', '03': 'March', '04': 'April',
|
||||
'05': 'May', '06': 'June', '07': 'July', '08': 'August',
|
||||
'09': 'September', '10': 'October', '11': 'November', '12': 'December'
|
||||
};
|
||||
|
||||
// Create/update archive files
|
||||
for (const year of Object.keys(archiveData).sort().reverse()) {
|
||||
const yearPath = path.join(ARCHIVE_PATH, year);
|
||||
|
||||
try {
|
||||
await fs.mkdir(yearPath, { recursive: true });
|
||||
} catch (e) {
|
||||
// Directory exists
|
||||
}
|
||||
|
||||
for (const month of Object.keys(archiveData[year]).sort().reverse()) {
|
||||
const monthPath = path.join(yearPath, `${month}.md`);
|
||||
|
||||
// Read existing content if exists
|
||||
let existingContent = '';
|
||||
try {
|
||||
existingContent = await fs.readFile(monthPath, 'utf-8');
|
||||
// Normalize line endings to prevent regex issues
|
||||
existingContent = existingContent.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||
} catch (e) {
|
||||
// File doesn't exist
|
||||
}
|
||||
|
||||
// Parse existing entries into a Map (date -> content) for deduplication
|
||||
const allEntries = new Map();
|
||||
|
||||
// Helper function to parse entries from content
|
||||
const parseEntries = (content) => {
|
||||
const entries = new Map();
|
||||
const parts = content.split(/(?=^## \d{4}-\d{2}-\d{2}$)/m);
|
||||
for (const part of parts) {
|
||||
const trimmed = part.trim();
|
||||
if (!trimmed) continue;
|
||||
const dateMatch = trimmed.match(/^## (\d{4}-\d{2}-\d{2})/);
|
||||
if (dateMatch) {
|
||||
entries.set(dateMatch[1], trimmed);
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
};
|
||||
|
||||
// Parse existing content
|
||||
if (existingContent) {
|
||||
const existingEntries = parseEntries(existingContent);
|
||||
for (const [date, content] of existingEntries) {
|
||||
allEntries.set(date, content);
|
||||
}
|
||||
}
|
||||
|
||||
// Add new entries (existing entries take precedence to avoid overwriting)
|
||||
let addedCount = 0;
|
||||
for (const entry of archiveData[year][month]) {
|
||||
const dateMatch = entry.match(/^## (\d{4}-\d{2}-\d{2})/);
|
||||
if (dateMatch && !allEntries.has(dateMatch[1])) {
|
||||
allEntries.set(dateMatch[1], entry.trim());
|
||||
addedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort entries by date (newest first) and write
|
||||
const sortedDates = [...allEntries.keys()].sort().reverse();
|
||||
const sortedContent = sortedDates.map(date => allEntries.get(date)).join('\n\n');
|
||||
|
||||
if (addedCount > 0 || !existingContent) {
|
||||
await fs.writeFile(monthPath, sortedContent + '\n', 'utf-8');
|
||||
console.log(`Updated: ${monthPath} (${allEntries.size} total entries, +${addedCount} new)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build history section
|
||||
let historySection = [];
|
||||
historySection.push('');
|
||||
historySection.push('<details>');
|
||||
historySection.push('<summary><h2>📜 History</h2></summary>');
|
||||
historySection.push('');
|
||||
|
||||
// Get all years from archive directory
|
||||
let allYears = [];
|
||||
try {
|
||||
const archiveDir = await fs.readdir(ARCHIVE_PATH);
|
||||
allYears = archiveDir.filter(f => /^\d{4}$/.test(f)).sort().reverse();
|
||||
} catch (e) {
|
||||
allYears = Object.keys(archiveData).sort().reverse();
|
||||
}
|
||||
|
||||
for (const year of allYears) {
|
||||
historySection.push('');
|
||||
historySection.push('<details>');
|
||||
historySection.push(`<summary><h3>${year}</h3></summary>`);
|
||||
historySection.push('');
|
||||
|
||||
// Get months for this year
|
||||
let months = [];
|
||||
try {
|
||||
const yearDir = await fs.readdir(path.join(ARCHIVE_PATH, year));
|
||||
months = yearDir
|
||||
.filter(f => f.endsWith('.md'))
|
||||
.map(f => f.replace('.md', ''))
|
||||
.sort()
|
||||
.reverse();
|
||||
} catch (e) {
|
||||
months = Object.keys(archiveData[year] || {}).sort().reverse();
|
||||
}
|
||||
|
||||
for (const month of months) {
|
||||
const monthName = monthNames[month] || month;
|
||||
const monthPath = path.join(ARCHIVE_PATH, year, `${month}.md`);
|
||||
|
||||
// Count entries in month file
|
||||
let entryCount = 0;
|
||||
try {
|
||||
let monthContent = await fs.readFile(monthPath, 'utf-8');
|
||||
monthContent = monthContent.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||
entryCount = (monthContent.match(/^## \d{4}-\d{2}-\d{2}$/gm) || []).length;
|
||||
} catch (e) {
|
||||
entryCount = (archiveData[year]?.[month] || []).length;
|
||||
}
|
||||
|
||||
const relativePath = `.github/changelogs/${year}/${month}.md`;
|
||||
historySection.push('');
|
||||
historySection.push('<details>');
|
||||
historySection.push(`<summary><h4>${monthName} (${entryCount} entries)</h4></summary>`);
|
||||
historySection.push('');
|
||||
historySection.push(`[View ${monthName} ${year} Changelog](${relativePath})`);
|
||||
historySection.push('');
|
||||
historySection.push('</details>');
|
||||
}
|
||||
|
||||
historySection.push('');
|
||||
historySection.push('</details>');
|
||||
}
|
||||
|
||||
historySection.push('');
|
||||
historySection.push('</details>');
|
||||
|
||||
// Build new CHANGELOG.md (History first, then recent entries)
|
||||
const newChangelog = [
|
||||
...header,
|
||||
'',
|
||||
historySection.join('\n'),
|
||||
'',
|
||||
recentEntries.join('\n\n')
|
||||
].join('\n');
|
||||
|
||||
await fs.writeFile(CHANGELOG_PATH, newChangelog, 'utf-8');
|
||||
console.log('CHANGELOG.md updated successfully');
|
||||
|
||||
- name: Check for changes
|
||||
id: verify-diff
|
||||
run: |
|
||||
git diff --quiet . || echo "changed=true" >> $GITHUB_ENV
|
||||
|
||||
- name: Commit and push changes
|
||||
if: env.changed == 'true'
|
||||
run: |
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add CHANGELOG.md .github/changelogs/
|
||||
git commit -m "Archive old changelog entries"
|
||||
git checkout -b $BRANCH_NAME || git checkout $BRANCH_NAME
|
||||
git push origin $BRANCH_NAME --force
|
||||
echo "HEAD_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Create pull request if not exists
|
||||
if: env.changed == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
run: |
|
||||
PR_EXISTS=$(gh pr list --head "${BRANCH_NAME}" --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository == false)][0].number // empty')
|
||||
if [ -z "$PR_EXISTS" ]; then
|
||||
gh pr create --title "[Github Action] Archive old changelog entries" \
|
||||
--body "This PR is auto-generated by a Github Action to archive old changelog entries (older than 14 days) to .github/changelogs/YEAR/MONTH.md" \
|
||||
--head $BRANCH_NAME \
|
||||
--base main \
|
||||
--label "$AUTOMATED_PR_LABEL"
|
||||
fi
|
||||
|
||||
- name: Approve and merge pull request
|
||||
if: env.changed == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token-merge.outputs.token }}
|
||||
run: |
|
||||
git config --global user.name "github-actions-automege[bot]"
|
||||
git config --global user.email "github-actions-automege[bot]@users.noreply.github.com"
|
||||
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository == false)][0].number // empty')
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
gh pr review "$PR_NUMBER" --approve
|
||||
gh pr merge "$PR_NUMBER" --squash --admin --match-head-commit "$HEAD_SHA"
|
||||
fi
|
||||
Generated
-439
@@ -1,439 +0,0 @@
|
||||
name: Create Changelog Pull Request
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
workflow_dispatch:
|
||||
# Fired by community-scripts/core when an engine pull request is merged, so a
|
||||
# change there does not wait for the next push here. Optional: engine PRs are
|
||||
# collected on every run regardless, this only decides how soon.
|
||||
repository_dispatch:
|
||||
types: [core-pr-merged]
|
||||
|
||||
jobs:
|
||||
update-changelog-pull-request:
|
||||
if: github.repository == 'community-scripts/ProxmoxVE'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CONFIG_PATH: .github/changelog-pr-config.json
|
||||
BRANCH_NAME: github-action-update-changelog
|
||||
AUTOMATED_PR_LABEL: "automated pr"
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Generate a token
|
||||
id: generate-token
|
||||
uses: actions/create-github-app-token@v3
|
||||
with:
|
||||
app-id: ${{ vars.GHAPP_PR_ID }}
|
||||
private-key: ${{ secrets.GHAPP_PR_PRIVATE_KEY }}
|
||||
|
||||
- name: Generate a token for PR approval and merge
|
||||
id: generate-token-merge
|
||||
uses: actions/create-github-app-token@v3
|
||||
with:
|
||||
app-id: ${{ vars.GHAPP_MERGEBOT_ID }}
|
||||
private-key: ${{ secrets.GHAPP_MERGEBOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Get latest dates in changelog
|
||||
run: |
|
||||
DATES=$(grep -E '^## [0-9]{4}-[0-9]{2}-[0-9]{2}' CHANGELOG.md | head -n 2 | awk '{print $2}')
|
||||
|
||||
LATEST_DATE=$(echo "$DATES" | sed -n '1p')
|
||||
SECOND_LATEST_DATE=$(echo "$DATES" | sed -n '2p')
|
||||
TODAY=$(date -u +%Y-%m-%d)
|
||||
|
||||
echo "TODAY=$TODAY" >> $GITHUB_ENV
|
||||
if [[ "$LATEST_DATE" == "$TODAY" ]]; then
|
||||
echo "LATEST_DATE=$SECOND_LATEST_DATE" >> $GITHUB_ENV
|
||||
else
|
||||
echo "LATEST_DATE=$LATEST_DATE" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Get categorized pull requests
|
||||
id: get-categorized-prs
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
script: |
|
||||
async function main() {
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
|
||||
const configPath = path.resolve(process.env.CONFIG_PATH);
|
||||
const fileContent = await fs.readFile(configPath, 'utf-8');
|
||||
const changelogConfig = JSON.parse(fileContent);
|
||||
|
||||
const categorizedPRs = changelogConfig.map(obj => ({
|
||||
...obj,
|
||||
notes: [],
|
||||
subCategories: obj.subCategories ?? (
|
||||
obj.labels.includes("update script") ? [
|
||||
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
|
||||
{ title: "✨ New Features", labels: ["feature"], notes: [] },
|
||||
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
|
||||
{ title: "🔧 Refactor", labels: ["refactor"], notes: [] },
|
||||
] :
|
||||
obj.labels.includes("maintenance") ? [
|
||||
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
|
||||
{ title: "✨ New Features", labels: ["feature"], notes: [] },
|
||||
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
|
||||
{ title: "📡 API", labels: ["api"], notes: [] },
|
||||
{ title: "Github", labels: ["github"], notes: [] },
|
||||
{ title: "📝 Documentation", labels: ["maintenance"], notes: [] },
|
||||
{ title: "🔧 Refactor", labels: ["refactor"], notes: [] }
|
||||
] :
|
||||
obj.labels.includes("website") ? [
|
||||
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
|
||||
{ title: "✨ New Features", labels: ["feature"], notes: [] },
|
||||
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
|
||||
{ title: "Script Information", labels: ["json"], notes: [] }
|
||||
] : []
|
||||
)
|
||||
}));
|
||||
|
||||
const latestDateInChangelog = new Date(process.env.LATEST_DATE);
|
||||
latestDateInChangelog.setUTCHours(23, 59, 59, 999);
|
||||
|
||||
const { data: pulls } = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo: "ProxmoxVE",
|
||||
base: "main",
|
||||
state: "closed",
|
||||
sort: "updated",
|
||||
direction: "desc",
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
const filteredPRs = pulls.filter(pr =>
|
||||
pr.merged_at &&
|
||||
new Date(pr.merged_at) > latestDateInChangelog &&
|
||||
!pr.labels.some(label =>
|
||||
["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase())
|
||||
)
|
||||
);
|
||||
|
||||
async function getScriptAuthors(pr) {
|
||||
try {
|
||||
const { data: files } = await github.rest.pulls.listFiles({
|
||||
owner: context.repo.owner,
|
||||
repo: "ProxmoxVE",
|
||||
pull_number: pr.number,
|
||||
per_page: 100,
|
||||
});
|
||||
const ctFile = files.find(file => file.status === "added" && /^ct\/[^/]+\.sh$/.test(file.filename));
|
||||
if (!ctFile) return "";
|
||||
|
||||
const { data: script } = await github.rest.repos.getContent({
|
||||
owner: context.repo.owner,
|
||||
repo: "ProxmoxVE",
|
||||
path: ctFile.filename,
|
||||
ref: pr.merge_commit_sha,
|
||||
});
|
||||
const header = Buffer.from(script.content, "base64").toString("utf-8")
|
||||
.split("\n").slice(0, 20)
|
||||
.find(line => /^#\s*Authors?:/i.test(line));
|
||||
if (!header) return "";
|
||||
|
||||
// "MickLesk (CanbiZ)" puts the handle first, "Slaviša Arežina (tremor021)" in the parentheses
|
||||
const candidates = header.replace(/^#\s*Authors?:/i, "").split("|").map(part => {
|
||||
part = part.trim().replace(/^[A-Za-z-]+:\s*/, "");
|
||||
const match = part.match(/^([^(]*)\(([^)]*)\)/);
|
||||
if (!match) return part;
|
||||
const words = match[1].trim().split(/\s+/).filter(Boolean);
|
||||
return words.length === 1 ? words[0] : match[2].trim();
|
||||
});
|
||||
|
||||
// A display name used alone in a header; the GitHub account of that name is someone else
|
||||
const authorAliases = { canbiz: "MickLesk" };
|
||||
const logins = [];
|
||||
for (let candidate of candidates) {
|
||||
if (!/^[A-Za-z0-9-]+$/.test(candidate)) continue;
|
||||
candidate = authorAliases[candidate.toLowerCase()] ?? candidate;
|
||||
try {
|
||||
const { data: user } = await github.rest.users.getByUsername({ username: candidate });
|
||||
if (user.type === "User" && !logins.includes(user.login)) logins.push(user.login);
|
||||
} catch (error) {
|
||||
console.log(`No GitHub user ${candidate} (${ctFile.filename}): ${error}`);
|
||||
}
|
||||
}
|
||||
return logins.map(login => `[@${login}](https://github.com/${login})`).join(", ");
|
||||
} catch (error) {
|
||||
console.error(`Could not read the author of #${pr.number}: ${error}`);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of filteredPRs) {
|
||||
const prLabels = pr.labels.map(label => label.name.toLowerCase());
|
||||
const scriptAuthors = prLabels.includes("new script") ? await getScriptAuthors(pr) : "";
|
||||
if (scriptAuthors) {
|
||||
prNote = `- ${pr.title} ${scriptAuthors} ([#${pr.number}](${pr.html_url}))`;
|
||||
} else if (pr.user.login.includes("push-app-to-main[bot]")) {
|
||||
|
||||
const scriptName = pr.title;
|
||||
try {
|
||||
const { data: relatedIssues } = await github.rest.issues.listForRepo({
|
||||
owner: context.repo.owner,
|
||||
repo: "DevScripts",
|
||||
state: "all",
|
||||
labels: ["Started Migration To ProxmoxVE"],
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
const matchingIssue = relatedIssues.find(issue =>
|
||||
issue.title.trim().toLowerCase() === scriptName.trim().toLowerCase()
|
||||
);
|
||||
|
||||
if (matchingIssue) {
|
||||
const issueAuthor = matchingIssue.user.login;
|
||||
const issueAuthorUrl = `https://github.com/${issueAuthor}`;
|
||||
prNote = `- ${pr.title} [@${issueAuthor}](${issueAuthorUrl}) ([#${pr.number}](${pr.html_url}))`;
|
||||
}
|
||||
else {
|
||||
prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error fetching related issues: ${error}`);
|
||||
prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
|
||||
}
|
||||
}else{
|
||||
prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
|
||||
}
|
||||
|
||||
|
||||
if (prLabels.includes("new script")) {
|
||||
const newScriptCategory = categorizedPRs.find(category =>
|
||||
category.title === "New Scripts" || category.labels.includes("new script"));
|
||||
if (newScriptCategory) {
|
||||
newScriptCategory.notes.push(prNote);
|
||||
}
|
||||
} else {
|
||||
|
||||
let categorized = false;
|
||||
const priorityCategories = categorizedPRs.slice();
|
||||
|
||||
// Priority order for content-type labels (highest priority first)
|
||||
const subCategoryPriority = ["breaking change", "bugfix", "feature", "refactor"];
|
||||
|
||||
for (const category of priorityCategories) {
|
||||
if (categorized) break;
|
||||
if (category.labels.some(label => prLabels.includes(label))) {
|
||||
if (category.subCategories && category.subCategories.length > 0) {
|
||||
// Find subcategory by priority order instead of first match
|
||||
let subCategory = null;
|
||||
for (const priorityLabel of subCategoryPriority) {
|
||||
if (prLabels.includes(priorityLabel)) {
|
||||
subCategory = category.subCategories.find(sub =>
|
||||
sub.labels.includes(priorityLabel)
|
||||
);
|
||||
if (subCategory) break;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: check for any other subcategory match (api, github, json, etc.)
|
||||
if (!subCategory) {
|
||||
subCategory = category.subCategories.find(sub =>
|
||||
sub.labels.some(label => prLabels.includes(label))
|
||||
);
|
||||
}
|
||||
|
||||
if (subCategory) {
|
||||
subCategory.notes.push(prNote);
|
||||
} else {
|
||||
category.notes.push(prNote);
|
||||
}
|
||||
} else {
|
||||
category.notes.push(prNote);
|
||||
}
|
||||
categorized = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: Add to Uncategorized if no category matched
|
||||
if (!categorized) {
|
||||
const uncategorized = categorizedPRs.find(category =>
|
||||
category.title.includes("Uncategorized") || category.labels.includes("needs triage"));
|
||||
if (uncategorized) {
|
||||
uncategorized.notes.push(prNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ── Pull requests from other repositories ───────────────────────
|
||||
const externalRepos = [
|
||||
{ repo: "core", category: "💾 Core", prefix: "core" },
|
||||
{ repo: "services", category: "🛰️ Services", prefix: "services" },
|
||||
{ repo: "ProxmoxVE-Frontend", category: "🌐 Website", prefix: "website" },
|
||||
];
|
||||
const externalLabelAliases = {
|
||||
bug: "bugfix",
|
||||
bugfix: "bugfix",
|
||||
enhancement: "feature",
|
||||
feature: "feature",
|
||||
refactor: "refactor",
|
||||
"breaking change": "breaking change",
|
||||
};
|
||||
const externalPriority = ["breaking change", "bugfix", "feature", "refactor"];
|
||||
|
||||
for (const { repo, category: categoryTitle, prefix } of externalRepos) {
|
||||
try {
|
||||
const { data: externalPulls } = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo,
|
||||
base: "main",
|
||||
state: "closed",
|
||||
sort: "updated",
|
||||
direction: "desc",
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
const category = categorizedPRs.find(c => c.title === categoryTitle);
|
||||
|
||||
for (const pr of externalPulls) {
|
||||
if (!pr.merged_at) continue;
|
||||
if (new Date(pr.merged_at) <= latestDateInChangelog) continue;
|
||||
|
||||
const rawLabels = pr.labels.map(label => label.name.toLowerCase());
|
||||
if (rawLabels.some(l => ["invalid", "wontdo", "wontfix", "duplicate", process.env.AUTOMATED_PR_LABEL].includes(l))) continue;
|
||||
|
||||
if (!category) {
|
||||
console.log(`No ${categoryTitle} category configured; skipping ${prefix}#${pr.number}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// core#N rather than #N: a bare #N links to a pull request in this repository.
|
||||
const note = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([${prefix}#${pr.number}](${pr.html_url}))`;
|
||||
|
||||
const mapped = rawLabels.map(l => externalLabelAliases[l]).filter(Boolean);
|
||||
let placed = false;
|
||||
if (category.subCategories && category.subCategories.length > 0) {
|
||||
for (const priorityLabel of externalPriority) {
|
||||
if (!mapped.includes(priorityLabel)) continue;
|
||||
const subCategory = category.subCategories.find(sub =>
|
||||
sub.labels.includes(priorityLabel));
|
||||
if (subCategory) {
|
||||
subCategory.notes.push(note);
|
||||
placed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!placed) category.notes.push(note);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Could not read ${repo} pull requests: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
return categorizedPRs;
|
||||
}
|
||||
|
||||
return await main();
|
||||
|
||||
- name: Update CHANGELOG.md
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
|
||||
const today = process.env.TODAY;
|
||||
const latestDateInChangelog = process.env.LATEST_DATE;
|
||||
const changelogPath = path.resolve('CHANGELOG.md');
|
||||
const categorizedPRs = ${{ steps.get-categorized-prs.outputs.result }};
|
||||
|
||||
console.log(JSON.stringify(categorizedPRs, null, 2));
|
||||
|
||||
|
||||
let newReleaseNotes = `## ${today}\n\n`;
|
||||
for (const { title, notes, subCategories } of categorizedPRs) {
|
||||
const hasSubcategories = subCategories && subCategories.length > 0;
|
||||
const hasMainNotes = notes.length > 0;
|
||||
const hasSubNotes = hasSubcategories && subCategories.some(sub => sub.notes && sub.notes.length > 0);
|
||||
|
||||
if (hasMainNotes || hasSubNotes) {
|
||||
newReleaseNotes += `### ${title}\n\n`;
|
||||
}
|
||||
|
||||
if (hasMainNotes) {
|
||||
newReleaseNotes += ` ${notes.join("\n")}\n\n`;
|
||||
}
|
||||
if (hasSubcategories) {
|
||||
for (const { title: subTitle, notes: subNotes } of subCategories) {
|
||||
if (subNotes && subNotes.length > 0) {
|
||||
newReleaseNotes += ` - #### ${subTitle}\n\n`;
|
||||
newReleaseNotes += ` ${subNotes.join("\n ")}\n\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
const changelogContent = await fs.readFile(changelogPath, 'utf-8');
|
||||
const changelogIncludesTodaysReleaseNotes = changelogContent.includes(`\n## ${today}`);
|
||||
|
||||
const regex = changelogIncludesTodaysReleaseNotes
|
||||
? new RegExp(`## ${today}.*(?=## ${latestDateInChangelog})`, "gs")
|
||||
: new RegExp(`(?=## ${latestDateInChangelog})`, "gs");
|
||||
|
||||
const newChangelogContent = changelogContent.replace(regex, newReleaseNotes);
|
||||
await fs.writeFile(changelogPath, newChangelogContent);
|
||||
|
||||
- name: Check for changes
|
||||
id: verify-diff
|
||||
run: |
|
||||
git diff --quiet . || echo "changed=true" >> $GITHUB_ENV
|
||||
|
||||
- name: Commit and push changes
|
||||
if: env.changed == 'true'
|
||||
run: |
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add CHANGELOG.md
|
||||
git commit -m "Update CHANGELOG.md"
|
||||
git checkout -b $BRANCH_NAME || git checkout $BRANCH_NAME
|
||||
git push origin $BRANCH_NAME --force
|
||||
echo "HEAD_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Create pull request if not exists
|
||||
if: env.changed == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
run: |
|
||||
PR_EXISTS=$(gh pr list --head "${BRANCH_NAME}" --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository == false)][0].number // empty')
|
||||
if [ -z "$PR_EXISTS" ]; then
|
||||
gh pr create --title "[Github Action] Update CHANGELOG.md" \
|
||||
--body "This PR is auto-generated by a Github Action to update the CHANGELOG.md file." \
|
||||
--head $BRANCH_NAME \
|
||||
--base main \
|
||||
--label "$AUTOMATED_PR_LABEL"
|
||||
fi
|
||||
|
||||
- name: Approve pull request
|
||||
if: env.changed == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository == false)][0].number // empty')
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
gh pr review "$PR_NUMBER" --approve
|
||||
fi
|
||||
|
||||
- name: Approve pull request and merge
|
||||
if: env.changed == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token-merge.outputs.token }}
|
||||
run: |
|
||||
git config --global user.name "github-actions-automege[bot]"
|
||||
git config --global user.email "github-actions-automege[bot]@users.noreply.github.com"
|
||||
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository == false)][0].number // empty')
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
gh pr review "$PR_NUMBER" --approve
|
||||
gh pr merge "$PR_NUMBER" --squash --admin --match-head-commit "$HEAD_SHA"
|
||||
fi
|
||||
+1
-1
@@ -579,7 +579,7 @@ jobs:
|
||||
# "opened" — a label added a moment later can arrive too late.
|
||||
#
|
||||
# "keep-open" rather than "automated pr" for that exemption: both
|
||||
# skip the template check, but changelog-pr.yml drops every PR
|
||||
# skip the template check, but daily-release.yml drops every PR
|
||||
# carrying "automated pr" (it marks its own PR with it), so that
|
||||
# label would keep these bumps out of the changelog entirely.
|
||||
# "update script" and "bugfix" place them under Updated Scripts →
|
||||
|
||||
Generated
+1
-1
@@ -555,7 +555,7 @@ jobs:
|
||||
|
||||
# Labels go on at creation: they exempt the PR from the template check,
|
||||
# which runs on "opened". "keep-open" rather than "automated pr", which
|
||||
# changelog-pr.yml drops.
|
||||
# daily-release.yml drops.
|
||||
if url=$(gh pr create \
|
||||
--title "${slug}: bump PHP from ${our} to ${upstream}" \
|
||||
--body "$body" \
|
||||
|
||||
+1
-1
@@ -524,7 +524,7 @@ jobs:
|
||||
|
||||
# Labels go on at creation: they exempt the PR from the template check,
|
||||
# which runs on "opened". "keep-open" rather than "automated pr", which
|
||||
# changelog-pr.yml drops.
|
||||
# daily-release.yml drops.
|
||||
if url=$(gh pr create \
|
||||
--title "${slug}: bump Python from ${our} to ${upstream}" \
|
||||
--body "$body" \
|
||||
|
||||
Generated
+886
@@ -0,0 +1,886 @@
|
||||
name: Daily Changelog and Release
|
||||
|
||||
# One CHANGELOG.md pull request per day.
|
||||
#
|
||||
# While the day is running, every merge to main (and every merged core pull
|
||||
# request) rebuilds the entry for the current UTC day on the changelog branch
|
||||
# and keeps that one pull request up to date, so the entries are visible and a
|
||||
# bad title can be fixed by renaming the pull request it comes from.
|
||||
#
|
||||
# At 00:01 UTC the previous day is finished: the pull request is rebuilt with
|
||||
# the whole day, merged automatically, and the GitHub release is created from
|
||||
# the same notes. On Sundays the entries older than 30 days are archived into
|
||||
# .github/changelogs/ in that pull request.
|
||||
#
|
||||
# The range to build starts at the newest entry in CHANGELOG.md, so a day that
|
||||
# failed is picked up by the next run.
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: ["main"]
|
||||
# Fired by community-scripts/core when an engine pull request is merged, so a
|
||||
# change there shows up in the open pull request without waiting for the next
|
||||
# push here.
|
||||
repository_dispatch:
|
||||
types: [core-pr-merged]
|
||||
schedule:
|
||||
- cron: '1 0 * * *' # Finishes the previous day at 00:01 UTC
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
finalize:
|
||||
description: "Finish the previous day: merge the pull request and create the release"
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
since:
|
||||
description: "Rebuild from this day on (YYYY-MM-DD, UTC). Defaults to the newest entry in CHANGELOG.md."
|
||||
required: false
|
||||
type: string
|
||||
archive:
|
||||
description: "Archive old changelog entries even if it is not Sunday"
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
dry_run:
|
||||
description: "Build the notes and show the changelog diff, but create no release, push nothing and open no pull request"
|
||||
required: false
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
concurrency:
|
||||
group: daily-release
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
daily-release:
|
||||
if: github.repository == 'community-scripts/ProxmoxVE'
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
CONFIG_PATH: .github/changelog-pr-config.json
|
||||
BRANCH_NAME: github-action-update-changelog
|
||||
AUTOMATED_PR_LABEL: "automated pr"
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
steps:
|
||||
- name: Generate a token
|
||||
id: generate-token
|
||||
if: ${{ !inputs.dry_run }}
|
||||
uses: actions/create-github-app-token@v3
|
||||
with:
|
||||
app-id: ${{ vars.GHAPP_PR_ID }}
|
||||
private-key: ${{ secrets.GHAPP_PR_PRIVATE_KEY }}
|
||||
|
||||
- name: Generate a token for PR approval and merge
|
||||
id: generate-token-merge
|
||||
if: ${{ !inputs.dry_run }}
|
||||
uses: actions/create-github-app-token@v3
|
||||
with:
|
||||
app-id: ${{ vars.GHAPP_MERGEBOT_ID }}
|
||||
private-key: ${{ secrets.GHAPP_MERGEBOT_PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v7
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Resolve the range to build
|
||||
env:
|
||||
EVENT_NAME: ${{ github.event_name }}
|
||||
INPUT_FINALIZE: ${{ inputs.finalize }}
|
||||
INPUT_SINCE: ${{ inputs.since }}
|
||||
INPUT_ARCHIVE: ${{ inputs.archive }}
|
||||
INPUT_DRY_RUN: ${{ inputs.dry_run }}
|
||||
run: |
|
||||
if [[ "$INPUT_DRY_RUN" == "true" ]]; then
|
||||
echo "DRY_RUN=true" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
MODE=update
|
||||
if [[ "$EVENT_NAME" == "schedule" || "$INPUT_FINALIZE" == "true" ]]; then
|
||||
MODE=finalize
|
||||
fi
|
||||
echo "MODE=$MODE" >> $GITHUB_ENV
|
||||
|
||||
TODAY=$(date -u +%Y-%m-%d)
|
||||
YESTERDAY=$(date -u -d yesterday +%Y-%m-%d)
|
||||
TOMORROW=$(date -u -d tomorrow +%Y-%m-%d)
|
||||
LATEST=$(grep -m1 -E '^## [0-9]{4}-[0-9]{2}-[0-9]{2}' CHANGELOG.md | awk '{print $2}')
|
||||
|
||||
# The newest entry is built again when it is recent: it may have been merged
|
||||
# while its day was still running and be missing the pull requests after that.
|
||||
if [[ -n "$INPUT_SINCE" ]]; then
|
||||
START=$(date -u -d "$INPUT_SINCE" +%Y-%m-%d) || exit 1
|
||||
elif [[ -z "$LATEST" ]]; then
|
||||
START=$YESTERDAY
|
||||
elif [[ "$LATEST" > "$YESTERDAY" || "$LATEST" == "$YESTERDAY" ]]; then
|
||||
START=$LATEST
|
||||
else
|
||||
START=$(date -u -d "$LATEST +1 day" +%Y-%m-%d)
|
||||
fi
|
||||
|
||||
# Finishing a day only builds complete days; the day under way is left for
|
||||
# the next one so that its entry is never merged half done.
|
||||
if [[ "$MODE" == "finalize" ]]; then
|
||||
END=$TODAY
|
||||
else
|
||||
END=$TOMORROW
|
||||
fi
|
||||
echo "TODAY=$TODAY" >> $GITHUB_ENV
|
||||
echo "RANGE_START=${START}T00:00:00Z" >> $GITHUB_ENV
|
||||
echo "RANGE_END=${END}T00:00:00Z" >> $GITHUB_ENV
|
||||
echo "Mode: $MODE, building $START up to (not including) $END"
|
||||
|
||||
if [[ "$INPUT_ARCHIVE" == "true" || ( "$MODE" == "finalize" && "$(date -u +%u)" == "7" ) ]]; then
|
||||
echo "RUN_ARCHIVE=true" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Get categorized pull requests
|
||||
id: get-categorized-prs
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
script: |
|
||||
async function main() {
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
|
||||
const configPath = path.resolve(process.env.CONFIG_PATH);
|
||||
const fileContent = await fs.readFile(configPath, 'utf-8');
|
||||
const changelogConfig = JSON.parse(fileContent);
|
||||
|
||||
const newCategories = () => changelogConfig.map(obj => ({
|
||||
...obj,
|
||||
notes: [],
|
||||
subCategories: obj.subCategories ?? (
|
||||
obj.labels.includes("update script") ? [
|
||||
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
|
||||
{ title: "✨ New Features", labels: ["feature"], notes: [] },
|
||||
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
|
||||
{ title: "🔧 Refactor", labels: ["refactor"], notes: [] },
|
||||
] :
|
||||
obj.labels.includes("maintenance") ? [
|
||||
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
|
||||
{ title: "✨ New Features", labels: ["feature"], notes: [] },
|
||||
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
|
||||
{ title: "📡 API", labels: ["api"], notes: [] },
|
||||
{ title: "Github", labels: ["github"], notes: [] },
|
||||
{ title: "📝 Documentation", labels: ["maintenance"], notes: [] },
|
||||
{ title: "🔧 Refactor", labels: ["refactor"], notes: [] }
|
||||
] :
|
||||
obj.labels.includes("website") ? [
|
||||
{ title: "🐞 Bug Fixes", labels: ["bugfix"], notes: [] },
|
||||
{ title: "✨ New Features", labels: ["feature"], notes: [] },
|
||||
{ title: "💥 Breaking Changes", labels: ["breaking change"], notes: [] },
|
||||
{ title: "Script Information", labels: ["json"], notes: [] }
|
||||
] : []
|
||||
)
|
||||
}));
|
||||
|
||||
// One set of categories per UTC day, keyed YYYY-MM-DD
|
||||
const days = {};
|
||||
const categoriesFor = mergedAt => days[mergedAt.slice(0, 10)] ??= newCategories();
|
||||
|
||||
const rangeStart = new Date(process.env.RANGE_START);
|
||||
const rangeEnd = new Date(process.env.RANGE_END);
|
||||
|
||||
// Closed pull requests come newest-update first, and a pull request merged
|
||||
// in the range was updated at or after its merge. So once a page ends with
|
||||
// one last updated before the range began, nothing further can belong to it.
|
||||
async function listMergedPRs(repo) {
|
||||
const merged = [];
|
||||
for (let page = 1; ; page++) {
|
||||
const { data } = await github.rest.pulls.list({
|
||||
owner: context.repo.owner,
|
||||
repo,
|
||||
base: "main",
|
||||
state: "closed",
|
||||
sort: "updated",
|
||||
direction: "desc",
|
||||
per_page: 100,
|
||||
page,
|
||||
});
|
||||
for (const pr of data) {
|
||||
if (!pr.merged_at) continue;
|
||||
const mergedAt = new Date(pr.merged_at);
|
||||
if (mergedAt >= rangeStart && mergedAt < rangeEnd) merged.push(pr);
|
||||
}
|
||||
if (data.length < 100 || new Date(data[data.length - 1].updated_at) < rangeStart) {
|
||||
// Newest merge first, so the notes do not reshuffle between runs
|
||||
return merged.sort((a, b) => b.merged_at.localeCompare(a.merged_at) || b.number - a.number);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const filteredPRs = (await listMergedPRs("ProxmoxVE")).filter(pr =>
|
||||
!pr.labels.some(label =>
|
||||
["invalid", "wontdo", process.env.AUTOMATED_PR_LABEL].includes(label.name.toLowerCase())
|
||||
)
|
||||
);
|
||||
|
||||
async function getScriptAuthors(pr) {
|
||||
try {
|
||||
const { data: files } = await github.rest.pulls.listFiles({
|
||||
owner: context.repo.owner,
|
||||
repo: "ProxmoxVE",
|
||||
pull_number: pr.number,
|
||||
per_page: 100,
|
||||
});
|
||||
const ctFile = files.find(file => file.status === "added" && /^ct\/[^/]+\.sh$/.test(file.filename));
|
||||
if (!ctFile) return "";
|
||||
|
||||
const { data: script } = await github.rest.repos.getContent({
|
||||
owner: context.repo.owner,
|
||||
repo: "ProxmoxVE",
|
||||
path: ctFile.filename,
|
||||
ref: pr.merge_commit_sha,
|
||||
});
|
||||
const header = Buffer.from(script.content, "base64").toString("utf-8")
|
||||
.split("\n").slice(0, 20)
|
||||
.find(line => /^#\s*Authors?:/i.test(line));
|
||||
if (!header) return "";
|
||||
|
||||
// "MickLesk (CanbiZ)" puts the handle first, "Slaviša Arežina (tremor021)" in the parentheses
|
||||
const candidates = header.replace(/^#\s*Authors?:/i, "").split("|").map(part => {
|
||||
part = part.trim().replace(/^[A-Za-z-]+:\s*/, "");
|
||||
const match = part.match(/^([^(]*)\(([^)]*)\)/);
|
||||
if (!match) return part;
|
||||
const words = match[1].trim().split(/\s+/).filter(Boolean);
|
||||
return words.length === 1 ? words[0] : match[2].trim();
|
||||
});
|
||||
|
||||
// A display name used alone in a header; the GitHub account of that name is someone else
|
||||
const authorAliases = { canbiz: "MickLesk" };
|
||||
const logins = [];
|
||||
for (let candidate of candidates) {
|
||||
if (!/^[A-Za-z0-9-]+$/.test(candidate)) continue;
|
||||
candidate = authorAliases[candidate.toLowerCase()] ?? candidate;
|
||||
try {
|
||||
const { data: user } = await github.rest.users.getByUsername({ username: candidate });
|
||||
if (user.type === "User" && !logins.includes(user.login)) logins.push(user.login);
|
||||
} catch (error) {
|
||||
console.log(`No GitHub user ${candidate} (${ctFile.filename}): ${error}`);
|
||||
}
|
||||
}
|
||||
return logins.map(login => `[@${login}](https://github.com/${login})`).join(", ");
|
||||
} catch (error) {
|
||||
console.error(`Could not read the author of #${pr.number}: ${error}`);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
for (const pr of filteredPRs) {
|
||||
const categorizedPRs = categoriesFor(pr.merged_at);
|
||||
const prLabels = pr.labels.map(label => label.name.toLowerCase());
|
||||
const scriptAuthors = prLabels.includes("new script") ? await getScriptAuthors(pr) : "";
|
||||
if (scriptAuthors) {
|
||||
prNote = `- ${pr.title} ${scriptAuthors} ([#${pr.number}](${pr.html_url}))`;
|
||||
} else if (pr.user.login.includes("push-app-to-main[bot]")) {
|
||||
|
||||
const scriptName = pr.title;
|
||||
try {
|
||||
const { data: relatedIssues } = await github.rest.issues.listForRepo({
|
||||
owner: context.repo.owner,
|
||||
repo: "DevScripts",
|
||||
state: "all",
|
||||
labels: ["Started Migration To ProxmoxVE"],
|
||||
per_page: 100,
|
||||
});
|
||||
|
||||
const matchingIssue = relatedIssues.find(issue =>
|
||||
issue.title.trim().toLowerCase() === scriptName.trim().toLowerCase()
|
||||
);
|
||||
|
||||
if (matchingIssue) {
|
||||
const issueAuthor = matchingIssue.user.login;
|
||||
const issueAuthorUrl = `https://github.com/${issueAuthor}`;
|
||||
prNote = `- ${pr.title} [@${issueAuthor}](${issueAuthorUrl}) ([#${pr.number}](${pr.html_url}))`;
|
||||
}
|
||||
else {
|
||||
prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error fetching related issues: ${error}`);
|
||||
prNote = `- ${pr.title} ([#${pr.number}](${pr.html_url}))`;
|
||||
}
|
||||
}else{
|
||||
prNote = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([#${pr.number}](${pr.html_url}))`;
|
||||
}
|
||||
|
||||
|
||||
if (prLabels.includes("new script")) {
|
||||
const newScriptCategory = categorizedPRs.find(category =>
|
||||
category.title === "New Scripts" || category.labels.includes("new script"));
|
||||
if (newScriptCategory) {
|
||||
newScriptCategory.notes.push(prNote);
|
||||
}
|
||||
} else {
|
||||
|
||||
let categorized = false;
|
||||
const priorityCategories = categorizedPRs.slice();
|
||||
|
||||
// Priority order for content-type labels (highest priority first)
|
||||
const subCategoryPriority = ["breaking change", "bugfix", "feature", "refactor"];
|
||||
|
||||
for (const category of priorityCategories) {
|
||||
if (categorized) break;
|
||||
if (category.labels.some(label => prLabels.includes(label))) {
|
||||
if (category.subCategories && category.subCategories.length > 0) {
|
||||
// Find subcategory by priority order instead of first match
|
||||
let subCategory = null;
|
||||
for (const priorityLabel of subCategoryPriority) {
|
||||
if (prLabels.includes(priorityLabel)) {
|
||||
subCategory = category.subCategories.find(sub =>
|
||||
sub.labels.includes(priorityLabel)
|
||||
);
|
||||
if (subCategory) break;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: check for any other subcategory match (api, github, json, etc.)
|
||||
if (!subCategory) {
|
||||
subCategory = category.subCategories.find(sub =>
|
||||
sub.labels.some(label => prLabels.includes(label))
|
||||
);
|
||||
}
|
||||
|
||||
if (subCategory) {
|
||||
subCategory.notes.push(prNote);
|
||||
} else {
|
||||
category.notes.push(prNote);
|
||||
}
|
||||
} else {
|
||||
category.notes.push(prNote);
|
||||
}
|
||||
categorized = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback: Add to Uncategorized if no category matched
|
||||
if (!categorized) {
|
||||
const uncategorized = categorizedPRs.find(category =>
|
||||
category.title.includes("Uncategorized") || category.labels.includes("needs triage"));
|
||||
if (uncategorized) {
|
||||
uncategorized.notes.push(prNote);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ── Pull requests from other repositories ───────────────────────
|
||||
const externalRepos = [
|
||||
{ repo: "core", category: "💾 Core", prefix: "core" },
|
||||
{ repo: "services", category: "🛰️ Services", prefix: "services" },
|
||||
{ repo: "ProxmoxVE-Frontend", category: "🌐 Website", prefix: "website" },
|
||||
];
|
||||
const externalLabelAliases = {
|
||||
bug: "bugfix",
|
||||
bugfix: "bugfix",
|
||||
enhancement: "feature",
|
||||
feature: "feature",
|
||||
refactor: "refactor",
|
||||
"breaking change": "breaking change",
|
||||
};
|
||||
const externalPriority = ["breaking change", "bugfix", "feature", "refactor"];
|
||||
|
||||
for (const { repo, category: categoryTitle, prefix } of externalRepos) {
|
||||
try {
|
||||
const externalPulls = await listMergedPRs(repo);
|
||||
|
||||
for (const pr of externalPulls) {
|
||||
const category = categoriesFor(pr.merged_at).find(c => c.title === categoryTitle);
|
||||
const rawLabels = pr.labels.map(label => label.name.toLowerCase());
|
||||
if (rawLabels.some(l => ["invalid", "wontdo", "wontfix", "duplicate", process.env.AUTOMATED_PR_LABEL].includes(l))) continue;
|
||||
|
||||
if (!category) {
|
||||
console.log(`No ${categoryTitle} category configured; skipping ${prefix}#${pr.number}`);
|
||||
continue;
|
||||
}
|
||||
|
||||
// core#N rather than #N: a bare #N links to a pull request in this repository.
|
||||
const note = `- ${pr.title} [@${pr.user.login}](https://github.com/${pr.user.login}) ([${prefix}#${pr.number}](${pr.html_url}))`;
|
||||
|
||||
const mapped = rawLabels.map(l => externalLabelAliases[l]).filter(Boolean);
|
||||
let placed = false;
|
||||
if (category.subCategories && category.subCategories.length > 0) {
|
||||
for (const priorityLabel of externalPriority) {
|
||||
if (!mapped.includes(priorityLabel)) continue;
|
||||
const subCategory = category.subCategories.find(sub =>
|
||||
sub.labels.includes(priorityLabel));
|
||||
if (subCategory) {
|
||||
subCategory.notes.push(note);
|
||||
placed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!placed) category.notes.push(note);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Could not read ${repo} pull requests: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
return days;
|
||||
}
|
||||
|
||||
return await main();
|
||||
|
||||
- name: Build the changelog entries
|
||||
id: notes
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
|
||||
const changelogPath = path.resolve('CHANGELOG.md');
|
||||
const daysByDate = ${{ steps.get-categorized-prs.outputs.result }};
|
||||
|
||||
console.log(JSON.stringify(daysByDate, null, 2));
|
||||
|
||||
function renderDay(date, categorizedPRs) {
|
||||
let hasNotes = false;
|
||||
let text = `## ${date}\n\n`;
|
||||
for (const { title, notes, subCategories } of categorizedPRs) {
|
||||
const hasSubcategories = subCategories && subCategories.length > 0;
|
||||
const hasMainNotes = notes.length > 0;
|
||||
const hasSubNotes = hasSubcategories && subCategories.some(sub => sub.notes && sub.notes.length > 0);
|
||||
|
||||
if (hasMainNotes || hasSubNotes) {
|
||||
hasNotes = true;
|
||||
text += `### ${title}\n\n`;
|
||||
}
|
||||
|
||||
if (hasMainNotes) {
|
||||
text += ` ${notes.join("\n")}\n\n`;
|
||||
}
|
||||
if (hasSubcategories) {
|
||||
for (const { title: subTitle, notes: subNotes } of subCategories) {
|
||||
if (subNotes && subNotes.length > 0) {
|
||||
text += ` - #### ${subTitle}\n\n`;
|
||||
text += ` ${subNotes.join("\n ")}\n\n`;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return hasNotes ? text.trimEnd() + '\n' : null;
|
||||
}
|
||||
|
||||
// Days without a merged pull request get no entry
|
||||
const sections = {};
|
||||
for (const [date, categorizedPRs] of Object.entries(daysByDate)) {
|
||||
const text = renderDay(date, categorizedPRs);
|
||||
if (text) {
|
||||
sections[date] = text;
|
||||
await fs.writeFile(path.join(process.env.RUNNER_TEMP, `section_${date}.md`), text);
|
||||
}
|
||||
}
|
||||
const dates = Object.keys(sections).sort();
|
||||
console.log(`Entries built: ${dates.join(", ") || "none"}`);
|
||||
|
||||
// Every finished day gets a release, unless it already has one. The pull
|
||||
// request for the day under way is only an entry in CHANGELOG.md.
|
||||
const releaseDays = process.env.MODE === "finalize" ? dates : [];
|
||||
core.setOutput('release_days', releaseDays.join(" "));
|
||||
|
||||
// CHANGELOG.md is a preamble followed by one entry per day, newest first.
|
||||
// An entry that is built again replaces the old one, a new one goes in order.
|
||||
const original = await fs.readFile(changelogPath, 'utf-8');
|
||||
const parts = original.split(/^(?=## \d{4}-\d{2}-\d{2}$)/m);
|
||||
const preamble = /^## \d{4}-\d{2}-\d{2}$/m.test(parts[0]) ? "" : parts.shift();
|
||||
const entries = new Map(parts.map(part => [part.slice(3, 13), part]));
|
||||
for (const date of dates) {
|
||||
entries.set(date, sections[date]);
|
||||
}
|
||||
const body = [...entries.keys()].sort().reverse()
|
||||
.map(date => entries.get(date).trimEnd())
|
||||
.join("\n\n");
|
||||
const updated = `${preamble}${body}${original.endsWith('\n') ? '\n' : ''}`;
|
||||
|
||||
if (updated !== original) {
|
||||
await fs.writeFile(changelogPath, updated);
|
||||
}
|
||||
|
||||
- name: Create GitHub releases
|
||||
if: steps.notes.outputs.release_days != ''
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RELEASE_DAYS: ${{ steps.notes.outputs.release_days }}
|
||||
run: |
|
||||
for DAY in $RELEASE_DAYS; do
|
||||
if gh release view "$DAY" >/dev/null 2>&1; then
|
||||
echo "Release $DAY already exists, skipping"
|
||||
continue
|
||||
fi
|
||||
|
||||
cd "$RUNNER_TEMP"
|
||||
|
||||
# GitHub fills a release's Contributors only from bare @login mentions
|
||||
sed -E 's#\[@([A-Za-z0-9-]+)\]\(https://github\.com/\1\)#@\1#g' "section_$DAY.md" > release_full.md
|
||||
|
||||
# Keep whole lines up to 120000 characters (GitHub allows 125000)
|
||||
export LC_ALL=C.UTF-8
|
||||
SIZE=0
|
||||
TRUNCATED=false
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
SIZE=$((SIZE + ${#line} + 1))
|
||||
if [ "$SIZE" -gt 120000 ]; then
|
||||
TRUNCATED=true
|
||||
break
|
||||
fi
|
||||
printf '%s\n' "$line"
|
||||
done < release_full.md > release_notes.md
|
||||
if [ "$TRUNCATED" = true ]; then
|
||||
printf '\nCut to fit the release size limit. The full list is in [CHANGELOG.md](https://github.com/community-scripts/ProxmoxVE/blob/main/CHANGELOG.md).\n' >> release_notes.md
|
||||
fi
|
||||
|
||||
PREVIOUS=$(gh release view --json tagName --jq .tagName 2>/dev/null || true)
|
||||
if [ -n "$PREVIOUS" ]; then
|
||||
printf '\n**Full Changelog**: https://github.com/community-scripts/ProxmoxVE/compare/%s...%s\n' "$PREVIOUS" "$DAY" >> release_notes.md
|
||||
fi
|
||||
|
||||
cat release_notes.md
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "Dry run: not creating the release $DAY"
|
||||
else
|
||||
gh release create "$DAY" -t "$DAY" -F release_notes.md
|
||||
fi
|
||||
cd - >/dev/null
|
||||
done
|
||||
|
||||
- name: Archive old changelog entries
|
||||
if: env.RUN_ARCHIVE == 'true'
|
||||
uses: actions/github-script@v9
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs').promises;
|
||||
const path = require('path');
|
||||
|
||||
const KEEP_DAYS = 30;
|
||||
const ARCHIVE_PATH = '.github/changelogs';
|
||||
const CHANGELOG_PATH = 'CHANGELOG.md';
|
||||
|
||||
// Calculate cutoff date
|
||||
const cutoffDate = new Date();
|
||||
cutoffDate.setDate(cutoffDate.getDate() - KEEP_DAYS);
|
||||
cutoffDate.setHours(0, 0, 0, 0);
|
||||
|
||||
console.log(`Cutoff date: ${cutoffDate.toISOString().split('T')[0]}`);
|
||||
|
||||
// Read changelog and normalize line endings
|
||||
let content = await fs.readFile(CHANGELOG_PATH, 'utf-8');
|
||||
content = content.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||
const lines = content.split('\n');
|
||||
|
||||
// Parse entries
|
||||
const datePattern = /^## (\d{4})-(\d{2})-(\d{2})$/;
|
||||
let header = [];
|
||||
let recentEntries = [];
|
||||
let archiveData = {};
|
||||
let currentDate = null;
|
||||
let currentContent = [];
|
||||
let inHeader = true;
|
||||
let inOldHistory = false;
|
||||
let historyDetailsDepth = 0;
|
||||
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
const line = lines[i];
|
||||
const match = line.match(datePattern);
|
||||
|
||||
// Detect the start of History section: <details> followed by line with 📜 History
|
||||
if (inHeader && !inOldHistory && line.trim() === '<details>') {
|
||||
// Look ahead to see if this is the History section
|
||||
const nextLine = lines[i + 1] || '';
|
||||
if (nextLine.includes('📜 History')) {
|
||||
inOldHistory = true;
|
||||
historyDetailsDepth = 1;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Track nested details tags to find the end of History section
|
||||
if (inOldHistory) {
|
||||
if (line.trim() === '<details>') {
|
||||
historyDetailsDepth++;
|
||||
}
|
||||
if (line.trim() === '</details>') {
|
||||
historyDetailsDepth--;
|
||||
if (historyDetailsDepth === 0) {
|
||||
// We've closed the main History details tag
|
||||
inOldHistory = false;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (match) {
|
||||
inHeader = false;
|
||||
|
||||
// Save previous entry
|
||||
if (currentDate && currentContent.length > 0) {
|
||||
const entryText = currentContent.join('\n').trim();
|
||||
const dateObj = new Date(`${currentDate}T00:00:00Z`);
|
||||
|
||||
// Always add to archive (by month)
|
||||
const year = currentDate.substring(0, 4);
|
||||
const month = currentDate.substring(5, 7);
|
||||
|
||||
if (!archiveData[year]) archiveData[year] = {};
|
||||
if (!archiveData[year][month]) archiveData[year][month] = [];
|
||||
|
||||
archiveData[year][month].push(`## ${currentDate}\n\n${entryText}`);
|
||||
|
||||
// Also add to recent entries if within cutoff
|
||||
if (dateObj >= cutoffDate) {
|
||||
recentEntries.push(`## ${currentDate}\n\n${entryText}`);
|
||||
}
|
||||
}
|
||||
|
||||
currentDate = `${match[1]}-${match[2]}-${match[3]}`;
|
||||
currentContent = [];
|
||||
} else if (inHeader) {
|
||||
header.push(line);
|
||||
} else if (currentDate) {
|
||||
currentContent.push(line);
|
||||
}
|
||||
}
|
||||
|
||||
// Don't forget the last entry
|
||||
if (currentDate && currentContent.length > 0) {
|
||||
const entryText = currentContent.join('\n').trim();
|
||||
const dateObj = new Date(`${currentDate}T00:00:00Z`);
|
||||
|
||||
// Always add to archive (by month)
|
||||
const year = currentDate.substring(0, 4);
|
||||
const month = currentDate.substring(5, 7);
|
||||
|
||||
if (!archiveData[year]) archiveData[year] = {};
|
||||
if (!archiveData[year][month]) archiveData[year][month] = [];
|
||||
|
||||
archiveData[year][month].push(`## ${currentDate}\n\n${entryText}`);
|
||||
|
||||
// Also add to recent entries if within cutoff
|
||||
if (dateObj >= cutoffDate) {
|
||||
recentEntries.push(`## ${currentDate}\n\n${entryText}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`Recent entries: ${recentEntries.length}`);
|
||||
console.log(`Years to archive: ${Object.keys(archiveData).length}`);
|
||||
|
||||
// Month names in English
|
||||
const monthNames = {
|
||||
'01': 'January', '02': 'February', '03': 'March', '04': 'April',
|
||||
'05': 'May', '06': 'June', '07': 'July', '08': 'August',
|
||||
'09': 'September', '10': 'October', '11': 'November', '12': 'December'
|
||||
};
|
||||
|
||||
// Create/update archive files
|
||||
for (const year of Object.keys(archiveData).sort().reverse()) {
|
||||
const yearPath = path.join(ARCHIVE_PATH, year);
|
||||
|
||||
try {
|
||||
await fs.mkdir(yearPath, { recursive: true });
|
||||
} catch (e) {
|
||||
// Directory exists
|
||||
}
|
||||
|
||||
for (const month of Object.keys(archiveData[year]).sort().reverse()) {
|
||||
const monthPath = path.join(yearPath, `${month}.md`);
|
||||
|
||||
// Read existing content if exists
|
||||
let existingContent = '';
|
||||
try {
|
||||
existingContent = await fs.readFile(monthPath, 'utf-8');
|
||||
// Normalize line endings to prevent regex issues
|
||||
existingContent = existingContent.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||
} catch (e) {
|
||||
// File doesn't exist
|
||||
}
|
||||
|
||||
// Parse existing entries into a Map (date -> content) for deduplication
|
||||
const allEntries = new Map();
|
||||
|
||||
// Helper function to parse entries from content
|
||||
const parseEntries = (content) => {
|
||||
const entries = new Map();
|
||||
const parts = content.split(/(?=^## \d{4}-\d{2}-\d{2}$)/m);
|
||||
for (const part of parts) {
|
||||
const trimmed = part.trim();
|
||||
if (!trimmed) continue;
|
||||
const dateMatch = trimmed.match(/^## (\d{4}-\d{2}-\d{2})/);
|
||||
if (dateMatch) {
|
||||
entries.set(dateMatch[1], trimmed);
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
};
|
||||
|
||||
// Parse existing content
|
||||
if (existingContent) {
|
||||
const existingEntries = parseEntries(existingContent);
|
||||
for (const [date, content] of existingEntries) {
|
||||
allEntries.set(date, content);
|
||||
}
|
||||
}
|
||||
|
||||
// Add new entries (existing entries take precedence to avoid overwriting)
|
||||
let addedCount = 0;
|
||||
for (const entry of archiveData[year][month]) {
|
||||
const dateMatch = entry.match(/^## (\d{4}-\d{2}-\d{2})/);
|
||||
if (dateMatch && !allEntries.has(dateMatch[1])) {
|
||||
allEntries.set(dateMatch[1], entry.trim());
|
||||
addedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort entries by date (newest first) and write
|
||||
const sortedDates = [...allEntries.keys()].sort().reverse();
|
||||
const sortedContent = sortedDates.map(date => allEntries.get(date)).join('\n\n');
|
||||
|
||||
if (addedCount > 0 || !existingContent) {
|
||||
await fs.writeFile(monthPath, sortedContent + '\n', 'utf-8');
|
||||
console.log(`Updated: ${monthPath} (${allEntries.size} total entries, +${addedCount} new)`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Build history section
|
||||
let historySection = [];
|
||||
historySection.push('');
|
||||
historySection.push('<details>');
|
||||
historySection.push('<summary><h2>📜 History</h2></summary>');
|
||||
historySection.push('');
|
||||
|
||||
// Get all years from archive directory
|
||||
let allYears = [];
|
||||
try {
|
||||
const archiveDir = await fs.readdir(ARCHIVE_PATH);
|
||||
allYears = archiveDir.filter(f => /^\d{4}$/.test(f)).sort().reverse();
|
||||
} catch (e) {
|
||||
allYears = Object.keys(archiveData).sort().reverse();
|
||||
}
|
||||
|
||||
for (const year of allYears) {
|
||||
historySection.push('');
|
||||
historySection.push('<details>');
|
||||
historySection.push(`<summary><h3>${year}</h3></summary>`);
|
||||
historySection.push('');
|
||||
|
||||
// Get months for this year
|
||||
let months = [];
|
||||
try {
|
||||
const yearDir = await fs.readdir(path.join(ARCHIVE_PATH, year));
|
||||
months = yearDir
|
||||
.filter(f => f.endsWith('.md'))
|
||||
.map(f => f.replace('.md', ''))
|
||||
.sort()
|
||||
.reverse();
|
||||
} catch (e) {
|
||||
months = Object.keys(archiveData[year] || {}).sort().reverse();
|
||||
}
|
||||
|
||||
for (const month of months) {
|
||||
const monthName = monthNames[month] || month;
|
||||
const monthPath = path.join(ARCHIVE_PATH, year, `${month}.md`);
|
||||
|
||||
// Count entries in month file
|
||||
let entryCount = 0;
|
||||
try {
|
||||
let monthContent = await fs.readFile(monthPath, 'utf-8');
|
||||
monthContent = monthContent.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
||||
entryCount = (monthContent.match(/^## \d{4}-\d{2}-\d{2}$/gm) || []).length;
|
||||
} catch (e) {
|
||||
entryCount = (archiveData[year]?.[month] || []).length;
|
||||
}
|
||||
|
||||
const relativePath = `.github/changelogs/${year}/${month}.md`;
|
||||
historySection.push('');
|
||||
historySection.push('<details>');
|
||||
historySection.push(`<summary><h4>${monthName} (${entryCount} entries)</h4></summary>`);
|
||||
historySection.push('');
|
||||
historySection.push(`[View ${monthName} ${year} Changelog](${relativePath})`);
|
||||
historySection.push('');
|
||||
historySection.push('</details>');
|
||||
}
|
||||
|
||||
historySection.push('');
|
||||
historySection.push('</details>');
|
||||
}
|
||||
|
||||
historySection.push('');
|
||||
historySection.push('</details>');
|
||||
|
||||
// Build new CHANGELOG.md (History first, then recent entries)
|
||||
const newChangelog = [
|
||||
...header,
|
||||
'',
|
||||
historySection.join('\n'),
|
||||
'',
|
||||
recentEntries.join('\n\n')
|
||||
].join('\n');
|
||||
|
||||
await fs.writeFile(CHANGELOG_PATH, newChangelog, 'utf-8');
|
||||
console.log('CHANGELOG.md updated successfully');
|
||||
|
||||
- name: Check for changes
|
||||
run: |
|
||||
if [ -n "$(git status --porcelain CHANGELOG.md .github/changelogs)" ]; then
|
||||
if [ "$DRY_RUN" = "true" ]; then
|
||||
echo "Dry run: not committing. Pending changes:"
|
||||
git status --short CHANGELOG.md .github/changelogs
|
||||
git --no-pager diff --stat
|
||||
git --no-pager diff -- CHANGELOG.md | head -n 200
|
||||
else
|
||||
echo "changed=true" >> $GITHUB_ENV
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Commit and push changes
|
||||
if: env.changed == 'true'
|
||||
run: |
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git add CHANGELOG.md .github/changelogs/
|
||||
git commit -m "Update CHANGELOG.md"
|
||||
git checkout -b $BRANCH_NAME || git checkout $BRANCH_NAME
|
||||
git push origin $BRANCH_NAME --force
|
||||
echo "HEAD_SHA=$(git rev-parse HEAD)" >> "$GITHUB_ENV"
|
||||
|
||||
- name: Create pull request if not exists
|
||||
if: env.changed == 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
|
||||
run: |
|
||||
PR_EXISTS=$(gh pr list --head "${BRANCH_NAME}" --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository == false)][0].number // empty')
|
||||
if [ -z "$PR_EXISTS" ]; then
|
||||
gh pr create --title "[Github Action] Update CHANGELOG.md" \
|
||||
--body "This PR is auto-generated by a Github Action to update the CHANGELOG.md file. It is updated on every merge to main and merged automatically at 00:01 UTC together with the day's release. To fix an entry, rename the pull request it comes from; edits to this branch are overwritten." \
|
||||
--head $BRANCH_NAME \
|
||||
--base main \
|
||||
--label "$AUTOMATED_PR_LABEL"
|
||||
fi
|
||||
|
||||
- name: Approve pull request
|
||||
if: env.changed == 'true' && env.MODE == 'finalize'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository == false)][0].number // empty')
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
gh pr review "$PR_NUMBER" --approve
|
||||
fi
|
||||
|
||||
- name: Approve pull request and merge
|
||||
if: env.changed == 'true' && env.MODE == 'finalize'
|
||||
env:
|
||||
GH_TOKEN: ${{ steps.generate-token-merge.outputs.token }}
|
||||
run: |
|
||||
git config --global user.name "github-actions-automege[bot]"
|
||||
git config --global user.email "github-actions-automege[bot]@users.noreply.github.com"
|
||||
PR_NUMBER=$(gh pr list --head "${BRANCH_NAME}" --state open --json number,isCrossRepository --jq '[.[] | select(.isCrossRepository == false)][0].number // empty')
|
||||
if [ -n "$PR_NUMBER" ]; then
|
||||
gh pr review "$PR_NUMBER" --approve
|
||||
gh pr merge "$PR_NUMBER" --squash --admin --match-head-commit "$HEAD_SHA"
|
||||
fi
|
||||
Generated
-69
@@ -1,69 +0,0 @@
|
||||
name: Create Daily Release
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '1 0 * * *' # Runs daily at 00:01 UTC
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
create-daily-release:
|
||||
if: github.repository == 'community-scripts/ProxmoxVE'
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Clean CHANGELOG (remove HTML header)
|
||||
run: sed -n '/^## /,$p' CHANGELOG.md > changelog_cleaned.md
|
||||
|
||||
- name: Extract relevant changelog section
|
||||
id: extract
|
||||
run: |
|
||||
YESTERDAY=$(date -u --date="yesterday" +%Y-%m-%d)
|
||||
echo "Checking for changes on: $YESTERDAY"
|
||||
|
||||
# Extract the section from "## $YESTERDAY" until the next "## YYYY-MM-DD"
|
||||
sed -n "/^## $YESTERDAY/,/^## [0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}/p" changelog_cleaned.md | head -n -1 > changelog_tmp_full.md
|
||||
|
||||
# GitHub fills a release's Contributors only from bare @login mentions
|
||||
sed -i -E 's#\[@([A-Za-z0-9-]+)\]\(https://github\.com/\1\)#@\1#g' changelog_tmp_full.md
|
||||
|
||||
# Keep whole lines up to 120000 characters (GitHub allows 125000)
|
||||
export LC_ALL=C.UTF-8
|
||||
SIZE=0
|
||||
TRUNCATED=false
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
SIZE=$((SIZE + ${#line} + 1))
|
||||
if [ "$SIZE" -gt 120000 ]; then
|
||||
TRUNCATED=true
|
||||
break
|
||||
fi
|
||||
printf '%s\n' "$line"
|
||||
done < changelog_tmp_full.md > changelog_tmp.md
|
||||
if [ "$TRUNCATED" = true ]; then
|
||||
printf '\nCut to fit the release size limit. The full list is in [CHANGELOG.md](https://github.com/community-scripts/ProxmoxVE/blob/main/CHANGELOG.md).\n' >> changelog_tmp.md
|
||||
fi
|
||||
|
||||
echo "=== Extracted Changelog ==="
|
||||
cat changelog_tmp.md
|
||||
echo "==========================="
|
||||
|
||||
# Abort if no content was found
|
||||
if [ ! -s changelog_tmp.md ]; then
|
||||
echo "No changes found for $YESTERDAY, skipping release."
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
- name: Create GitHub release
|
||||
if: steps.extract.outputs.skip != 'true'
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
YESTERDAY=$(date -u --date="yesterday" +%Y-%m-%d)
|
||||
PREVIOUS=$(gh release view --json tagName --jq .tagName 2>/dev/null || true)
|
||||
if [ -n "$PREVIOUS" ]; then
|
||||
printf '\n**Full Changelog**: https://github.com/community-scripts/ProxmoxVE/compare/%s...%s\n' "$PREVIOUS" "$YESTERDAY" >> changelog_tmp.md
|
||||
fi
|
||||
gh release create "$YESTERDAY" -t "$YESTERDAY" -F changelog_tmp.md
|
||||
@@ -597,6 +597,34 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit
|
||||
- Docling-Serve [@MickLesk](https://github.com/MickLesk) ([#19237](https://github.com/community-scripts/ProxmoxVE/pull/19237))
|
||||
- Kopia [@MickLesk](https://github.com/MickLesk) ([#19238](https://github.com/community-scripts/ProxmoxVE/pull/19238))
|
||||
|
||||
### 🚀 Updated Scripts
|
||||
|
||||
- #### 🐞 Bug Fixes
|
||||
|
||||
- n8n: update with an empty npm cache and the service stopped [@MickLesk](https://github.com/MickLesk) ([#19262](https://github.com/community-scripts/ProxmoxVE/pull/19262))
|
||||
- Pterodactyl Panel: switch PHP with setup_php [@MickLesk](https://github.com/MickLesk) ([#19255](https://github.com/community-scripts/ProxmoxVE/pull/19255))
|
||||
- Frigate: fetch the Intel key for install_deps with retries [@MickLesk](https://github.com/MickLesk) ([#19253](https://github.com/community-scripts/ProxmoxVE/pull/19253))
|
||||
- ERPNext: raise the default RAM to 6 GB [@MickLesk](https://github.com/MickLesk) ([#19252](https://github.com/community-scripts/ProxmoxVE/pull/19252))
|
||||
- Aurral: build without the exact Node minor check [@MickLesk](https://github.com/MickLesk) ([#19251](https://github.com/community-scripts/ProxmoxVE/pull/19251))
|
||||
- Dreeve: follow FrankenPHP releases for PHP 8.6 [@MickLesk](https://github.com/MickLesk) ([#19250](https://github.com/community-scripts/ProxmoxVE/pull/19250))
|
||||
- cross-seed: reinstall when a Node.js upgrade broke better-sqlite3 [@MickLesk](https://github.com/MickLesk) ([#19249](https://github.com/community-scripts/ProxmoxVE/pull/19249))
|
||||
- Dispatcharr: consume the plugins and dvr queues like upstream [@MickLesk](https://github.com/MickLesk) ([#19248](https://github.com/community-scripts/ProxmoxVE/pull/19248))
|
||||
|
||||
- #### 🔧 Refactor
|
||||
|
||||
- Martin: Refactor - use the legacycpu build on CPUs below x86-64-v3 [@MickLesk](https://github.com/MickLesk) ([#19264](https://github.com/community-scripts/ProxmoxVE/pull/19264))
|
||||
- Sure: set SECRET_KEY_BASE whatever the example holds [@MickLesk](https://github.com/MickLesk) ([#19258](https://github.com/community-scripts/ProxmoxVE/pull/19258))
|
||||
|
||||
### 🧰 Tools
|
||||
|
||||
- #### ✨ New Features
|
||||
|
||||
- [tools.update-lxcs] feat: optional CLEAN_CACHE to remove downloaded packages after each update [@mattstein111](https://github.com/mattstein111) ([#19192](https://github.com/community-scripts/ProxmoxVE/pull/19192))
|
||||
|
||||
### 📂 Github
|
||||
|
||||
- refactor(ci): merge changelog, archive and release workflows into one daily run [@CrazyWolf13](https://github.com/CrazyWolf13) ([#19190](https://github.com/community-scripts/ProxmoxVE/pull/19190))
|
||||
|
||||
## 2026-12-01
|
||||
|
||||
### 🆕 New Scripts
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ function update_script() {
|
||||
export VITE_GITHUB_REPO="lklynet/aurral"
|
||||
export VITE_RELEASE_CHANNEL="stable"
|
||||
$STD pnpm install --frozen-lockfile --config.engine-strict=false --filter aurral-frontend --filter aurral-backend
|
||||
$STD pnpm --filter aurral-frontend run build
|
||||
$STD pnpm --config.engine-strict=false --filter aurral-frontend run build
|
||||
mkdir -p /opt/aurral_data
|
||||
cat <<EOF >/opt/aurral/aurral.env
|
||||
NODE_ENV=production
|
||||
|
||||
+6
-1
@@ -30,13 +30,18 @@ function update_script() {
|
||||
ensure_dependencies build-essential
|
||||
|
||||
if command -v cross-seed &>/dev/null; then
|
||||
current_version=$(cross-seed --version)
|
||||
current_version=$(node -p "require('$(npm root -g)/cross-seed/package.json').version")
|
||||
latest_version=$(npm show cross-seed version)
|
||||
if [ "$current_version" != "$latest_version" ]; then
|
||||
msg_info "Updating cross-seed from version v${current_version} to v${latest_version}"
|
||||
$STD npm install -g cross-seed@latest
|
||||
systemctl restart cross-seed
|
||||
msg_ok "Updated successfully!"
|
||||
elif ! cross-seed --version &>/dev/null; then
|
||||
msg_info "Reinstalling cross-seed v${current_version} for Node.js $(node -v)"
|
||||
$STD npm install -g "cross-seed@${current_version}"
|
||||
systemctl restart cross-seed
|
||||
msg_ok "Reinstalled cross-seed"
|
||||
else
|
||||
msg_ok "cross-seed is already at v${current_version}"
|
||||
fi
|
||||
|
||||
+45
-1
@@ -117,9 +117,52 @@ EOF
|
||||
msg_ok "Compiled and Installed Comskip"
|
||||
fi
|
||||
|
||||
if ! grep -qs -- "-Q celery,plugins" /opt/dispatcharr/start-celery.sh; then
|
||||
msg_info "Migrating Celery Workers"
|
||||
cat <<'EOF' >/opt/dispatcharr/start-celery.sh
|
||||
#!/usr/bin/env bash
|
||||
cd /opt/dispatcharr
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
exec uv run celery -A dispatcharr worker -l info -Q celery,plugins -n default@%h --autoscale="${CELERY_MAX_WORKERS:-6},${CELERY_MIN_WORKERS:-1}"
|
||||
EOF
|
||||
cat <<'EOF' >/opt/dispatcharr/start-celery-dvr.sh
|
||||
#!/usr/bin/env bash
|
||||
cd /opt/dispatcharr
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
exec uv run celery -A dispatcharr worker -l info -Q dvr -n dvr@%h --pool=threads --concurrency=20
|
||||
EOF
|
||||
chmod +x /opt/dispatcharr/start-celery.sh /opt/dispatcharr/start-celery-dvr.sh
|
||||
cat <<EOF >/etc/systemd/system/dispatcharr-celery-dvr.service
|
||||
[Unit]
|
||||
Description=Dispatcharr Celery DVR Worker
|
||||
After=network.target redis-server.service
|
||||
Requires=dispatcharr.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/opt/dispatcharr
|
||||
ExecStart=/opt/dispatcharr/start-celery-dvr.sh
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl daemon-reload
|
||||
systemctl enable -q --now dispatcharr-celery-dvr
|
||||
systemctl restart dispatcharr-celery
|
||||
msg_ok "Migrated Celery Workers"
|
||||
fi
|
||||
|
||||
if check_for_gh_release "Dispatcharr" "Dispatcharr/Dispatcharr"; then
|
||||
msg_info "Stopping Services"
|
||||
systemctl stop dispatcharr-celery
|
||||
systemctl stop dispatcharr-celery-dvr
|
||||
systemctl stop dispatcharr-celerybeat
|
||||
systemctl stop dispatcharr-daphne
|
||||
systemctl stop dispatcharr
|
||||
@@ -130,7 +173,7 @@ EOF
|
||||
if [[ -f /opt/dispatcharr/start-gunicorn.sh ]]; then
|
||||
rm -f /opt/dispatcharr/start-gunicorn.sh
|
||||
fi
|
||||
create_backup /opt/dispatcharr/.env /opt/dispatcharr/start-celery.sh /opt/dispatcharr/start-celerybeat.sh /opt/dispatcharr/start-daphne.sh
|
||||
create_backup /opt/dispatcharr/.env /opt/dispatcharr/start-celery.sh /opt/dispatcharr/start-celery-dvr.sh /opt/dispatcharr/start-celerybeat.sh /opt/dispatcharr/start-daphne.sh
|
||||
if [[ -f /opt/dispatcharr/.env ]]; then
|
||||
set -o allexport
|
||||
source /opt/dispatcharr/.env
|
||||
@@ -213,6 +256,7 @@ EOF
|
||||
msg_info "Starting Services"
|
||||
systemctl start dispatcharr
|
||||
systemctl start dispatcharr-celery
|
||||
systemctl start dispatcharr-celery-dvr
|
||||
systemctl start dispatcharr-celerybeat
|
||||
systemctl start dispatcharr-daphne
|
||||
msg_ok "Started Services"
|
||||
|
||||
@@ -31,6 +31,18 @@ function update_script() {
|
||||
exit
|
||||
fi
|
||||
|
||||
if check_for_gh_release "frankenphp" "php/frankenphp"; then
|
||||
msg_info "Stopping Service"
|
||||
systemctl stop dreeve
|
||||
msg_ok "Stopped Service"
|
||||
|
||||
fetch_and_deploy_gh_release "frankenphp" "php/frankenphp" "singlefile" "latest" "/opt/frankenphp" "frankenphp-linux-$(arch_resolve x86_64 aarch64)-gnu"
|
||||
|
||||
msg_info "Starting Service"
|
||||
systemctl start dreeve
|
||||
msg_ok "Started Service"
|
||||
fi
|
||||
|
||||
if check_for_gh_release "dreeve" "dreeveapp/dreeve"; then
|
||||
msg_info "Stopping Service"
|
||||
systemctl stop dreeve
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@ source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_
|
||||
APP="ERPNext"
|
||||
var_tags="${var_tags:-erp;business;accounting}"
|
||||
var_cpu="${var_cpu:-4}"
|
||||
var_ram="${var_ram:-4096}"
|
||||
var_ram="${var_ram:-6144}"
|
||||
var_disk="${var_disk:-20}"
|
||||
var_os="${var_os:-debian}"
|
||||
var_version="${var_version:-13}"
|
||||
|
||||
+8
-1
@@ -36,7 +36,14 @@ function update_script() {
|
||||
systemctl stop martin
|
||||
msg_ok "Stopped Martin"
|
||||
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "martin" "maplibre/martin" "prebuild" "latest" "/opt/martin" "martin-$(arch_resolve "x86_64" "aarch64")-unknown-linux-musl.tar.gz"
|
||||
if [[ "$(cat ~/.martin 2>/dev/null)" =~ (^|[^0-9])1\.[0-9] ]]; then
|
||||
msg_warn "Martin 2.0 drops settings 1.x deprecated and needs PostgreSQL 15 and PostGIS 3.5 for database sources: https://maplibre.org/martin/migration-guide/"
|
||||
fi
|
||||
MARTIN_ASSET="martin-$(arch_resolve "x86_64" "aarch64")-unknown-linux-musl.tar.gz"
|
||||
if [[ "$(arch_resolve)" == "amd64" ]] && ! { grep -qw avx2 /proc/cpuinfo && grep -qw bmi2 /proc/cpuinfo && grep -qw fma /proc/cpuinfo && grep -qw movbe /proc/cpuinfo; }; then
|
||||
MARTIN_ASSET="martin-x86_64-unknown-linux-musl-legacycpu.tar.gz"
|
||||
fi
|
||||
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "martin" "maplibre/martin" "prebuild" "latest" "/opt/martin" "$MARTIN_ASSET"
|
||||
|
||||
msg_info "Starting Martin"
|
||||
systemctl start martin
|
||||
|
||||
@@ -49,8 +49,11 @@ EOF
|
||||
# n8n-nodes-base 2.46.0 pins both @napi-rs/canvas musl binaries as hard
|
||||
# dependencies, which no os/cpu/libc combination can satisfy. Drop --force
|
||||
# once upstream makes them optional again.
|
||||
# prevent excessive ram use by clearing cache
|
||||
systemctl stop n8n
|
||||
$STD npm cache clean --force
|
||||
$STD npm install -g n8n@latest --force
|
||||
systemctl restart n8n
|
||||
systemctl start n8n
|
||||
msg_ok "Updated n8n"
|
||||
msg_ok "Updated successfully!"
|
||||
exit
|
||||
|
||||
+1
-23
@@ -30,29 +30,7 @@ function update_script() {
|
||||
exit
|
||||
fi
|
||||
setup_mariadb
|
||||
CURRENT_PHP=$(php -v 2>/dev/null | awk '/^PHP/{print $2}' | cut -d. -f1,2)
|
||||
|
||||
if [[ "$CURRENT_PHP" != "8.4" ]]; then
|
||||
msg_info "Migrating PHP $CURRENT_PHP to 8.4"
|
||||
$STD curl -fsSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
|
||||
$STD dpkg -i /tmp/debsuryorg-archive-keyring.deb
|
||||
$STD sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
|
||||
cat <<EOF >/etc/apt/sources.list.d/php.sources
|
||||
Types: deb
|
||||
URIs: https://packages.sury.org/php/
|
||||
Suites: $(lsb_release -sc)
|
||||
Components: main
|
||||
Signed-By: /usr/share/keyrings/deb.sury.org-php.gpg
|
||||
EOF
|
||||
apt_update_safe
|
||||
$STD apt remove -y php"${CURRENT_PHP//./}"*
|
||||
$STD apt install -y \
|
||||
php8.4 \
|
||||
php8.4-{gd,mysql,mbstring,bcmath,xml,curl,zip,intl,fpm} \
|
||||
libapache2-mod-php8.4
|
||||
|
||||
msg_ok "Migrated PHP $CURRENT_PHP to 8.4"
|
||||
fi
|
||||
PHP_VERSION="8.4" PHP_APACHE="YES" PHP_FPM="YES" PHP_MODULE="mysql" setup_php
|
||||
|
||||
if [[ -f /opt/${APP}_version.txt ]]; then
|
||||
mv /opt/"${APP}_version.txt" ~/.pterodactyl-panel
|
||||
|
||||
@@ -34,7 +34,7 @@ export VITE_APP_VERSION="$(cat ~/.aurral)"
|
||||
export VITE_GITHUB_REPO="lklynet/aurral"
|
||||
export VITE_RELEASE_CHANNEL="stable"
|
||||
$STD pnpm install --frozen-lockfile --config.engine-strict=false --filter aurral-frontend --filter aurral-backend
|
||||
$STD pnpm --filter aurral-frontend run build
|
||||
$STD pnpm --config.engine-strict=false --filter aurral-frontend run build
|
||||
msg_ok "Built Aurral"
|
||||
|
||||
msg_info "Creating Service"
|
||||
|
||||
@@ -185,16 +185,26 @@ exec .venv/bin/uwsgi \\
|
||||
EOF
|
||||
chmod +x /opt/dispatcharr/start-uwsgi.sh
|
||||
|
||||
cat <<EOF >/opt/dispatcharr/start-celery.sh
|
||||
cat <<'EOF' >/opt/dispatcharr/start-celery.sh
|
||||
#!/usr/bin/env bash
|
||||
cd /opt/dispatcharr
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
exec uv run celery -A dispatcharr worker -l info -c 4 -Q celery,recordings,dvr,default
|
||||
exec uv run celery -A dispatcharr worker -l info -Q celery,plugins -n default@%h --autoscale="${CELERY_MAX_WORKERS:-6},${CELERY_MIN_WORKERS:-1}"
|
||||
EOF
|
||||
chmod +x /opt/dispatcharr/start-celery.sh
|
||||
|
||||
cat <<'EOF' >/opt/dispatcharr/start-celery-dvr.sh
|
||||
#!/usr/bin/env bash
|
||||
cd /opt/dispatcharr
|
||||
set -a
|
||||
source .env
|
||||
set +a
|
||||
exec uv run celery -A dispatcharr worker -l info -Q dvr -n dvr@%h --pool=threads --concurrency=20
|
||||
EOF
|
||||
chmod +x /opt/dispatcharr/start-celery-dvr.sh
|
||||
|
||||
cat <<EOF >/opt/dispatcharr/start-celerybeat.sh
|
||||
#!/usr/bin/env bash
|
||||
cd /opt/dispatcharr
|
||||
@@ -250,6 +260,24 @@ User=root
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
cat <<EOF >/etc/systemd/system/dispatcharr-celery-dvr.service
|
||||
[Unit]
|
||||
Description=Dispatcharr Celery DVR Worker
|
||||
After=network.target redis-server.service
|
||||
Requires=dispatcharr.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/opt/dispatcharr
|
||||
ExecStart=/opt/dispatcharr/start-celery-dvr.sh
|
||||
Restart=on-failure
|
||||
RestartSec=10
|
||||
User=root
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
cat <<EOF >/etc/systemd/system/dispatcharr-celerybeat.service
|
||||
[Unit]
|
||||
Description=Dispatcharr Celery Beat Scheduler
|
||||
@@ -285,7 +313,7 @@ User=root
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable -q --now dispatcharr dispatcharr-celery dispatcharr-celerybeat dispatcharr-daphne
|
||||
systemctl enable -q --now dispatcharr dispatcharr-celery dispatcharr-celery-dvr dispatcharr-celerybeat dispatcharr-daphne
|
||||
msg_ok "Created Services"
|
||||
|
||||
motd_ssh
|
||||
|
||||
@@ -20,8 +20,7 @@ $STD apt install -y \
|
||||
ca-certificates
|
||||
msg_ok "Installed Dependencies"
|
||||
|
||||
# 1.13.0's php-cli shifts the script into argv[1], which breaks composer and bin/console (php/frankenphp#2690); unpin once 1.13.1 is out
|
||||
fetch_and_deploy_gh_release "frankenphp" "php/frankenphp" "singlefile" "v1.12.7" "/opt/frankenphp" "frankenphp-linux-$(arch_resolve x86_64 aarch64)-gnu"
|
||||
fetch_and_deploy_gh_release "frankenphp" "php/frankenphp" "singlefile" "latest" "/opt/frankenphp" "frankenphp-linux-$(arch_resolve x86_64 aarch64)-gnu"
|
||||
fetch_and_deploy_gh_release "dreeve" "dreeveapp/dreeve" "tarball"
|
||||
|
||||
msg_info "Providing php CLI"
|
||||
|
||||
@@ -224,6 +224,9 @@ sed -i '/^.*unset DEBIAN_FRONTEND.*$/d' /opt/frigate/docker/main/install_deps.sh
|
||||
echo "libedgetpu1-max libedgetpu/accepted-eula boolean true" | debconf-set-selections
|
||||
echo "libedgetpu1-max libedgetpu/install-confirm-max boolean true" | debconf-set-selections
|
||||
echo 'force-overwrite' >/etc/dpkg/dpkg.cfg.d/force-overwrite
|
||||
if [[ "$(arch_resolve)" == "amd64" ]] && download_gpg_key "https://repositories.intel.com/gpu/intel-graphics.key" "/usr/share/keyrings/intel-graphics.gpg" "dearmor"; then
|
||||
sed -i '/intel-graphics.key/d' /opt/frigate/docker/main/install_deps.sh
|
||||
fi
|
||||
$STD bash /opt/frigate/docker/main/install_deps.sh
|
||||
rm -f /etc/dpkg/dpkg.cfg.d/force-overwrite
|
||||
$STD pip3 install -U /wheels/*.whl
|
||||
|
||||
@@ -13,7 +13,12 @@ setting_up_container
|
||||
network_check
|
||||
update_os
|
||||
|
||||
fetch_and_deploy_gh_release "martin" "maplibre/martin" "prebuild" "latest" "/opt/martin" "martin-$(arch_resolve "x86_64" "aarch64")-unknown-linux-musl.tar.gz"
|
||||
# Martin 2.x builds for x86_64 need an x86-64-v3 CPU; older ones get the legacycpu build.
|
||||
MARTIN_ASSET="martin-$(arch_resolve "x86_64" "aarch64")-unknown-linux-musl.tar.gz"
|
||||
if [[ "$(arch_resolve)" == "amd64" ]] && ! { grep -qw avx2 /proc/cpuinfo && grep -qw bmi2 /proc/cpuinfo && grep -qw fma /proc/cpuinfo && grep -qw movbe /proc/cpuinfo; }; then
|
||||
MARTIN_ASSET="martin-x86_64-unknown-linux-musl-legacycpu.tar.gz"
|
||||
fi
|
||||
fetch_and_deploy_gh_release "martin" "maplibre/martin" "prebuild" "latest" "/opt/martin" "$MARTIN_ASSET"
|
||||
|
||||
msg_info "Configuring Martin"
|
||||
mkdir -p /opt/martin_data/tiles
|
||||
|
||||
@@ -44,7 +44,7 @@ msg_info "Configuring Sure"
|
||||
KEY="$(openssl rand -hex 64)"
|
||||
mkdir -p /etc/sure
|
||||
mv /opt/sure/.env.example /etc/sure/.env
|
||||
sed -i -e "/^SECRET_KEY_BASE=/s/secret-value/${KEY}/" \
|
||||
sed -i -e "s/^SECRET_KEY_BASE=.*/SECRET_KEY_BASE=${KEY}/" \
|
||||
-e 's/_KEY_BASE=.*$/&\n\nRAILS_FORCE_SSL=false \
|
||||
\
|
||||
# Change to true when using a reverse proxy \
|
||||
|
||||
@@ -119,6 +119,11 @@ EXCLUDE=
|
||||
|
||||
# Healthchecks.io Ping URL (optional)
|
||||
# PING_URL=
|
||||
|
||||
# Remove downloaded packages after each successful update (optional).
|
||||
# Without it, apt and the other package managers keep every package they
|
||||
# download, and the cache grows on each run until the container's disk fills.
|
||||
# CLEAN_CACHE=yes
|
||||
CONF
|
||||
ok "Created config ${CONF_FILE}"
|
||||
fi
|
||||
|
||||
@@ -13,6 +13,7 @@ export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
||||
CONF_FILE="/etc/update-lxcs.conf"
|
||||
LOG_FILE="/var/log/update-lxcs-cron.log"
|
||||
PING_URL=""
|
||||
CLEAN_CACHE=""
|
||||
|
||||
# Collect excluded containers from arguments
|
||||
excluded_containers=("$@")
|
||||
@@ -20,6 +21,7 @@ excluded_containers=("$@")
|
||||
# Merge exclusions and healthchecks URL from config file if it exists
|
||||
if [[ -f "$CONF_FILE" ]]; then
|
||||
PING_URL=$(grep -oP '^\s*PING_URL\s*=\s*\K.+' "$CONF_FILE" 2>/dev/null | tr -d '"' | tr -d "'" || true)
|
||||
CLEAN_CACHE=$(grep -oP '^\s*CLEAN_CACHE\s*=\s*\K.+' "$CONF_FILE" 2>/dev/null | tr -d '"' | tr -d "'" || true)
|
||||
conf_exclude=$(grep -oP '^\s*EXCLUDE\s*=\s*\K[0-9,]+' "$CONF_FILE" 2>/dev/null || true)
|
||||
IFS=',' read -ra conf_ids <<<"$conf_exclude"
|
||||
for id in "${conf_ids[@]}"; do
|
||||
@@ -39,6 +41,22 @@ fi
|
||||
|
||||
echo -e "\n $(date)"
|
||||
|
||||
# Remove downloaded package files after a successful update (CLEAN_CACHE=yes).
|
||||
# The upgrade commands keep every package they download, so without this the
|
||||
# cache grows on every run until the container's disk is full.
|
||||
function clean_container() {
|
||||
local container=$1
|
||||
local os=$2
|
||||
echo -e " [Info] Cleaning package cache in $container"
|
||||
case "$os" in
|
||||
alpine) pct exec "$container" -- ash -c "apk cache clean 2>/dev/null || true" ;;
|
||||
archlinux) pct exec "$container" -- bash -c "pacman -Sc --noconfirm" ;;
|
||||
fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y clean packages" ;;
|
||||
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get clean" ;;
|
||||
opensuse) pct exec "$container" -- bash -c "zypper --non-interactive clean" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
function update_container() {
|
||||
local container=$1
|
||||
local name
|
||||
@@ -46,14 +64,22 @@ function update_container() {
|
||||
local os
|
||||
os=$(pct config "$container" | awk '/^ostype/ {print $2}')
|
||||
echo -e "\n [Info] Updating $container : $name (os: $os)"
|
||||
local rc=0
|
||||
case "$os" in
|
||||
alpine) pct exec "$container" -- ash -c "apk -U upgrade" ;;
|
||||
archlinux) pct exec "$container" -- bash -c "pacman -Syyu --noconfirm" ;;
|
||||
fedora | rocky | centos | alma) pct exec "$container" -- bash -c "dnf -y update && dnf -y upgrade" ;;
|
||||
ubuntu | debian | devuan) pct exec "$container" -- bash -c "apt-get update; DEBIAN_FRONTEND=noninteractive apt-get -o Dpkg::Options::='--force-confold' dist-upgrade -y; status=\$?; rm -rf /usr/lib/python3.*/EXTERNALLY-MANAGED || true; exit \$status" ;;
|
||||
opensuse) pct exec "$container" -- bash -c "zypper ref && zypper --non-interactive dup" ;;
|
||||
*) echo " [Warn] Unknown OS type '$os' for container $container, skipping" ;;
|
||||
esac
|
||||
*)
|
||||
echo " [Warn] Unknown OS type '$os' for container $container, skipping"
|
||||
return 0
|
||||
;;
|
||||
esac || rc=$?
|
||||
if [[ $rc -eq 0 && "${CLEAN_CACHE,,}" =~ ^(1|yes|true)$ ]]; then
|
||||
clean_container "$container" "$os" || echo " [Warn] Cache cleanup failed for $container"
|
||||
fi
|
||||
return $rc
|
||||
}
|
||||
|
||||
update_status=0
|
||||
|
||||
Reference in new issue
Block a user