feat(release): Automate changelog, asset updates, and tagging (#4407)

This commit is contained in:
James Rich 2026-02-02 12:19:08 -06:00 committed by GitHub
parent f60fbf4b3a
commit 70d7319efe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 309 additions and 45 deletions

View file

@ -35,6 +35,7 @@ jobs:
release_name: ${{ steps.calculate_tags.outputs.release_name }}
final_tag: ${{ steps.calculate_tags.outputs.final_tag }}
from_channel: ${{ steps.calculate_tags.outputs.from_channel }}
commit_sha: ${{ steps.get_sha.outputs.commit_sha }}
steps:
- name: Checkout code
uses: actions/checkout@v6
@ -105,21 +106,154 @@ jobs:
fi
shell: bash
- name: Create and push new tag
if: ${{ !inputs.dry_run }}
env:
GH_TOKEN: ${{ github.token }}
- name: Determine previous tag
if: ${{ !inputs.dry_run && inputs.channel == 'internal' }}
id: previous_tag
run: |
FINAL_TAG="${{ steps.calculate_tags.outputs.final_tag }}"
if [[ "${{ inputs.channel }}" == "internal" ]]; then
# For internal, tag the current HEAD. tag_to_process and final_tag are the same.
git tag $FINAL_TAG
# Find the tag reachable from the parent of the current HEAD
# Exclude tags with hyphens to skip pre-releases
PREV_TAG=$(git describe --tags --abbrev=0 --exclude "*-*" HEAD 2>/dev/null || echo "")
echo "Found previous tag: $PREV_TAG"
echo "PREV_TAG=$PREV_TAG" >> $GITHUB_OUTPUT
- name: Update External Assets (Firmware, Hardware, Protos)
if: ${{ !inputs.dry_run && inputs.channel == 'internal' }}
run: |
# Update Submodules (Protobufs)
echo "Updating core/proto submodule..."
git submodule update --init --remote core/proto
# Update Firmware List
firmware_file_path="app/src/main/assets/firmware_releases.json"
temp_firmware_file="/tmp/new_firmware_releases.json"
echo "Fetching latest firmware releases..."
curl -s --fail https://api.meshtastic.org/github/firmware/list > "$temp_firmware_file"
if ! jq empty "$temp_firmware_file" 2>/dev/null; then
echo "::error::Firmware API returned invalid JSON data. Aborting."
exit 1
else
# For promotions, create the new tag pointing to the same commit as the old tag.
TAG_TO_PROCESS="${{ steps.calculate_tags.outputs.tag_to_process }}"
git tag $FINAL_TAG $TAG_TO_PROCESS
if [ ! -f "$firmware_file_path" ] || ! jq --sort-keys . "$temp_firmware_file" | diff -q - <(jq --sort-keys . "$firmware_file_path"); then
echo "Changes detected in firmware list or local file missing. Updating $firmware_file_path."
cp "$temp_firmware_file" "$firmware_file_path"
else
echo "No changes detected in firmware list."
fi
fi
git push origin $FINAL_TAG
# Update Hardware List
hardware_file_path="app/src/main/assets/device_hardware.json"
temp_hardware_file="/tmp/new_device_hardware.json"
echo "Fetching latest device hardware data..."
curl -s --fail https://api.meshtastic.org/resource/deviceHardware > "$temp_hardware_file"
if ! jq empty "$temp_hardware_file" 2>/dev/null; then
echo "::error::Hardware API returned invalid JSON data. Aborting."
exit 1
else
if [ ! -f "$hardware_file_path" ] || ! jq --sort-keys . "$temp_hardware_file" | diff -q - <(jq --sort-keys . "$hardware_file_path"); then
echo "Changes detected in hardware list or local file missing. Updating $hardware_file_path."
cp "$temp_hardware_file" "$hardware_file_path"
else
echo "No changes detected in hardware list."
fi
fi
- name: Sync with Crowdin
if: ${{ !inputs.dry_run && inputs.channel == 'internal' }}
uses: crowdin/github-action@v2
with:
base_url: 'https://meshtastic.crowdin.com/api/v2'
config: 'crowdin.yml'
crowdin_branch_name: 'main'
upload_sources: true
upload_sources_args: '--preserve-hierarchy'
upload_translations: false
download_translations: true
download_translations_args: '--preserve-hierarchy'
create_pull_request: false
push_translations: false
push_sources: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: Generate Changelog Content
if: ${{ !inputs.dry_run && inputs.channel == 'internal' && steps.previous_tag.outputs.PREV_TAG != '' }}
uses: mikepenz/release-changelog-builder-action@v6
id: build_changelog
with:
configuration: .github/release.yml
fromTag: ${{ steps.previous_tag.outputs.PREV_TAG }}
toTag: HEAD
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit Release Assets (Changelog, Translations, Data, Config)
if: ${{ !inputs.dry_run && inputs.channel == 'internal' }}
env:
CHANGELOG: ${{ steps.build_changelog.outputs.changelog }}
FINAL_TAG: ${{ steps.calculate_tags.outputs.final_tag }}
run: |
# Calculate Version Code
OFFSET=$(grep '^VERSION_CODE_OFFSET=' config.properties | cut -d'=' -f2)
COMMIT_COUNT=$(git rev-list --count HEAD)
# +1 because we are about to add a commit
VERSION_CODE=$((COMMIT_COUNT + OFFSET + 1))
echo "Calculated Version Code: $VERSION_CODE"
# Update VERSION_NAME_BASE in config.properties
sed -i "s/^VERSION_NAME_BASE=.*/VERSION_NAME_BASE=${{ inputs.base_version }}/" config.properties
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
# Add changelog if generated
if [ ! -z "$CHANGELOG" ]; then
FILE_PATH="fastlane/metadata/android/en-US/changelogs/${VERSION_CODE}.txt"
echo "$CHANGELOG" > "$FILE_PATH"
git add "$FILE_PATH"
fi
# Add updated data files
git add config.properties
git add app/src/main/assets/firmware_releases.json || true
git add app/src/main/assets/device_hardware.json || true
git add core/proto || true
# Add updated translations (fastlane metadata and strings)
git add fastlane/metadata/android || true
git add "**/strings.xml" || true
# Only commit if there are changes
if ! git diff --cached --quiet; then
git commit -m "chore(release): prepare $FINAL_TAG [skip ci]
- Bump base version to ${{ inputs.base_version }}
- Add changelog for version code $VERSION_CODE
- Sync translations and assets"
git push
else
echo "No changes to commit."
fi
shell: bash
- name: Get Commit SHA to Tag
id: get_sha
run: |
if [[ "${{ inputs.channel }}" == "internal" ]]; then
# Internal build uses the latest commit (including any asset updates)
SHA=$(git rev-parse HEAD)
else
# Promotions use the SHA of the tag we are promoting
TAG_TO_PROCESS="${{ steps.calculate_tags.outputs.tag_to_process }}"
SHA=$(git rev-parse $TAG_TO_PROCESS)
fi
echo "commit_sha=$SHA" >> $GITHUB_OUTPUT
shell: bash
call-release-workflow:
@ -127,7 +261,8 @@ jobs:
needs: determine-tags
uses: ./.github/workflows/release.yml
with:
tag_name: ${{ needs.determine-tags.outputs.tag_to_process }}
tag_name: ${{ needs.determine-tags.outputs.final_tag }}
commit_sha: ${{ needs.determine-tags.outputs.commit_sha }}
channel: ${{ inputs.channel }}
base_version: ${{ inputs.base_version }}
secrets: inherit
@ -140,6 +275,7 @@ jobs:
tag_name: ${{ needs.determine-tags.outputs.tag_to_process }}
release_name: ${{ needs.determine-tags.outputs.release_name }}
final_tag: ${{ needs.determine-tags.outputs.final_tag }}
commit_sha: ${{ needs.determine-tags.outputs.commit_sha }}
channel: ${{ inputs.channel }}
base_version: ${{ inputs.base_version }}
from_channel: ${{ needs.determine-tags.outputs.from_channel }}