diff --git a/.github/actions/calculate-version-code/action.yml b/.github/actions/calculate-version-code/action.yml deleted file mode 100644 index 3af727e6f..000000000 --- a/.github/actions/calculate-version-code/action.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: 'Calculate Version Code' -description: 'Calculates the Android versionCode based on the Git commit count plus an offset.' -outputs: - versionCode: - description: "The calculated version code" - value: ${{ steps.calculate_version.outputs.VERSION_CODE }} -runs: - using: 'composite' - steps: - - name: Calculate Version Code - id: calculate_version - shell: bash - run: | - # This action assumes that the repo has been checked out with `fetch-depth: 0` - GIT_COMMIT_COUNT=$(git rev-list --count HEAD) - OFFSET=30630 - VERSION_CODE=$((GIT_COMMIT_COUNT + OFFSET)) - echo "Calculated versionCode: $VERSION_CODE (from $GIT_COMMIT_COUNT commits + $OFFSET offset)" - echo "VERSION_CODE=$VERSION_CODE" >> $GITHUB_OUTPUT diff --git a/.github/workflows/create-or-promote-release.yml b/.github/workflows/create-or-promote-release.yml index 7b1365186..89d6254db 100644 --- a/.github/workflows/create-or-promote-release.yml +++ b/.github/workflows/create-or-promote-release.yml @@ -106,112 +106,6 @@ jobs: fi shell: bash - - 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 - 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 - - # 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: Commit Release Assets (Translations, Data, Config) - if: ${{ !inputs.dry_run && inputs.channel == 'internal' }} - env: - 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 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 }} - - Sync translations and assets" - git push origin HEAD:${{ github.ref_name }} - else - echo "No changes to commit." - fi - shell: bash - - name: Create and Push Release Tag if: ${{ !inputs.dry_run && inputs.channel == 'internal' }} env: @@ -244,3 +138,19 @@ jobs: base_version: ${{ inputs.base_version }} from_channel: ${{ needs.determine-tags.outputs.from_channel }} secrets: inherit + + cleanup-on-failure: + needs: [determine-tags, call-release-workflow] + if: ${{ failure() && !inputs.dry_run && inputs.channel == 'internal' }} + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v6 + with: + fetch-depth: 0 + - name: Delete Failed Tag + env: + FINAL_TAG: ${{ needs.determine-tags.outputs.final_tag }} + run: | + echo "Release workflow failed. Deleting tag $FINAL_TAG to allow a clean retry..." + git push origin :refs/tags/"$FINAL_TAG" || echo "Tag was not pushed or already deleted." diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 84b7b70a3..41e5c1954 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,15 +60,6 @@ permissions: attestations: write jobs: - run-lint: - uses: ./.github/workflows/reusable-check.yml - with: - run_lint: true - run_unit_tests: false - run_instrumented_tests: false - upload_artifacts: false - secrets: inherit - prepare-build-info: runs-on: ubuntu-latest outputs: @@ -85,19 +76,6 @@ jobs: ref: ${{ inputs.tag_name }} fetch-depth: 0 submodules: 'recursive' - - name: Set up JDK 17 - uses: actions/setup-java@v5 - with: - java-version: '17' - distribution: 'jetbrains' - - name: Setup Gradle - uses: gradle/actions/setup-gradle@v5 - with: - cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - build-scan-publish: true - build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service' - build-scan-terms-of-use-agree: 'yes' - - name: Determine Version Name from Tag id: get_version_name run: echo "APP_VERSION_NAME=$(echo ${{ inputs.tag_name }} | sed 's/-.*//' | sed 's/v//')" >> $GITHUB_OUTPUT @@ -119,7 +97,7 @@ jobs: release-google: runs-on: ubuntu-latest - needs: [prepare-build-info, run-lint] + needs: [prepare-build-info] environment: Release env: GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }} @@ -210,7 +188,7 @@ jobs: release-fdroid: runs-on: ubuntu-latest - needs: [prepare-build-info, run-lint] + needs: [prepare-build-info] environment: Release env: GRADLE_CACHE_URL: ${{ secrets.GRADLE_CACHE_URL }} @@ -286,7 +264,6 @@ jobs: uses: actions/checkout@v6 with: ref: ${{ inputs.tag_name }} - fetch-depth: 0 - name: Download all artifacts uses: actions/download-artifact@v8 @@ -297,6 +274,7 @@ jobs: uses: softprops/action-gh-release@v2 with: tag_name: ${{ inputs.tag_name }} + target_commitish: ${{ inputs.commit_sha || github.sha }} name: ${{ inputs.tag_name }} (${{ needs.prepare-build-info.outputs.APP_VERSION_CODE }}) generate_release_notes: false files: ./artifacts/*/* diff --git a/.github/workflows/reusable-check.yml b/.github/workflows/reusable-check.yml index 9805e1a17..b7df32393 100644 --- a/.github/workflows/reusable-check.yml +++ b/.github/workflows/reusable-check.yml @@ -75,16 +75,12 @@ jobs: with: dependency-graph: generate-and-submit cache-encryption-key: ${{ secrets.GRADLE_ENCRYPTION_KEY }} - cache-cleanup: true + cache-cleanup: on-success build-scan-publish: true build-scan-terms-of-use-url: 'https://gradle.com/terms-of-service' build-scan-terms-of-use-agree: 'yes' add-job-summary: always - - name: Calculate Version Code - id: calculate_version_code - uses: ./.github/actions/calculate-version-code - - name: Determine Tasks id: tasks run: | @@ -120,8 +116,6 @@ jobs: - name: Run Flavor Check (with Emulator) if: inputs.run_instrumented_tests == true uses: reactivecircus/android-emulator-runner@v2 - env: - VERSION_CODE: ${{ steps.calculate_version_code.outputs.versionCode }} with: api-level: ${{ matrix.api_level }} arch: x86_64 @@ -132,8 +126,6 @@ jobs: - name: Run Flavor Check (no Emulator) if: inputs.run_instrumented_tests == false - env: - VERSION_CODE: ${{ steps.calculate_version_code.outputs.versionCode }} run: ./gradlew ${{ steps.tasks.outputs.tasks }} -Pci=true -PenableComposeCompilerMetrics=true -PenableComposeCompilerReports=true --parallel --configuration-cache --continue --scan - name: Upload coverage results to Codecov