From 17c6df1f8b371d8de54b2098db46fb24d2bbb95a Mon Sep 17 00:00:00 2001 From: Aiden Schembri Date: Wed, 4 Mar 2026 09:49:41 +0100 Subject: [PATCH] chore: add workflow step to update and commit metainfo.xml for releases --- .github/workflows/build.yml | 101 +++++++++++++++++++++++++++++++++++- 1 file changed, 99 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39715280d..54a545c90 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -381,10 +381,71 @@ jobs: Fladder_x86_64.AppImage Fladder_x86_64.AppImage.zsync + prepare-metainfo: + runs-on: ubuntu-latest + needs: [fetch-info] + if: needs.fetch-info.outputs.build_type == 'release' + steps: + - name: Checkout repository + uses: actions/checkout@v6.0.2 + with: + fetch-depth: 0 + + - name: Update metainfo.xml releases + uses: actions/github-script@v8 + with: + script: | + const fs = require('fs'); + const version = '${{ needs.fetch-info.outputs.version_name }}'; + const date = new Date().toISOString().split('T')[0]; + + // Same API call that generate_release_notes: true uses internally + const { data } = await github.rest.repos.generateReleaseNotes({ + owner: context.repo.owner, + repo: context.repo.repo, + tag_name: `v${version}`, + target_commitish: 'HEAD', + }); + + const escape = s => s + .replace(/&/g, '&') + .replace(//g, '>'); + + const items = data.body.split('\n') + .filter(l => l.trimStart().startsWith('* ')) + .map(l => l.replace(/^\s*\*\s*/, '').trim()) + .map(l => l.replace(/\[([^\]]+)\]\([^)]+\)/g, '$1')) // strip markdown links + .map(l => l.replace(/\*\*([^*]+)\*\*/g, '$1')) // strip bold + .filter(Boolean) + .slice(0, 30) + .map(l => `
  • ${escape(l)}
  • `) + .join('\n'); + + const description = items + ? ` \n \n ` + : ` \n

    See GitHub for detailed changelog

    \n
    `; + + const newReleases = + ` \n \n${description}\n \n `; + + let content = fs.readFileSync('flatpak/nl.jknaapen.fladder.metainfo.xml', 'utf8'); + content = content.replace(/ [\s\S]*?<\/releases>/, newReleases); + fs.writeFileSync('flatpak/nl.jknaapen.fladder.metainfo.xml', content); + + core.info(`Updated metainfo.xml: version=${version}, date=${date}`); + + - name: Upload updated metainfo + uses: actions/upload-artifact@v4 + with: + name: fladder-metainfo + path: flatpak/nl.jknaapen.fladder.metainfo.xml + build-linux-flatpak: runs-on: ubuntu-latest - if: needs.fetch-info.outputs.build_type == 'release' || needs.fetch-info.outputs.build_type == 'nightly' - needs: [fetch-info, build-linux] + # prepare-metainfo is skipped for nightly; !failure() && !cancelled() allows this job to still run + if: ${{ !failure() && !cancelled() && (needs.fetch-info.outputs.build_type == 'release' || needs.fetch-info.outputs.build_type == 'nightly') }} + needs: [fetch-info, build-linux, prepare-metainfo] container: image: bilelmoussaoui/flatpak-github-actions:gnome-46 options: --privileged @@ -394,6 +455,13 @@ jobs: with: submodules: true + - name: Download updated metainfo + if: needs.fetch-info.outputs.build_type == 'release' + uses: actions/download-artifact@v4 + with: + name: fladder-metainfo + path: flatpak + - name: Download Artifacts Linux uses: actions/download-artifact@v4 with: @@ -456,6 +524,7 @@ jobs: name: Create Release needs: - fetch-info + - prepare-metainfo - build-android - build-windows - build-ios @@ -474,6 +543,13 @@ jobs: with: fetch-depth: 0 + - name: Checkout repository (release) + if: needs.fetch-info.outputs.build_type == 'release' + uses: actions/checkout@v4.1.1 + with: + ref: develop + token: ${{ secrets.GITHUB_TOKEN }} + - name: Set version variables id: version run: | @@ -483,6 +559,27 @@ jobs: echo "version=${{ needs.fetch-info.outputs.version_name }}" >> $GITHUB_OUTPUT fi + - name: Download updated metainfo for commit + if: needs.fetch-info.outputs.build_type == 'release' + uses: actions/download-artifact@v4 + with: + name: fladder-metainfo + path: fladder-metainfo + + - name: Commit updated metainfo.xml to develop + if: needs.fetch-info.outputs.build_type == 'release' + run: | + cp fladder-metainfo/nl.jknaapen.fladder.metainfo.xml flatpak/nl.jknaapen.fladder.metainfo.xml + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add flatpak/nl.jknaapen.fladder.metainfo.xml + if git diff --staged --quiet; then + echo "No changes to metainfo.xml, skipping commit" + else + git commit -m "chore: update metainfo.xml to v${{ needs.fetch-info.outputs.version_name }}" + git push origin develop + fi + - name: Delete existing nightly release if: needs.fetch-info.outputs.build_type == 'nightly' run: |