From f3e9fa1e08d6862851b7a94fcc2813578f058a56 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Fri, 21 Feb 2025 15:57:04 -0500 Subject: [PATCH 1/3] feat: allow editing releases and properly escape changleogs --- .github/workflows/release-production.yml | 54 ++++++++++++++++++++---- 1 file changed, 45 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml index bac9121fc6..5c8c226b3b 100644 --- a/.github/workflows/release-production.yml +++ b/.github/workflows/release-production.yml @@ -2,7 +2,7 @@ name: Publish Release to Digital Ocean on: release: - types: [published] + types: [published, edited] jobs: publish-to-digital-ocean: @@ -25,14 +25,50 @@ jobs: with: latest: true prerelease: false - - name: Get Release Changelog - run: | - notes=$(cat << EOF - ${{ steps.release-info.outputs.body }} - EOF - ) - escapedNotes=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"$notes") - sed -i -z -E "s/(.*)<\/CHANGES>/\n${escapedNotes}\n<\/CHANGES>/g" "dynamix.unraid.net.plg" + - uses: actions/setup-node@v4 + with: + node-version: '20.x' + - run: npm install html-sloppy-escaper xml2js + - name: Update Plugin Changelog + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const { escape as escapeHtml } = require('html-sloppy-escaper'); + const releaseNotes = escapeHtml(`${{ steps.release-info.outputs.body }}`); + + if (!releaseNotes) { + console.error('No release notes found'); + process.exit(1); + } + + // Read the plugin file + const pluginPath = 'dynamix.unraid.net.plg'; + + if (!fs.existsSync(pluginPath)) { + console.error('Plugin file not found:', pluginPath); + process.exit(1); + } + + let pluginContent = fs.readFileSync(pluginPath, 'utf8'); + + // Replace the changelog section using CDATA + pluginContent = pluginContent.replace( + /[\s\S]*?<\/CHANGES>/, + `\n\n` + ); + + // Validate the plugin file is valid XML + const xml2js = require('xml2js'); + const parser = new xml2js.Parser(); + parser.parseStringPromise(pluginContent).then((result) => { + console.log('Plugin file is valid XML'); + }).catch((err) => { + console.error('Plugin file is not valid XML'); + process.exit(1); + }); + // Write back to file + fs.writeFileSync(pluginPath, pluginContent); - name: Upload All Release Files to DO Spaces uses: BetaHuhn/do-spaces-action@v2 From fc1b7fe4d6f8f126af65ab183e8b96748affd318 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Fri, 21 Feb 2025 15:58:40 -0500 Subject: [PATCH 2/3] fix: remove cdata tag --- .github/workflows/release-production.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml index 5c8c226b3b..74b1c92e38 100644 --- a/.github/workflows/release-production.yml +++ b/.github/workflows/release-production.yml @@ -55,7 +55,7 @@ jobs: // Replace the changelog section using CDATA pluginContent = pluginContent.replace( /[\s\S]*?<\/CHANGES>/, - `\n\n` + `\n${releaseNotes}\n` ); // Validate the plugin file is valid XML From d6c90a1f2b9cb28bfbd9847b07dec7299545f8b5 Mon Sep 17 00:00:00 2001 From: Eli Bosley Date: Fri, 21 Feb 2025 16:05:43 -0500 Subject: [PATCH 3/3] fix: async not awaited --- .github/workflows/release-production.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-production.yml b/.github/workflows/release-production.yml index 74b1c92e38..ddc76e5b77 100644 --- a/.github/workflows/release-production.yml +++ b/.github/workflows/release-production.yml @@ -63,12 +63,13 @@ jobs: const parser = new xml2js.Parser(); parser.parseStringPromise(pluginContent).then((result) => { console.log('Plugin file is valid XML'); + + // Write back to file + fs.writeFileSync(pluginPath, pluginContent); }).catch((err) => { console.error('Plugin file is not valid XML'); process.exit(1); }); - // Write back to file - fs.writeFileSync(pluginPath, pluginContent); - name: Upload All Release Files to DO Spaces uses: BetaHuhn/do-spaces-action@v2