Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 23 additions & 8 deletions .github/actions/deploy-to-s3/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,41 @@ runs:
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
version_code=$(echo "$filename" | sed -n -E 's/.*-([0-9]+)-${{ inputs.build-flavour }}-${{ inputs.build-variant }}\.apk/\1/p')

if [[ -z "$version" ]]; then
echo "Failed to extract version"
echo "filename=$filename"
exit 1
fi

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"
mapping_full_path=$(find app/build/outputs/mapping -type f -name mapping.txt | grep "/${{ inputs.build-flavour }}" | head -n1)

if [[ -z "$mapping_full_path" ]]; then
echo "Failed to locate mapping.txt for ${{ inputs.build-flavour }}${{ inputs.build-variant }}"
find app/build/outputs/mapping -type f -name mapping.txt
exit 1
fi

if [[ -n "${{ env.VERSION_CODE }}" ]]; then
new_mapping_file_name="mapping-${{ env.VERSION }}-${{ env.VERSION_CODE }}-${{ inputs.build-flavour }}-${{ inputs.build-variant }}.txt"
else
# e.g. FDroid does not have version code
new_mapping_file_name="mapping-${{ env.VERSION }}-${{ inputs.build-flavour }}-${{ inputs.build-variant }}.txt"
fi

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
Expand Down
Loading