From c7d173cf9a0b9ddd559000fab6b700937b341c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lison=20Fernandes?= Date: Thu, 26 Feb 2026 18:56:45 +0000 Subject: [PATCH] [PM-32751] ci: Fix version name output in run summary (#6585) --- .github/scripts/set-build-version.sh | 23 +++++++++++++++++++++++ .github/workflows/build-authenticator.yml | 19 +++---------------- .github/workflows/build-testharness.yml | 19 +++---------------- .github/workflows/build.yml | 23 ++++------------------- 4 files changed, 33 insertions(+), 51 deletions(-) create mode 100755 .github/scripts/set-build-version.sh diff --git a/.github/scripts/set-build-version.sh b/.github/scripts/set-build-version.sh new file mode 100755 index 0000000000..0de27f5e89 --- /dev/null +++ b/.github/scripts/set-build-version.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Runs fastlane setBuildVersionInfo and appends Version Name/Number to GITHUB_STEP_SUMMARY. +# Usage: set-build-version.sh [version_name] [toml_path] + +VERSION_CODE="${1:?Usage: $0 [version_name] [toml_path]}" +VERSION_NAME="${2:-}" +TOML_FILE="${3:-gradle/libs.versions.toml}" + +bundle exec fastlane setBuildVersionInfo \ + versionCode:"$VERSION_CODE" \ + versionName:"$VERSION_NAME" + +if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then + VERSION_NAME="" + regex='appVersionName = "([^"]+)"' + if [[ "$(cat "$TOML_FILE")" =~ $regex ]]; then + VERSION_NAME="${BASH_REMATCH[1]}" + fi + echo "Version Name: ${VERSION_NAME}" >> "$GITHUB_STEP_SUMMARY" + echo "Version Number: $VERSION_CODE" >> "$GITHUB_STEP_SUMMARY" +fi diff --git a/.github/workflows/build-authenticator.yml b/.github/workflows/build-authenticator.yml index 9b531d0b1c..973cff49d1 100644 --- a/.github/workflows/build-authenticator.yml +++ b/.github/workflows/build-authenticator.yml @@ -171,22 +171,9 @@ jobs: - name: Increment version env: - DEFAULT_VERSION_CODE: ${{ github.run_number }} - INPUT_VERSION_CODE: "${{ needs.version.outputs.version_number }}" - INPUT_VERSION_NAME: ${{ needs.version.outputs.version_name }} - run: | - VERSION_CODE="${INPUT_VERSION_CODE:-$DEFAULT_VERSION_CODE}" - VERSION_NAME_INPUT="${INPUT_VERSION_NAME:-}" - bundle exec fastlane setBuildVersionInfo \ - versionCode:"$VERSION_CODE" \ - versionName:"$VERSION_NAME_INPUT" - - regex='appVersionName = "([^"]+)"' - if [[ "$(cat gradle/libs.versions.toml)" =~ $regex ]]; then - VERSION_NAME="${BASH_REMATCH[1]}" - fi - echo "Version Name: ${VERSION_NAME}" >> "$GITHUB_STEP_SUMMARY" - echo "Version Number: $VERSION_CODE" >> "$GITHUB_STEP_SUMMARY" + VERSION_CODE: ${{ needs.version.outputs.version_number || github.run_number }} + VERSION_NAME: ${{ needs.version.outputs.version_name }} + run: ./.github/scripts/set-build-version.sh "$VERSION_CODE" "$VERSION_NAME" - name: Generate release Play Store bundle if: ${{ matrix.variant == 'aab' }} diff --git a/.github/workflows/build-testharness.yml b/.github/workflows/build-testharness.yml index e5d0663890..04e11d2004 100644 --- a/.github/workflows/build-testharness.yml +++ b/.github/workflows/build-testharness.yml @@ -57,22 +57,9 @@ jobs: - name: Increment version env: - DEFAULT_VERSION_CODE: ${{ github.run_number }} - INPUT_VERSION_CODE: "${{ needs.version.outputs.version_number }}" - INPUT_VERSION_NAME: ${{ needs.version.outputs.version_name }} - run: | - VERSION_CODE="${INPUT_VERSION_CODE:-$DEFAULT_VERSION_CODE}" - VERSION_NAME_INPUT="${INPUT_VERSION_NAME:-}" - bundle exec fastlane setBuildVersionInfo \ - versionCode:"$VERSION_CODE" \ - versionName:"$VERSION_NAME_INPUT" - - regex='appVersionName = "(.+)"' - if [[ "$(cat gradle/libs.versions.toml)" =~ $regex ]]; then - VERSION_NAME="${BASH_REMATCH[1]}" - fi - echo "Version Name: ${VERSION_NAME}" >> "$GITHUB_STEP_SUMMARY" - echo "Version Number: $VERSION_CODE" >> "$GITHUB_STEP_SUMMARY" + VERSION_CODE: ${{ needs.version.outputs.version_number || github.run_number }} + VERSION_NAME: ${{ needs.version.outputs.version_name }} + run: ./.github/scripts/set-build-version.sh "$VERSION_CODE" "$VERSION_NAME" - name: Build Test Harness Debug APK run: ./gradlew :testharness:assembleDebug diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3a22d140cb..345897848d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -167,13 +167,9 @@ jobs: - name: Increment version env: - VERSION_CODE: ${{ needs.version.outputs.version_number }} + VERSION_CODE: ${{ needs.version.outputs.version_number || github.run_number }} VERSION_NAME: ${{ needs.version.outputs.version_name }} - run: | - VERSION_CODE="${VERSION_CODE:-$GITHUB_RUN_NUMBER}" - bundle exec fastlane setBuildVersionInfo \ - versionCode:$VERSION_CODE \ - versionName:$VERSION_NAME + run: ./.github/scripts/set-build-version.sh "$VERSION_CODE" "$VERSION_NAME" - name: Generate release Play Store bundle if: ${{ matrix.variant == 'prod' && matrix.artifact == 'aab' }} @@ -436,20 +432,9 @@ jobs: - name: Increment version env: - VERSION_CODE: ${{ needs.version.outputs.version_number }} + VERSION_CODE: ${{ needs.version.outputs.version_number || github.run_number }} VERSION_NAME: ${{ needs.version.outputs.version_name }} - run: | - VERSION_CODE="${VERSION_CODE:-$GITHUB_RUN_NUMBER}" - bundle exec fastlane setBuildVersionInfo \ - versionCode:$VERSION_CODE \ - versionName:$VERSION_NAME - - regex='appVersionName = "([^"]+)"' - if [[ "$(cat gradle/libs.versions.toml)" =~ $regex ]]; then - VERSION_NAME="${BASH_REMATCH[1]}" - fi - echo "Version Name: ${VERSION_NAME}" >> "$GITHUB_STEP_SUMMARY" - echo "Version Number: $VERSION_CODE" >> "$GITHUB_STEP_SUMMARY" + run: ./.github/scripts/set-build-version.sh "$VERSION_CODE" "$VERSION_NAME" - name: Generate F-Droid artifacts env: FDROID_STORE_PASSWORD: ${{ steps.get-kv-secrets.outputs.FDROID-KEYSTORE-PASSWORD }}