From 10f0c6d0a089671bf26886ddad27f905eca98fd8 Mon Sep 17 00:00:00 2001 From: Hossain Khan Date: Thu, 26 Jun 2025 23:15:32 -0400 Subject: [PATCH 1/7] Add GitHub Actions version management workflow and helper script --- .github/workflows/version-management.yml | 126 +++++++++++++++++++++++ README.md | 33 ++++++ scripts/show_version_info.sh | 64 ++++++++++++ 3 files changed, 223 insertions(+) create mode 100644 .github/workflows/version-management.yml create mode 100755 scripts/show_version_info.sh diff --git a/.github/workflows/version-management.yml b/.github/workflows/version-management.yml new file mode 100644 index 0000000..396647d --- /dev/null +++ b/.github/workflows/version-management.yml @@ -0,0 +1,126 @@ +name: Version Management + +on: + workflow_dispatch: + inputs: + version_name: + description: 'Version name (semantic version e.g. 1.9.5)' + required: true + type: string + version_code: + description: 'Version code (integer, must increase with each release)' + required: true + type: string + git_tag: + description: 'Git tag for this release (defaults to v + version_name)' + required: false + type: string + release_notes: + description: 'Release notes (comma-separated items)' + required: true + type: string + create_pr: + description: 'Create PR instead of direct commit' + required: false + type: boolean + default: false + branch_name: + description: 'Branch name for PR (only used if create_pr is true)' + required: false + type: string + default: 'version-bump' + +jobs: + update-version: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set git user + run: | + git config user.name "GitHub Actions Bot" + git config user.email "actions@github.com" + + - name: Set git tag if not provided + if: ${{ inputs.git_tag == '' }} + run: echo "GIT_TAG=v${{ inputs.version_name }}" >> $GITHUB_ENV + + - name: Use provided git tag + if: ${{ inputs.git_tag != '' }} + run: echo "GIT_TAG=${{ inputs.git_tag }}" >> $GITHUB_ENV + + - name: Create branch if creating PR + if: ${{ inputs.create_pr == true }} + run: | + BRANCH="${{ inputs.branch_name }}-${{ inputs.version_name }}" + git checkout -b $BRANCH + echo "BRANCH_NAME=$BRANCH" >> $GITHUB_ENV + + - name: Update app/build.gradle.kts + run: | + sed -i "s/versionCode = [0-9]\\+/versionCode = ${{ inputs.version_code }}/g" app/build.gradle.kts + sed -i "s/versionName = \"[^\"]*\"/versionName = \"${{ inputs.version_name }}\"/g" app/build.gradle.kts + echo "✓ Updated app/build.gradle.kts with version ${{ inputs.version_name }} (${{ inputs.version_code }})" + + - name: Update F-Droid metadata file + run: | + if [ -f "metadata/ink.trmnl.android.yml" ]; then + sed -i "s/CurrentVersion: .*/CurrentVersion: ${{ inputs.version_name }}/g" metadata/ink.trmnl.android.yml + sed -i "s/CurrentVersionCode: [0-9]\\+/CurrentVersionCode: ${{ inputs.version_code }}/g" metadata/ink.trmnl.android.yml + sed -i "s/versionName: .*/versionName: ${{ inputs.version_name }}/g" metadata/ink.trmnl.android.yml + sed -i "s/versionCode: [0-9]\\+/versionCode: ${{ inputs.version_code }}/g" metadata/ink.trmnl.android.yml + sed -i "s/commit: .*/commit: ${{ env.GIT_TAG }}/g" metadata/ink.trmnl.android.yml + echo "✓ Updated metadata/ink.trmnl.android.yml with version ${{ inputs.version_name }} (${{ inputs.version_code }})" + else + echo "Warning: metadata/ink.trmnl.android.yml not found" + fi + + - name: Create changelog file + run: | + mkdir -p fastlane/metadata/android/en-US/changelogs + echo "- Updated to the latest version (${{ inputs.version_name }})" > fastlane/metadata/android/en-US/changelogs/${{ inputs.version_code }}.txt + + # Process release notes + IFS=',' read -ra NOTES <<< "${{ inputs.release_notes }}" + for note in "${NOTES[@]}"; do + # Trim whitespace and add bullet point + trimmed_note=$(echo "$note" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + echo "- $trimmed_note" >> fastlane/metadata/android/en-US/changelogs/${{ inputs.version_code }}.txt + done + + echo "✓ Created changelog file at fastlane/metadata/android/en-US/changelogs/${{ inputs.version_code }}.txt" + cat fastlane/metadata/android/en-US/changelogs/${{ inputs.version_code }}.txt + + - name: Commit changes directly + if: ${{ inputs.create_pr == false }} + run: | + git add app/build.gradle.kts metadata/ fastlane/ + git commit -m "chore: prepare release ${{ inputs.version_name }}" + git tag ${{ env.GIT_TAG }} + git push origin HEAD:${{ github.ref_name }} + git push origin ${{ env.GIT_TAG }} + echo "✓ Changes committed and pushed to ${{ github.ref_name }}" + echo "✓ Created and pushed tag ${{ env.GIT_TAG }}" + + - name: Create Pull Request + if: ${{ inputs.create_pr == true }} + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: "chore: prepare release ${{ inputs.version_name }}" + title: "Prepare release ${{ inputs.version_name }}" + body: | + This PR updates the version to ${{ inputs.version_name }} (${{ inputs.version_code }}) + + ### Release Notes: + ${{ inputs.release_notes }} + + ### Changes: + - Updated app/build.gradle.kts + - Updated F-Droid metadata + - Created changelog file + + After merging this PR, please create a tag with: `git tag ${{ env.GIT_TAG }} && git push origin ${{ env.GIT_TAG }}` + branch: ${{ env.BRANCH_NAME }} + base: ${{ github.ref_name }} diff --git a/README.md b/README.md index e483e15..f45182a 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,39 @@ To build specific variants: ./gradlew buildAllFlavors ``` +### Version Management + +The project uses GitHub Actions to manage version synchronization across different files: + +- `app/build.gradle.kts`: Contains the app's version code and name +- `metadata/ink.trmnl.android.yml`: Contains F-Droid metadata and versioning +- `fastlane/metadata/android/en-US/changelogs/`: Contains version-specific changelog files + +#### Creating a new release + +1. **Check current version information**: + ```bash + # Show current version information and suggested next version + ./scripts/show_version_info.sh + ``` + +2. **Run the Version Management workflow**: + - Go to GitHub Actions → Version Management workflow + - Click "Run workflow" + - Enter the required information: + - **Version name**: Semantic version (e.g., 1.9.5) + - **Version code**: Integer value, must increase with each release + - **Git tag** (optional): Defaults to v + version name + - **Release notes**: Comma-separated release notes + - **Create PR**: Whether to create a pull request or commit directly + +3. **Wait for workflow completion**: + - The workflow will update all necessary files + - It will create or update the changelog + - It will commit changes and create a git tag + +This automated process ensures consistency across all version-related files without manual edits. + --- ## Related References 📖 diff --git a/scripts/show_version_info.sh b/scripts/show_version_info.sh new file mode 100755 index 0000000..5254af0 --- /dev/null +++ b/scripts/show_version_info.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# Script to display current version information across the project + +set -e + +# Get current directory +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT_DIR="$(dirname "$SCRIPT_DIR")" + +echo "🔍 Current TRMNL Android Version Information" +echo "-------------------------------------------" + +# Extract version from app/build.gradle.kts +VERSION_CODE=$(grep -o 'versionCode = [0-9]\+' "$ROOT_DIR/app/build.gradle.kts" | awk '{print $3}') +VERSION_NAME=$(grep -o 'versionName = "[^"]*"' "$ROOT_DIR/app/build.gradle.kts" | sed 's/versionName = "\(.*\)"/\1/') + +echo "📱 From app/build.gradle.kts:" +echo " - Version Code: $VERSION_CODE" +echo " - Version Name: $VERSION_NAME" +echo + +# Extract version from F-Droid metadata +if [ -f "$ROOT_DIR/metadata/ink.trmnl.android.yml" ]; then + echo "🤖 From F-Droid metadata:" + FDROID_VERSION=$(grep -o 'CurrentVersion: .*' "$ROOT_DIR/metadata/ink.trmnl.android.yml" | awk '{print $2}') + FDROID_CODE=$(grep -o 'CurrentVersionCode: [0-9]*' "$ROOT_DIR/metadata/ink.trmnl.android.yml" | awk '{print $2}') + FDROID_TAG=$(grep -o 'commit: .*' "$ROOT_DIR/metadata/ink.trmnl.android.yml" | awk '{print $2}') + echo " - Version Code: $FDROID_CODE" + echo " - Version Name: $FDROID_VERSION" + echo " - Git Tag: $FDROID_TAG" + echo +fi + +# Find and list changelog files +echo "📝 Changelog files:" +if [ -d "$ROOT_DIR/fastlane/metadata/android/en-US/changelogs" ]; then + for file in "$ROOT_DIR/fastlane/metadata/android/en-US/changelogs"/*.txt; do + if [ -f "$file" ]; then + VERSION=$(basename "$file" .txt) + echo " - Version $VERSION:" + sed 's/^/ /' "$file" # Indent the file content + echo + fi + done +else + echo " No changelog files found in fastlane/metadata/android/en-US/changelogs" +fi + +# Suggest next version +NEXT_VERSION_CODE=$((VERSION_CODE + 1)) +# Simple semantic version increment (assumes X.Y.Z format) +IFS='.' read -ra VER_PARTS <<< "$VERSION_NAME" +NEXT_VERSION_NAME="${VER_PARTS[0]}.${VER_PARTS[1]}.$((${VER_PARTS[2]} + 1))" + +echo "🚀 Suggested next version:" +echo " - Version Code: $NEXT_VERSION_CODE" +echo " - Version Name: $NEXT_VERSION_NAME" +echo + +echo "To update version, run the GitHub Actions workflow 'Version Management' with:" +echo " - Version name: $NEXT_VERSION_NAME" +echo " - Version code: $NEXT_VERSION_CODE" +echo " - Git tag: v$NEXT_VERSION_NAME (default)" +echo " - Release notes: your comma-separated release notes" From d105dff6cfd3f531be853b9be83c56e4aebab27c Mon Sep 17 00:00:00 2001 From: Hossain Khan Date: Thu, 26 Jun 2025 23:27:58 -0400 Subject: [PATCH 2/7] Move version management instructions to RELEASE_CHECKLIST.md --- README.md | 33 ++---------------- RELEASE_CHECKLIST.md | 81 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 31 deletions(-) create mode 100644 RELEASE_CHECKLIST.md diff --git a/README.md b/README.md index f45182a..87325a0 100644 --- a/README.md +++ b/README.md @@ -72,38 +72,9 @@ To build specific variants: ./gradlew buildAllFlavors ``` -### Version Management +### Release Process -The project uses GitHub Actions to manage version synchronization across different files: - -- `app/build.gradle.kts`: Contains the app's version code and name -- `metadata/ink.trmnl.android.yml`: Contains F-Droid metadata and versioning -- `fastlane/metadata/android/en-US/changelogs/`: Contains version-specific changelog files - -#### Creating a new release - -1. **Check current version information**: - ```bash - # Show current version information and suggested next version - ./scripts/show_version_info.sh - ``` - -2. **Run the Version Management workflow**: - - Go to GitHub Actions → Version Management workflow - - Click "Run workflow" - - Enter the required information: - - **Version name**: Semantic version (e.g., 1.9.5) - - **Version code**: Integer value, must increase with each release - - **Git tag** (optional): Defaults to v + version name - - **Release notes**: Comma-separated release notes - - **Create PR**: Whether to create a pull request or commit directly - -3. **Wait for workflow completion**: - - The workflow will update all necessary files - - It will create or update the changelog - - It will commit changes and create a git tag - -This automated process ensures consistency across all version-related files without manual edits. +For instructions on creating new releases and managing versions across the project, see the [Release Checklist](RELEASE_CHECKLIST.md). --- diff --git a/RELEASE_CHECKLIST.md b/RELEASE_CHECKLIST.md new file mode 100644 index 0000000..296f969 --- /dev/null +++ b/RELEASE_CHECKLIST.md @@ -0,0 +1,81 @@ +# Release Checklist for TRMNL Android + +This document outlines the process for creating new releases of the TRMNL Android app. + +## Version Management + +The project uses GitHub Actions to manage version synchronization across different files: + +- `app/build.gradle.kts`: Contains the app's version code and name +- `metadata/ink.trmnl.android.yml`: Contains F-Droid metadata and versioning +- `fastlane/metadata/android/en-US/changelogs/`: Contains version-specific changelog files + +## Creating a new release + +### 1. Check current version information + +```bash +# Show current version information and suggested next version +./scripts/show_version_info.sh +``` + +This will display: +- Current version code and name +- F-Droid metadata version information +- Existing changelog files +- Suggested next version + +### 2. Run the Version Management workflow + +- Go to GitHub Actions → Version Management workflow +- Click "Run workflow" +- Enter the required information: + - **Version name**: Semantic version (e.g., 1.9.5) + - **Version code**: Integer value, must increase with each release + - **Git tag** (optional): Defaults to v + version name + - **Release notes**: Comma-separated release notes + - **Create PR**: Whether to create a pull request or commit directly + +### 3. Wait for workflow completion + +- The workflow will update all necessary files +- It will create or update the changelog +- It will commit changes and create a git tag + +This automated process ensures consistency across all version-related files without manual edits. + +## 4. Post-release tasks + +After the version management workflow has completed: + +1. **Pull the latest changes** (if you ran the workflow with direct commits): + ```bash + git pull origin main + ``` + +2. **Verify the build works with the new version**: + ```bash + # Build both variants to ensure they work + ./gradlew buildStandard buildFDroid + ``` + +3. **Create a GitHub release**: + - Go to GitHub → Releases → Draft new release + - Select the tag created by the workflow + - Title: "TRMNL Android v{VERSION_NAME}" + - Description: Copy content from the changelog file + - Attach the built APKs + +## Troubleshooting + +If you encounter issues with the version management workflow: + +1. **Manual versioning**: + - Update `app/build.gradle.kts` with the new version code and name + - Update `metadata/ink.trmnl.android.yml` with the same version information + - Create a new changelog file in `fastlane/metadata/android/en-US/changelogs/{VERSION_CODE}.txt` + - Commit and tag manually + +2. **Workflow permissions**: + - Ensure the GitHub Actions workflow has sufficient permissions to create commits and tags + - Check the repository settings → Actions → General → Workflow permissions From 1436121aa168e92ccc1ae086c18dbd954a4fdeae Mon Sep 17 00:00:00 2001 From: Hossain Khan Date: Thu, 26 Jun 2025 23:32:19 -0400 Subject: [PATCH 3/7] [UPDATE] Make PR required by default --- .github/workflows/version-management.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/version-management.yml b/.github/workflows/version-management.yml index 396647d..a6ffcbf 100644 --- a/.github/workflows/version-management.yml +++ b/.github/workflows/version-management.yml @@ -1,3 +1,5 @@ +# This GitHub Actions workflow is intended for version management within the trmnl-android project. +# The workflow helps ensure consistent and automated version control processes for the repository. name: Version Management on: @@ -23,7 +25,7 @@ on: description: 'Create PR instead of direct commit' required: false type: boolean - default: false + default: true branch_name: description: 'Branch name for PR (only used if create_pr is true)' required: false From c29654f5b8e7cf4c5ab496561e0ab0e1e6ed7d06 Mon Sep 17 00:00:00 2001 From: Hossain Khan Date: Thu, 26 Jun 2025 23:37:46 -0400 Subject: [PATCH 4/7] [ADDED] Missing release note text --- fastlane/metadata/android/en-US/changelogs/15.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 fastlane/metadata/android/en-US/changelogs/15.txt diff --git a/fastlane/metadata/android/en-US/changelogs/15.txt b/fastlane/metadata/android/en-US/changelogs/15.txt new file mode 100644 index 0000000..10629b4 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/15.txt @@ -0,0 +1,2 @@ +- Updated to latest version 1.9.4 +- Latest TRMNL Mirror app with F-Droid support \ No newline at end of file From c80bb0edc7a6f55a652f3d0939e1b1ceced15a8a Mon Sep 17 00:00:00 2001 From: Hossain Khan Date: Thu, 26 Jun 2025 23:39:14 -0400 Subject: [PATCH 5/7] [MINOR] Address PR feedback --- RELEASE_CHECKLIST.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_CHECKLIST.md b/RELEASE_CHECKLIST.md index 296f969..daa0604 100644 --- a/RELEASE_CHECKLIST.md +++ b/RELEASE_CHECKLIST.md @@ -44,7 +44,7 @@ This will display: This automated process ensures consistency across all version-related files without manual edits. -## 4. Post-release tasks +### 4. Post-release tasks After the version management workflow has completed: From 569976817f18f82e5c87d084ffe217e51f550aa6 Mon Sep 17 00:00:00 2001 From: Hossain Khan Date: Thu, 26 Jun 2025 23:42:46 -0400 Subject: [PATCH 6/7] Move Build Variants section from README to CONTRIBUTING.md --- CONTRIBUTING.md | 17 +++++++++++++++++ README.md | 17 ----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 264ee2c..95bdc3e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -71,6 +71,23 @@ To build a debug APK: ./gradlew assembleDebug ``` +### Build Variants +The app supports multiple build variants: +- **Standard**: The default variant with all features +- **F-Droid**: A variant optimized for F-Droid distribution without Google dependencies + +To build specific variants: +```bash +# Build the standard release variant +./gradlew buildStandard + +# Build the F-Droid release variant +./gradlew buildFDroid + +# Build all variants +./gradlew buildAllFlavors +``` + ### Snapshot Builds Automatic snapshot release builds are available in the [release workflow](https://github.com/usetrmnl/trmnl-android/actions/workflows/android-release.yml) artifacts. diff --git a/README.md b/README.md index 87325a0..7f3092f 100644 --- a/README.md +++ b/README.md @@ -55,23 +55,6 @@ The app will *soon* be available on F-Droid, providing a free and open source An ## android logoAndroid Development & Contribution Guide See [CONTRIBUTING.md](CONTRIBUTING.md) for more details on how to get started and contribute to the project. -### Build Variants -The app supports multiple build variants: -- **Standard**: The default variant with all features -- **F-Droid**: A variant optimized for F-Droid distribution without Google dependencies - -To build specific variants: -```bash -# Build the standard release variant -./gradlew buildStandard - -# Build the F-Droid release variant -./gradlew buildFDroid - -# Build all variants -./gradlew buildAllFlavors -``` - ### Release Process For instructions on creating new releases and managing versions across the project, see the [Release Checklist](RELEASE_CHECKLIST.md). From 032438603914d24bf18067ac49fab4207c428682 Mon Sep 17 00:00:00 2001 From: Hossain Khan Date: Thu, 26 Jun 2025 23:47:03 -0400 Subject: [PATCH 7/7] Fix changelog sorting to use version order with sort -V --- scripts/show_version_info.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/show_version_info.sh b/scripts/show_version_info.sh index 5254af0..970ffbe 100755 --- a/scripts/show_version_info.sh +++ b/scripts/show_version_info.sh @@ -34,7 +34,8 @@ fi # Find and list changelog files echo "📝 Changelog files:" if [ -d "$ROOT_DIR/fastlane/metadata/android/en-US/changelogs" ]; then - for file in "$ROOT_DIR/fastlane/metadata/android/en-US/changelogs"/*.txt; do + # Using find with sort -V to ensure version-sorted order of changelog files + for file in $(find "$ROOT_DIR/fastlane/metadata/android/en-US/changelogs" -name "*.txt" | sort -V); do if [ -f "$file" ]; then VERSION=$(basename "$file" .txt) echo " - Version $VERSION:"