From 36b2a8730de4ce644e02a9af6d199fb3108b9d32 Mon Sep 17 00:00:00 2001 From: Oussama Hassine Date: Mon, 20 Jan 2025 13:13:58 +0100 Subject: [PATCH] chore: upload mapping file to s3 (WPB-8774) (#3713) Co-authored-by: Yamil Medina --- .github/actions/deploy-to-s3/action.yml | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/.github/actions/deploy-to-s3/action.yml b/.github/actions/deploy-to-s3/action.yml index 74e312278f..73dee3c2cb 100644 --- a/.github/actions/deploy-to-s3/action.yml +++ b/.github/actions/deploy-to-s3/action.yml @@ -64,3 +64,57 @@ runs: GITHUB_TOKEN: ${{ inputs.github-token }} run: | gh pr comment "${{ github.event.pull_request.number }}" --body "Built [wire-android-${{ inputs.build-flavour }}-${{ inputs.build-variant }}-pr-${{ github.event.pull_request.number }}.apk](${{ steps.upload.outputs.file-url }}) is available for download" + - name: Extract version and version code from APK filename + shell: bash + run: | + filename=${{ steps.path.outputs.apk_full_path }} + + # Extract version name and version code + version=$(echo "$filename" | sed -E 's/.*-v([0-9]+\.[0-9]+\.[0-9]+).*/\1/') + version_code=$(echo "$filename" | sed -E 's/.*-([0-9]+)-${{ inputs.build-flavour }}-${{ inputs.build-variant }}\.apk/\1/') + + # Print the extracted version and version code + echo "Extracted version: v$version" + echo "Extracted version code: $version_code" + + # set them as environment variables for later use + echo "VERSION=v$version" >> $GITHUB_ENV + echo "VERSION_CODE=$version_code" >> $GITHUB_ENV + - name: Rename mapping file + if: ${{ inputs.build-variant != 'debug' }} + shell: bash + id: mapping + run: | + capitalized_variant=$(echo "${{ inputs.build-variant }}" | awk '{print toupper(substr($0,1,1)) tolower(substr($0,2))}') + echo "Capitalized Variant: $capitalized_variant" + mapping_full_path="app/build/outputs/mapping/${{ inputs.build-flavour }}${capitalized_variant}/mapping.txt" + new_mapping_file_name="mapping-${{ env.VERSION }}-${{ env.VERSION_CODE }}-${{ inputs.build-flavour }}-${{ inputs.build-variant }}.txt" + mv "$mapping_full_path" "$new_mapping_file_name" + # Set the new mapping file name as an environment variable + echo "new_mapping_file_name=$new_mapping_file_name" >> $GITHUB_ENV + - name: Upload mapping file to S3 from branch + if: ${{ github.event.pull_request.number == '' && inputs.build-variant != 'debug' }} + id: upload-mapping-from-branch + uses: hkusu/s3-upload-action@v2.1.0 + with: + aws-access-key-id: ${{ inputs.aws-access-key-id }} + aws-secret-access-key: ${{ inputs.aws-secret-access-key }} + aws-region: 'eu-central-1' + aws-bucket: ${{ inputs.aws-bucket }} + destination-dir: "megazord/android/reloaded/${{ inputs.build-flavour }}/${{ inputs.build-variant }}/" + file-path: ${{ env.new_mapping_file_name }} + output-file-url: 'false' + public: false + - name: Upload mapping file to S3 from PR + if: ${{ github.event.pull_request.number != '' && inputs.build-variant != 'debug' }} + id: upload-mapping-from-PR + uses: hkusu/s3-upload-action@v2.1.0 + with: + aws-access-key-id: ${{ inputs.aws-access-key-id }} + aws-secret-access-key: ${{ inputs.aws-secret-access-key }} + aws-region: 'eu-central-1' + aws-bucket: ${{ inputs.aws-bucket }} + destination-dir: "megazord/android/reloaded/${{ inputs.build-flavour }}/${{ inputs.build-variant }}/PR-${{ github.event.pull_request.number }}/" + file-path: ${{ env.new_mapping_file_name }} + output-file-url: 'false' + public: false