From 2d232074976c10b10f907ce186be734d321fd6be Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 21 Jan 2026 12:40:52 +0100 Subject: [PATCH 1/3] added automatic versioning in workflow --- .gitea/workflows/android_build.yml | 114 +++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 21 deletions(-) diff --git a/.gitea/workflows/android_build.yml b/.gitea/workflows/android_build.yml index 9993997..544b13b 100644 --- a/.gitea/workflows/android_build.yml +++ b/.gitea/workflows/android_build.yml @@ -9,26 +9,70 @@ on: - main workflow_dispatch: - permissions: contents: write - actions: read + actions: read jobs: - build_apk: - name: Build Flutter APK + calculate-version: + name: Calculate Version runs-on: ubuntu-latest + outputs: + new_version: ${{ steps.version.outputs.new_version }} + bump_type: ${{ steps.version.outputs.bump_type }} steps: - name: Checkout code uses: actions/checkout@v3 + with: + fetch-depth: 0 - # - name: Cache pub deps - # uses: actions/cache@v3 - # with: - # path: ~/.pub-cache - # key: ${{ runner.os }}-pub-${{ hashFiles('**/pubspec.yaml') }} - # restore-keys: ${{ runner.os }}-pub- + - name: Get commit message and determine version bump + id: version + run: | + COMMIT_MSG="${{ github.event.head_commit.message }}" + + if [[ $COMMIT_MSG == [fix]* ]]; then + BUMP_TYPE="patch" + elif [[ $COMMIT_MSG == [feature]* ]]; then + BUMP_TYPE="minor" + elif [[ $COMMIT_MSG == [release]* ]]; then + BUMP_TYPE="major" + else + BUMP_TYPE="none" + fi + + LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") + LATEST_TAG=${LATEST_TAG#v} + + IFS='.' read -r MAJOR MINOR PATCH <<< "$LATEST_TAG" + MAJOR=${MAJOR:-0} + MINOR=${MINOR:-0} + PATCH=${PATCH:-0} + + if [ "$BUMP_TYPE" == "major" ]; then + ((MAJOR++)) + MINOR=0 + PATCH=0 + elif [ "$BUMP_TYPE" == "minor" ]; then + ((MINOR++)) + PATCH=0 + elif [ "$BUMP_TYPE" == "patch" ]; then + ((PATCH++)) + fi + + NEW_VERSION="$MAJOR.$MINOR.$PATCH" + echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT + echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT + + build_apk: + name: Build Flutter APK + runs-on: ubuntu-latest + needs: calculate-version + + steps: + - name: Checkout code + uses: actions/checkout@v3 - name: Setup Java (Temurin 17) uses: actions/setup-java@v3 @@ -40,40 +84,68 @@ jobs: uses: android-actions/setup-android@v3 with: packages: "platform-tools platforms;android-36 build-tools;36.0.0" - + - name: Setup Flutter uses: subosito/flutter-action@v2 with: channel: stable + - run: flutter --version - run: flutter doctor - + - name: Get dependencies run: flutter pub get - + + - name: Update pubspec.yaml with new version + run: | + sed -i "s/^version: .*/version: ${{ needs.calculate-version.outputs.new_version }}+${{ github.run_number }}/" pubspec.yaml + cat pubspec.yaml | grep version + - name: Build APK run: flutter build apk --release - + - name: Upload APK artifact uses: actions/upload-artifact@v3 with: name: flutter-apk path: build/app/outputs/flutter-apk/app-release.apk retention-days: 30 - + + create-release: + name: Create Release + runs-on: ubuntu-latest + needs: [calculate-version, build_apk] + if: needs.calculate-version.outputs.bump_type != 'none' + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Download APK artifact + uses: actions/download-artifact@v3 + with: + name: flutter-apk + + - name: Create Git tag + run: | + NEW_TAG="v${{ needs.calculate-version.outputs.new_version }}" + git config --local user.name "GitHub Actions" + git config --local user.email "actions@github.com" + git tag -a "$NEW_TAG" -m "Release ${{ needs.calculate-version.outputs.new_version }}" + git push origin "$NEW_TAG" + - name: Create Gitea release uses: akkuman/gitea-release-action@v1 env: - GITEA_TOKEN: ${{ secrets.RUNNER_CREATE_RELEASE }} + GITEA_TOKEN: ${{ secrets.RUNNER_CREATE_RELEASE }} with: - # tag & name: adjust to your versioning - tag_name: "v0.1.${{ github.run_number }}" - name: "Flutter Android v0.1.${{ github.run_number }}" - body: "Automated build from CI" + tag_name: "v${{ needs.calculate-version.outputs.new_version }}" + name: "Flutter Android v${{ needs.calculate-version.outputs.new_version }}" + body: "Automated build from CI\n\nVersion bump type: ${{ needs.calculate-version.outputs.bump_type }}" draft: false prerelease: false files: | build/app/outputs/flutter-apk/app-release.apk gitea_url: "https://git.skup.in" owner: "marco" - repo: "maps_bookmarks" \ No newline at end of file + repo: "maps_bookmarks" From 5feb535cf3a3d436fb5bd2d962aa24ea6d702c76 Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 21 Jan 2026 13:19:13 +0100 Subject: [PATCH 2/3] changed app version --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 90fc1af..db8ca29 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: "A new way to save google maps bookmarks" publish_to: 'none' -version: 1.0.0+1 +version: 0.0.0 environment: sdk: ^3.9.2 From cf88a9a37118e9dee60a1a8994b701225e4bfcbe Mon Sep 17 00:00:00 2001 From: marco Date: Wed, 21 Jan 2026 13:19:45 +0100 Subject: [PATCH 3/3] added bookmark count number in collections view --- lib/pages/collections_list_page.dart | 6 ++++++ lib/service/storage.dart | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/pages/collections_list_page.dart b/lib/pages/collections_list_page.dart index 28197cf..10d731e 100644 --- a/lib/pages/collections_list_page.dart +++ b/lib/pages/collections_list_page.dart @@ -20,6 +20,7 @@ class CollectionsListPage extends StatefulWidget { class _CollectionsListPageState extends State { bool addingNewBookmark = false; + final bookmarkCountMap = Storage.loadPerCollectionBookmarkCount(); Widget bottomSheetBuilder(BuildContext context) { final titleTextFieldController = TextEditingController( @@ -53,6 +54,11 @@ class _CollectionsListPageState extends State { title: Text(collection.name), onTap: () => navigateToCollection(collection.id), onLongPress: () => onEditCollection(collection), + leading: const Icon(Icons.list_rounded), + trailing: Text( + bookmarkCountMap[collection.id]?.toString() ?? '0', + style: Theme.of(context).textTheme.bodyMedium, + ), ); } diff --git a/lib/service/storage.dart b/lib/service/storage.dart index a4b57f2..ef91ac2 100644 --- a/lib/service/storage.dart +++ b/lib/service/storage.dart @@ -50,6 +50,14 @@ class Storage { return allBookmarks.where((b) => b.collectionId == collectionId).toList(); } + static Map loadPerCollectionBookmarkCount() { + return loadBookmarks().fold({}, (map, bookmark) { + map[bookmark.collectionId] ??= 0; + map[bookmark.collectionId] = map[bookmark.collectionId]! + 1; + return map; + }); + } + static Future addBookmark(Bookmark bookmark) async { final bookmarks = loadBookmarks(); bookmarks.add(bookmark);