-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Desktop Entry and AppStream #236
base: master
Are you sure you want to change the base?
Conversation
Could you add a script to do so that'll be invoked as part of our release scripts? |
It should be added to the release job in the release workflow: https://github.com/liftoff-app/liftoff/blob/master/.github/workflows/release.yml#L135 |
So this CI will run before releasing a new Update? |
Yep. If you make it edit the AppStream file, there's no risk of us forgetting. |
Does the CI also commit the changed files to the Repo, so builds from source will also work? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My bad, it turns out @zachatrocity runs this script locally when releasing:
https://github.com/liftoff-app/liftoff/blob/master/scripts/release.dart
Please update that to modify the appstream file. Then it'll always get done on every release.
The AppStream can also contains the Changelog. Is the changelog always a Markdown Bullet List, so I can convert it to the Format used by AppStream? |
There is quite a bit of changelog handling code in that release.dart file, that script parses the markdown and builds a release log. It writes it to fastlane, you should be able to add something similar for app stream around here: https://github.com/liftoff-app/liftoff/blob/master/scripts/release.dart#L115 |
I have modified the script. Just save the AppStream file as test.xml to test this: Future<void> updateChangelog(Version version) async {
final changelogFile = File('CHANGELOG.md');
final changelogContents = await changelogFile.readAsString();
var currentChangelog =
RegExp(r'^## Unreleased$.+?^##[^#]', multiLine: true, dotAll: true)
.stringMatch(changelogContents);
if (currentChangelog == null) {
printError('No changelog found');
}
currentChangelog = currentChangelog.substring(0, currentChangelog.length - 4);
final date = DateTime.now();
final dateString =
'${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
currentChangelog = currentChangelog.replaceFirst(
'Unreleased', 'v${version.toStringNoCode()} - $dateString');
confirm('Changelog looks good?\n$currentChangelog\n');
//await changelogFile.writeAsString(changelogContents.replaceFirst(
// 'Unreleased', 'v${version.toStringNoCode()} - $dateString'));
//await File('fastlane/metadata/android/en-US/changelogs/${version.code}.txt')
// .writeAsString(currentChangelog.split('\n').skip(2).join('\n'));
String appStreamRelease =
' <release version="v${version.toStringNoCode()}" date="${dateString}" type="stable">\n';
appStreamRelease +=
' <url>https://github.com/liftoff-app/liftoff/releases/tag/v${version.toStringNoCode()}</url>\n';
appStreamRelease += ' <description>\n';
appStreamRelease += ' <ul>\n';
currentChangelog.split('\n').forEach((String element) {
if (!element.isEmpty && element.startsWith("-")) {
appStreamRelease += ' <li>' + element.substring(2) + '</li>\n';
}
});
appStreamRelease += ' </ul>\n';
appStreamRelease += ' </description>\n';
appStreamRelease += ' </release>';
final appStreamFile = File('test.xml');
final appStreamContent = await appStreamFile.readAsString();
final releaseIndex =
appStreamContent.indexOf("<releases>") + "<releases>".length.toInt();
final newAppStreamContent = appStreamContent.substring(0, releaseIndex) +
"\n" +
appStreamRelease +
appStreamContent.substring(releaseIndex);
print(newAppStreamContent);
} I don't know if dart includes a XML parser (First time I worked with Dart), so I just used strings, which is a bit hacky. Is this script OK for you? If yes, I can use the correct path and write to the File instead of printing. |
To be honest, I'd prefer you use the dart xml package: It looks reasonably easy to use (even supports XPath), and will be much more robust than strings. |
Here is the version using the xml package (they should add better documentation): Future<void> updateChangelog(Version version) async {
final changelogFile = File('CHANGELOG.md');
final changelogContents = await changelogFile.readAsString();
var currentChangelog =
RegExp(r'^## Unreleased$.+?^##[^#]', multiLine: true, dotAll: true)
.stringMatch(changelogContents);
if (currentChangelog == null) {
printError('No changelog found');
}
currentChangelog = currentChangelog.substring(0, currentChangelog.length - 4);
final date = DateTime.now();
final dateString =
'${date.year}-${date.month.toString().padLeft(2, '0')}-${date.day.toString().padLeft(2, '0')}';
currentChangelog = currentChangelog.replaceFirst(
'Unreleased', 'v${version.toStringNoCode()} - $dateString');
confirm('Changelog looks good?\n$currentChangelog\n');
//await changelogFile.writeAsString(changelogContents.replaceFirst(
// 'Unreleased', 'v${version.toStringNoCode()} - $dateString'));
//await File('fastlane/metadata/android/en-US/changelogs/${version.code}.txt')
// .writeAsString(currentChangelog.split('\n').skip(2).join('\n'));
var appStreamList = new XmlElement(new XmlName('ul'));
currentChangelog.split('\n').forEach((String element) {
if (element.isNotEmpty && element.startsWith("-")) {
var appStreamListElement = new XmlElement(new XmlName('li'));
appStreamListElement.innerText = element.substring(2);
appStreamList.children.add(appStreamListElement);
}
});
var appStreamDescription = new XmlElement(new XmlName('description'));
appStreamDescription.children.add(appStreamList);
var appStreamURL = new XmlElement(new XmlName('url'));
appStreamURL.innerText =
'https://github.com/liftoff-app/liftoff/releases/tag/v${version.toStringNoCode()}';
var currentRelaseTag = new XmlElement(new XmlName('release'));
currentRelaseTag.setAttribute('version', 'v${version.toStringNoCode()}');
currentRelaseTag.setAttribute('date', dateString);
currentRelaseTag.setAttribute('type', 'stable');
currentRelaseTag.children.add(appStreamURL);
currentRelaseTag.children.add(appStreamDescription);
final appStreamFile = File('test.xml');
var appStreamXML = XmlDocument.parse(await appStreamFile.readAsString());
var releasesTag = appStreamXML.rootElement.getElement('releases');
if (releasesTag != null) {
releasesTag.children.insert(0, currentRelaseTag);
} else {
print("Can't find releases tag");
}
print(appStreamXML.toXmlString(pretty: true));
} Another big problem that needs to be solved before merging is, what the App ID should be. liftof currently uses |
@zachatrocity you good to test this? |
Yeah I can test this |
@JakobDev can you actually commit the changes to your branch? Also we'll need to tweak the dbus name even though its considered bad practice, we have too many users on ios/android to change the app id now. |
Done
If you can do that for Linux Desktop, then that's no problem. Just make sure, everything uses the same ID under Linux. Tell em your new ID, so I can update the files in this PR. These files also needed to be included in the linux.tar.gz archive, but i don't know how to do this. |
This are needed for the Linux Desktop e.g. Flatpak. Please include this files in the Linux build together with the SVG image.
Please always update the Version in the AppStream file before releasing a Update.