Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
EduMenges committed Nov 12, 2024
1 parent bdfb0eb commit 212fc91
Showing 1 changed file with 27 additions and 24 deletions.
51 changes: 27 additions & 24 deletions .github/workflows/build-targets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}}'
Expand Down Expand Up @@ -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' .)
Expand Down Expand Up @@ -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

Expand All @@ -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}
Expand All @@ -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"
Expand All @@ -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
Expand All @@ -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}
Expand Down

0 comments on commit 212fc91

Please sign in to comment.