mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Add automatic flatpak version bumping logic
This now bumps the version number in de.wger.flutter.metainfo.xml, which is something we were not doing before...
This commit is contained in:
12
.github/workflows/bump-version.yml
vendored
12
.github/workflows/bump-version.yml
vendored
@@ -21,6 +21,9 @@ jobs:
|
||||
- name: Common flutter setup
|
||||
uses: ./.github/actions/flutter-common
|
||||
|
||||
- name: Setup uv
|
||||
uses: astral-sh/setup-uv@v5
|
||||
|
||||
- name: Validate version
|
||||
run: |
|
||||
RELEASE_VERSION="${{ inputs.app_version }}"
|
||||
@@ -39,11 +42,16 @@ jobs:
|
||||
NEXT_BUILD=$(( (CURRENT_BUILD / 10 + 1) * 10 ))
|
||||
flutter pub run cider version ${{ inputs.app_version }}+${NEXT_BUILD}
|
||||
|
||||
- name: Bump flatpak version
|
||||
run: |
|
||||
cd flatpak
|
||||
uv run bump-flatpak-version.py ${{ inputs.app_version }}
|
||||
|
||||
- name: Tag release and commit pubspec
|
||||
run: |
|
||||
git config user.name Github-Actions
|
||||
git config user.email github-actions@github.com
|
||||
git add pubspec.yaml
|
||||
git commit -m "Bump version to $( flutter pub run cider version )"
|
||||
git add pubspec.yaml flatpak/de.wger.flutter.metainfo.xml
|
||||
git commit -m "Bump version to ${{ inputs.app_version }}"
|
||||
git tag ${{ inputs.app_version }}
|
||||
git push origin HEAD:master --tags
|
||||
|
||||
1
.github/workflows/make-release.yml
vendored
1
.github/workflows/make-release.yml
vendored
@@ -138,6 +138,7 @@ jobs:
|
||||
- name: Make Github release
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
generate_release_notes: true
|
||||
tag_name: ${{ inputs.version }}
|
||||
files: |
|
||||
builds-aab/app-release.aab
|
||||
|
||||
135
flatpak/bump-flatpak-version.py
Normal file
135
flatpak/bump-flatpak-version.py
Normal file
@@ -0,0 +1,135 @@
|
||||
# This file is part of wger Workout Manager.
|
||||
#
|
||||
# wger Workout Manager is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# wger Workout Manager is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
|
||||
# /// script
|
||||
# requires-python = ">=3.13"
|
||||
# dependencies = [
|
||||
# "requests == 2.31.0",
|
||||
# "markdown == 3.5.1",
|
||||
# ]
|
||||
# ///
|
||||
|
||||
|
||||
"""
|
||||
Updates the Flatpak metainfo.xml file with the given version.
|
||||
|
||||
Usage:
|
||||
uv run bump-flatpak-version.py x.y.z
|
||||
"""
|
||||
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
from datetime import datetime
|
||||
from typing import Tuple
|
||||
|
||||
import markdown
|
||||
import requests
|
||||
|
||||
REPO = "wger-project/flutter"
|
||||
|
||||
|
||||
def get_github_release_info(repo: str, version: str) -> Tuple[str, str]:
|
||||
"""
|
||||
Fetches the release description and published_at date from GitHub for the given repository
|
||||
and version. The description is converted fro markdown and returned as HTML.
|
||||
"""
|
||||
|
||||
print('Fetching release information from GitHub...')
|
||||
url = f'https://api.github.com/repos/{repo}/releases/tags/{version}'
|
||||
response = requests.get(url)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
html_desc = markdown.markdown(data.get('body', ''))
|
||||
|
||||
# Get the published_at date, formatted as YYYY-MM-DD, we don't need the time part
|
||||
published_at = data.get('published_at', '')[:10]
|
||||
return html_desc, published_at
|
||||
|
||||
|
||||
def add_release_to_metainfo(
|
||||
repo: str,
|
||||
xml_filename: str,
|
||||
version: str,
|
||||
date: str | None = None,
|
||||
description: str | None = None
|
||||
) -> None:
|
||||
"""
|
||||
Adds a <release> element with the specified version and date to the <releases>
|
||||
section in the given metainfo.xml file.
|
||||
|
||||
If a description is provided, it will be added as a child element of the
|
||||
<release> element.
|
||||
"""
|
||||
print(f'Adding release to {xml_filename}...')
|
||||
|
||||
if date is None:
|
||||
date = datetime.now().strftime('%Y-%m-%d')
|
||||
|
||||
if description is None:
|
||||
description = '<p>Bug fixes and improvements.</p>'
|
||||
|
||||
tree = ET.parse(xml_filename)
|
||||
root = tree.getroot()
|
||||
releases = root.find('releases')
|
||||
new_release = ET.Element('release', {'version': version, 'date': date})
|
||||
if description:
|
||||
desc_elem = ET.SubElement(new_release, 'description')
|
||||
|
||||
# Needed to add HTML content directly, otherwise it will be escaped
|
||||
fragment = ET.fromstring(f'<root>{description}</root>')
|
||||
for child in fragment:
|
||||
desc_elem.append(child)
|
||||
|
||||
url_elem = ET.SubElement(new_release, 'url')
|
||||
url_elem.text = f'https://{repo}/releases/tag/{version}'
|
||||
|
||||
releases.insert(0, new_release)
|
||||
ET.indent(tree, space=" ", level=0)
|
||||
tree.write(xml_filename, encoding="utf-8", xml_declaration=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 2:
|
||||
print('Usage: python bump-flatpak-version.py <x.y.z>')
|
||||
sys.exit(1)
|
||||
|
||||
version = sys.argv[1]
|
||||
|
||||
print(f'Processing version {version}...')
|
||||
|
||||
# Note: it seems it's currently not possible to update existing releases on
|
||||
# GitHub with softprops/action-gh-release.
|
||||
#
|
||||
# Once that's fixed, we can update the workflows to first create the
|
||||
# release and its changelog, and in a later step only update the artifacts.
|
||||
# We can then simply fetch the description and update the metainfo.xml file.
|
||||
#
|
||||
# See
|
||||
# * https://github.com/softprops/action-gh-release/issues/616
|
||||
# * https://github.com/softprops/action-gh-release/issues/445
|
||||
|
||||
# description, published_at = get_github_release_info(
|
||||
# REPO,
|
||||
# version
|
||||
# )
|
||||
|
||||
add_release_to_metainfo(
|
||||
repo=REPO,
|
||||
xml_filename='de.wger.flutter.metainfo.xml',
|
||||
version=version,
|
||||
date=None, # published_at,
|
||||
description=None # description
|
||||
)
|
||||
|
||||
print(f'Finished!')
|
||||
@@ -1,4 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<component type="desktop-application">
|
||||
<id>de.wger.flutter</id>
|
||||
<name>wger</name>
|
||||
@@ -7,7 +7,6 @@
|
||||
<p>wger is a free and open-source fitness application designed to help you achieve your
|
||||
fitness goals.
|
||||
</p>
|
||||
|
||||
<p>Workout Management</p>
|
||||
<ul>
|
||||
<li>Create and customize workout routines tailored to your fitness level and
|
||||
@@ -16,21 +15,18 @@
|
||||
<li>Track your progress with detailed exercise logs</li>
|
||||
<li>Access a vast library of exercises</li>
|
||||
</ul>
|
||||
|
||||
<p>Nutrition Tracking</p>
|
||||
<ul>
|
||||
<li>Log your food intake using the Open Food Facts database</li>
|
||||
<li>Calculate your calorie intake and macronutrient breakdown</li>
|
||||
<li>Set personalized dietary goals and track your progress</li>
|
||||
</ul>
|
||||
|
||||
<p>Body Measurement Tracking</p>
|
||||
<ul>
|
||||
<li>Monitor your body weight, body fat percentage, and other measurements</li>
|
||||
<li>Visualize your progress with charts and graphs</li>
|
||||
</ul>
|
||||
</description>
|
||||
|
||||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>AGPL-3.0-or-later</project_license>
|
||||
<recommends>
|
||||
@@ -45,13 +41,10 @@
|
||||
<url type="donation">https://buymeacoffee.com/wger</url>
|
||||
<url type="vcs-browser">https://github.com/wger-project/flutter</url>
|
||||
<url type="translate">https://hosted.weblate.org/engage/wger/</url>
|
||||
|
||||
<!-- https://docs.flathub.org/banner-preview/ -->
|
||||
<branding>
|
||||
<color scheme_preference="light" type="primary">#a2aedd</color>
|
||||
<color scheme_preference="dark" type="primary">#687bd9</color>
|
||||
</branding>
|
||||
|
||||
<screenshots>
|
||||
<screenshot type="default">
|
||||
<caption>wger's dashboard</caption>
|
||||
@@ -84,12 +77,9 @@
|
||||
</image>
|
||||
</screenshot>
|
||||
</screenshots>
|
||||
|
||||
<releases>
|
||||
<release version="1.5.3" date="2023-03-16" />
|
||||
</releases>
|
||||
|
||||
<content_rating type="oars-1.1" />
|
||||
|
||||
<launchable type="desktop-id">de.wger.flutter.desktop</launchable>
|
||||
</component>
|
||||
</component>
|
||||
Reference in New Issue
Block a user