From 212fc912e360ac2a9d12036d8f2bf19849d6a4fd Mon Sep 17 00:00:00 2001 From: Eduardo Menges Mattje Date: Mon, 11 Nov 2024 18:31:38 -0300 Subject: [PATCH] Fix --- .github/workflows/build-targets.yml | 51 +++++++++++++++-------------- 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build-targets.yml b/.github/workflows/build-targets.yml index f0d3e9df..b0858417 100644 --- a/.github/workflows/build-targets.yml +++ b/.github/workflows/build-targets.yml @@ -113,7 +113,7 @@ jobs: if: ${{ matrix.target == 'Linux' }} run: cmake -S build/${{matrix.target}} -B $BUILD_DIRECTORY -DCMAKE_BUILD_TYPE=${{matrix.build-type}} - - name: Creating release tag + - name: Create release tag id: create-release-tag run: | RELEASE_TAG='${{matrix.target}}-${{ github.ref_name }}-${{matrix.build-type}}' @@ -144,30 +144,30 @@ jobs: shell: bash - name: Check which targets need updating + id: check-targets working-directory: ${{env.BUILD_DIRECTORY}} run: | declare -A target_shas declare -A target_build_directories - echo Detecting targets - rg 'source_dir=(.*)' -u -r '$1' -g '*-source_dirinfo.txt' . + echo Detecting targets: + while IFS=':' read -r file src_dir; do if ${{matrix.host == 'windows-latest'}}; then - target="${file%-source_dirinfo.txt}" - target="${target##*\\}" - else - target="${file%-source_dirinfo.txt}" - target="${target##*/}" + file=$(cygpath -u ${file}) + src_dir=$(cygpath -u ${src_dir}) fi + target="${file%-source_dirinfo.txt}" + target="${target##*/}" - echo $target $src_dir + echo ${target}: ${src_dir} - sha=$(git -C "${src_dir}" rev-parse HEAD) + sha=$(git -C ${src_dir} rev-parse HEAD) target_shas[$target]=$sha - build_directory="${file%%*/}" + build_directory=$(echo $file | sed 's|^\(\./[^/]*\).*|\1|') target_build_directories[$target]=$build_directory done < <(rg 'source_dir=(.*)' -u -r '$1' -g '*-source_dirinfo.txt' .) @@ -201,21 +201,22 @@ jobs: fi done - echo "TARGETS_TO_UPDATE=${targets_to_update[@]}" >>$GITHUB_ENV - echo "SHA_OF_TARGETS_TO_UPDATE=${sha_of_targets_to_update[@]}" >>$GITHUB_ENV - echo "BUILD_DIRECTORIES_OF_TARGETS_TO_UPDATE=${build_directories_of_targets_to_update[@]}" >>$GITHUB_ENV - echo "UP_TO_DATE_TARGETS=${up_to_date_targets}" >>$GITHUB_ENV + echo "TARGETS_TO_UPDATE=${targets_to_update[@]}" >>$GITHUB_OUTPUT + echo "SHA_OF_TARGETS_TO_UPDATE=${sha_of_targets_to_update[@]}" >>$GITHUB_OUTPUT + echo "BUILD_DIRECTORIES_OF_TARGETS_TO_UPDATE=${build_directories_of_targets_to_update[@]}" >>$GITHUB_OUTPUT + echo "UP_TO_DATE_TARGETS=${up_to_date_targets}" >>$GITHUB_OUTPUT shell: bash - name: Download up to date targets working-directory: ${{env.BUILD_DIRECTORY}} run: | - up_to_date_targets=($UP_TO_DATE_TARGETS) + up_to_date_targets=(${{steps.check-targets.outputs.UP_TO_DATE_TARGETS}}) for target in "${up_to_date_targets[@]}"; do compressed_target="${target}-lib.tar.gz" echo Downloading ${compressed_target} - gh release download ${RELEASE_TAG} --pattern "${COMPRESSED_TARGET}" --clobber + gh release download ${RELEASE_TAG} --pattern "${compressed_target}" --clobber + tar -xvzf ${compressed_target} done shell: bash @@ -230,7 +231,7 @@ jobs: working-directory: ${{env.BUILD_DIRECTORY}} if: ${{matrix.host != 'windows-latest'}} run: | - targets_to_update=($TARGETS_TO_UPDATE) + targets_to_update=(${{steps.check-targets.outputs.TARGETS_TO_UPDATE}}) for target in "${targets_to_update[@]}"; do echo Building ${target} @@ -241,7 +242,7 @@ jobs: working-directory: ${{env.BUILD_DIRECTORY}} if: ${{matrix.host == 'windows-latest'}} run: | - $targets_to_update = $TARGETS_TO_UPDATE -split ' ' + $targets_to_update = "${{steps.check-targets.outputs.TARGETS_TO_UPDATE}}" -split ' ' foreach ($target in $targets_to_update) { Write-Host "Building $target" @@ -251,9 +252,9 @@ jobs: - name: Compress and upload targets working-directory: ${{env.BUILD_DIRECTORY}} run: | - targets_to_update=($TARGETS_TO_UPDATE) - build_directories=($BUILD_DIRECTORIES_OF_TARGETS_TO_UPDATE) - sha_of_targets=($SHA_OF_TARGETS_TO_UPDATE) + targets_to_update=(${{steps.check-targets.outputs.TARGETS_TO_UPDATE}}) + build_directories=(${{steps.check-targets.outputs.BUILD_DIRECTORIES_OF_TARGETS_TO_UPDATE}}) + sha_of_targets=(${{steps.check-targets.outputs.SHA_OF_TARGETS_TO_UPDATE}}) declare -A release_shas @@ -263,13 +264,15 @@ jobs: done < <(jq -r '.[] | "\(.name)=\(.sha)"' release.json) fi + echo Compressing targets + for i in "${!targets_to_update[@]}"; do target=${targets_to_update[$i]} compressed_file="${target}-lib.tar.gz" directory_to_compress="${build_directories[$i]}" - echo Compressing ${target} - tar --exclude="${directory_to_compress}/src" --exclude="${directory_to_compress}/tmp" -czf ${compressed_file} ${directory_to_compress} + echo ${target}: $directory_to_compress + tar --exclude="${directory_to_compress}/src" --exclude="${directory_to_compress}/tmp" -zfc ${compressed_file} ${directory_to_compress} echo -e "Uploading ${compressed_file}\n" gh release upload --clobber ${RELEASE_TAG} ${compressed_file}