Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 99 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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, '&lt;')
.replace(/>/g, '&gt;');

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 => ` <li>${escape(l)}</li>`)
.join('\n');

const description = items
? ` <description>\n <ul>\n${items}\n </ul>\n </description>`
: ` <description>\n <p>See GitHub for detailed changelog</p>\n </description>`;

const newReleases =
` <releases>\n <release version="${version}" date="${date}">\n${description}\n </release>\n </releases>`;

let content = fs.readFileSync('flatpak/nl.jknaapen.fladder.metainfo.xml', 'utf8');
content = content.replace(/ <releases>[\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
Expand All @@ -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:
Expand Down Expand Up @@ -456,6 +524,7 @@ jobs:
name: Create Release
needs:
- fetch-info
- prepare-metainfo
- build-android
- build-windows
- build-ios
Expand All @@ -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: |
Expand All @@ -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: |
Expand Down