Merge pull request #115 from usetrmnl/113-version-update-workflow

Add GitHub Actions version management workflow and helper script
This commit is contained in:
Hossain Khan
2025-06-26 23:50:20 -04:00
committed by GitHub
6 changed files with 295 additions and 15 deletions
+128
View File
@@ -0,0 +1,128 @@
# 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:
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: true
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 }}
+17
View File
@@ -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.
+2 -15
View File
@@ -55,22 +55,9 @@ The app will *soon* be available on F-Droid, providing a free and open source An
## <img src="project-resources/logo/android-logo-head.svg" width="60" alt="android logo"/>Android 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
### Release Process
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
```
For instructions on creating new releases and managing versions across the project, see the [Release Checklist](RELEASE_CHECKLIST.md).
---
+81
View File
@@ -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
@@ -0,0 +1,2 @@
- Updated to latest version 1.9.4
- Latest TRMNL Mirror app with F-Droid support
+65
View File
@@ -0,0 +1,65 @@
#!/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
# 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:"
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"