From 1540e0e959387c10990e28db1844789fb52b8633 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 12:27:24 +0800 Subject: [PATCH 01/12] Removed CI platform related step --- .github/workflows/build-artifacts.yml | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index 729d61b..3675f02 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -44,15 +44,10 @@ jobs: - name: Build the application run: dotnet publish --configuration Release -r ${{ matrix.runtime }} - - name: Move artifacts - Windows - if: runner.os == 'Windows' + - name: Move artifacts shell: pwsh run: Move-Item -Path TuneLab\bin\Release\net8.0\${{ matrix.runtime }}\publish -Destination workspace - - name: Move artifacts - MacOS and Linux - if: runner.os != 'Windows' - run: mv TuneLab/bin/Release/net8.0/${{ matrix.runtime }}/publish workspace - - name: Generate artifact attestation - Windows if: runner.os == 'Windows' && github.event_name != 'pull_request' uses: actions/attest-build-provenance@v1 From f3171faebe2d9ffbb5ebda7fc25bbced0e1df0d9 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 13:00:06 +0800 Subject: [PATCH 02/12] Add CI elf files auto find --- .github/workflows/build-artifacts.yml | 10 +++++++++- CIUtils/find-executable.sh | 28 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 CIUtils/find-executable.sh diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index 3675f02..253ecb2 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -53,12 +53,20 @@ jobs: uses: actions/attest-build-provenance@v1 with: subject-path: '"workspace/*.dll","workspace/*.exe"' + + - name: Find ELF files - MacOS and Linux + if: runner.os != 'Windows' && github.event_name != 'pull_request' + id: find-elf-files + working-directory: ${{github.workspace}} + run: | + ELF_FILES=$(./CIUtils/find-executable.sh "workspace/") + echo "::set-output name=elf_files::$ELF_FILES" - name: Generate artifact attestation - MacOS and Linux if: runner.os != 'Windows' && github.event_name != 'pull_request' uses: actions/attest-build-provenance@v1 with: - subject-path: '"workspace/*.dll","workspace/ExtensionInstaller","workspace/TuneLab"' + subject-path: '"workspace/*.dll",${{ steps.find-elf-files.outputs.elf_files }}' - name: Get short SHA uses: benjlevesque/short-sha@v3.0 diff --git a/CIUtils/find-executable.sh b/CIUtils/find-executable.sh new file mode 100644 index 0000000..87394f1 --- /dev/null +++ b/CIUtils/find-executable.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Check if a directory is provided as an argument +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Directory to search +directory=$1 + +# Find ELF files in the specified directory +files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF" && echo "$1"' _ {} \;) + +# Initialize an empty string for the output +output="" + +# Loop through each file and format it +for file in $files; do + if [ -z "$output" ]; then + output="\"$file\"" + else + output="$output,\"$file\"" + fi +done + +# Print the formatted output +echo $output From cf5f8125ffb9bfc32580c08cfc6f30829960be99 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 13:03:46 +0800 Subject: [PATCH 03/12] Fixed CI script executable permission --- .github/workflows/build-artifacts.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index 253ecb2..b9f558e 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -59,6 +59,7 @@ jobs: id: find-elf-files working-directory: ${{github.workspace}} run: | + chmod +x ./CIUtils/find-executable.sh ELF_FILES=$(./CIUtils/find-executable.sh "workspace/") echo "::set-output name=elf_files::$ELF_FILES" From 238add1a651eac65c591381a0afe0cf509e50fd0 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 13:10:22 +0800 Subject: [PATCH 04/12] Fixed CI elf find result output --- .github/workflows/build-artifacts.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index b9f558e..f309d19 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -61,7 +61,8 @@ jobs: run: | chmod +x ./CIUtils/find-executable.sh ELF_FILES=$(./CIUtils/find-executable.sh "workspace/") - echo "::set-output name=elf_files::$ELF_FILES" + echo "Found ELF files: $ELF_FILES" + echo "elf_files=$ELF_FILES" >> $GITHUB_OUTPUT - name: Generate artifact attestation - MacOS and Linux if: runner.os != 'Windows' && github.event_name != 'pull_request' From e106b8f253d506c4dcc635e6b28314fb71b09424 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 13:27:19 +0800 Subject: [PATCH 05/12] Fixed CI MacOS executable and dynamic library file find --- .github/workflows/build-artifacts.yml | 12 ++++++------ CIUtils/find-executable.sh | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index f309d19..3bfca8b 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -54,21 +54,21 @@ jobs: with: subject-path: '"workspace/*.dll","workspace/*.exe"' - - name: Find ELF files - MacOS and Linux + - name: Find executable and dynamic library files - MacOS and Linux if: runner.os != 'Windows' && github.event_name != 'pull_request' - id: find-elf-files + id: find-executable-files working-directory: ${{github.workspace}} run: | chmod +x ./CIUtils/find-executable.sh - ELF_FILES=$(./CIUtils/find-executable.sh "workspace/") - echo "Found ELF files: $ELF_FILES" - echo "elf_files=$ELF_FILES" >> $GITHUB_OUTPUT + EXEC_FILES=$(./CIUtils/find-executable.sh "workspace/") + echo "Found executable and dynamic library files: $EXEC_FILES" + echo "exec_files=$EXEC_FILES" >> $GITHUB_OUTPUT - name: Generate artifact attestation - MacOS and Linux if: runner.os != 'Windows' && github.event_name != 'pull_request' uses: actions/attest-build-provenance@v1 with: - subject-path: '"workspace/*.dll",${{ steps.find-elf-files.outputs.elf_files }}' + subject-path: '"workspace/*.dll",${{ steps.find-executable-files.outputs.exec_files }}' - name: Get short SHA uses: benjlevesque/short-sha@v3.0 diff --git a/CIUtils/find-executable.sh b/CIUtils/find-executable.sh index 87394f1..d838e9d 100644 --- a/CIUtils/find-executable.sh +++ b/CIUtils/find-executable.sh @@ -9,8 +9,8 @@ fi # Directory to search directory=$1 -# Find ELF files in the specified directory -files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF" && echo "$1"' _ {} \;) +# Find ELF, Mach-O and Universal Binary files in the specified directory +files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF|Mach-O|universal binary" && echo "$1"' _ {} \;) # Initialize an empty string for the output output="" From afb8e72dcd01b2b52009c05a298870c8be7a9192 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 13:37:24 +0800 Subject: [PATCH 06/12] Fixed CI executable find scripts for multi platforms --- CIUtils/find-elf.sh | 28 ++++++++++++++++++++++++++ CIUtils/find-executable.sh | 40 ++++++++++++++------------------------ CIUtils/find-macho.sh | 28 ++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 CIUtils/find-elf.sh create mode 100644 CIUtils/find-macho.sh diff --git a/CIUtils/find-elf.sh b/CIUtils/find-elf.sh new file mode 100644 index 0000000..87394f1 --- /dev/null +++ b/CIUtils/find-elf.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Check if a directory is provided as an argument +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Directory to search +directory=$1 + +# Find ELF files in the specified directory +files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF" && echo "$1"' _ {} \;) + +# Initialize an empty string for the output +output="" + +# Loop through each file and format it +for file in $files; do + if [ -z "$output" ]; then + output="\"$file\"" + else + output="$output,\"$file\"" + fi +done + +# Print the formatted output +echo $output diff --git a/CIUtils/find-executable.sh b/CIUtils/find-executable.sh index d838e9d..e6ddb4c 100644 --- a/CIUtils/find-executable.sh +++ b/CIUtils/find-executable.sh @@ -1,28 +1,18 @@ #!/bin/bash -# Check if a directory is provided as an argument -if [ -z "$1" ]; then - echo "Usage: $0 " - exit 1 -fi +# Detect the operating system +os_type=$(uname) -# Directory to search -directory=$1 - -# Find ELF, Mach-O and Universal Binary files in the specified directory -files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF|Mach-O|universal binary" && echo "$1"' _ {} \;) - -# Initialize an empty string for the output -output="" - -# Loop through each file and format it -for file in $files; do - if [ -z "$output" ]; then - output="\"$file\"" - else - output="$output,\"$file\"" - fi -done - -# Print the formatted output -echo $output +# Execute the corresponding script based on the operating system +case "$os_type" in + Linux) + echo $(./find-elf.sh "$1") + ;; + Darwin) + echo $(./find-macho.sh "$1") + ;; + *) + echo "Unsupported OS: $os_type" + exit 1 + ;; +esac diff --git a/CIUtils/find-macho.sh b/CIUtils/find-macho.sh new file mode 100644 index 0000000..84529c5 --- /dev/null +++ b/CIUtils/find-macho.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +# Check if a directory is provided as an argument +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Directory to search +directory=$1 + +# Find Mach-O and Universal Binary files in the specified directory +files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "Mach-O|universal binary" && echo "$1"' _ {} \;) + +# Initialize an empty string for the output +output="" + +# Loop through each file and format it +for file in $files; do + if [ -z "$output" ]; then + output="\"$file\"" + else + output="$output,\"$file\"" + fi +done + +# Print the formatted output +echo $output From feb8ba75fb4944d8dd279e92472ffd7abec0b9b0 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 13:43:22 +0800 Subject: [PATCH 07/12] Fixed CI script path --- .github/workflows/build-artifacts.yml | 2 +- CIUtils/find-executable.sh | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index 3bfca8b..0a0502a 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -59,7 +59,7 @@ jobs: id: find-executable-files working-directory: ${{github.workspace}} run: | - chmod +x ./CIUtils/find-executable.sh + find ./CIUtils/ -name "*.sh" -exec chmod +x {} \; EXEC_FILES=$(./CIUtils/find-executable.sh "workspace/") echo "Found executable and dynamic library files: $EXEC_FILES" echo "exec_files=$EXEC_FILES" >> $GITHUB_OUTPUT diff --git a/CIUtils/find-executable.sh b/CIUtils/find-executable.sh index e6ddb4c..ff62f04 100644 --- a/CIUtils/find-executable.sh +++ b/CIUtils/find-executable.sh @@ -1,15 +1,18 @@ #!/bin/bash +# Get the directory of the current script +script_dir=$(dirname "$0") + # Detect the operating system os_type=$(uname) # Execute the corresponding script based on the operating system case "$os_type" in Linux) - echo $(./find-elf.sh "$1") + echo $("$script_dir/find-elf.sh" "$1") ;; Darwin) - echo $(./find-macho.sh "$1") + echo $("$script_dir/find-macho.sh" "$1") ;; *) echo "Unsupported OS: $os_type" From 158d57a9b41f7f479c1889a30907c7ff531ee9e4 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 13:56:16 +0800 Subject: [PATCH 08/12] Fixed CI find Mach-O files --- CIUtils/find-macho.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/CIUtils/find-macho.sh b/CIUtils/find-macho.sh index 84529c5..d8dcb4a 100644 --- a/CIUtils/find-macho.sh +++ b/CIUtils/find-macho.sh @@ -9,20 +9,20 @@ fi # Directory to search directory=$1 -# Find Mach-O and Universal Binary files in the specified directory -files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "Mach-O|universal binary" && echo "$1"' _ {} \;) - # Initialize an empty string for the output output="" -# Loop through each file and format it -for file in $files; do - if [ -z "$output" ]; then - output="\"$file\"" - else - output="$output,\"$file\"" - fi -done +# Find Mach-O and Universal Binary files in the specified directory +find "$directory" -type f -exec sh -c ' + for file do + if file "$file" | grep -qE "Mach-O|universal binary"; then + if [ -n "$output" ]; then + output="${output}," + fi + output="${output}\"$file\"" + fi + done +' sh {} + -# Print the formatted output +# Print the output echo $output From 0004b8d8f2e1625980120549b94658f0c0c27a71 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 14:04:30 +0800 Subject: [PATCH 09/12] Fixed CI scripts executable file filter command --- CIUtils/find-elf.sh | 2 +- CIUtils/find-macho.sh | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/CIUtils/find-elf.sh b/CIUtils/find-elf.sh index 87394f1..3486615 100644 --- a/CIUtils/find-elf.sh +++ b/CIUtils/find-elf.sh @@ -10,7 +10,7 @@ fi directory=$1 # Find ELF files in the specified directory -files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -q "ELF" && echo "$1"' _ {} \;) +files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -qE "ELF" && echo "$1"' _ {} \;) # Initialize an empty string for the output output="" diff --git a/CIUtils/find-macho.sh b/CIUtils/find-macho.sh index d8dcb4a..700c56c 100644 --- a/CIUtils/find-macho.sh +++ b/CIUtils/find-macho.sh @@ -9,20 +9,20 @@ fi # Directory to search directory=$1 +# Find Mach-O and Universal Binary files in the specified directory +files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -qE "Mach-O|universal binary" && echo "$1"' _ {} \;) + # Initialize an empty string for the output output="" -# Find Mach-O and Universal Binary files in the specified directory -find "$directory" -type f -exec sh -c ' - for file do - if file "$file" | grep -qE "Mach-O|universal binary"; then - if [ -n "$output" ]; then - output="${output}," - fi - output="${output}\"$file\"" - fi - done -' sh {} + +# Loop through each file and format it +for file in $files; do + if [ -z "$output" ]; then + output="\"$file\"" + else + output="$output,\"$file\"" + fi +done -# Print the output +# Print the formatted output echo $output From 249622478bd5d6feb2a3ba6a3ac4e64994670720 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 14:12:21 +0800 Subject: [PATCH 10/12] Merged CI find executable scripts --- CIUtils/find-elf.sh | 28 -------------------------- CIUtils/find-executable.sh | 41 ++++++++++++++++++++++---------------- CIUtils/find-macho.sh | 28 -------------------------- 3 files changed, 24 insertions(+), 73 deletions(-) delete mode 100644 CIUtils/find-elf.sh delete mode 100644 CIUtils/find-macho.sh diff --git a/CIUtils/find-elf.sh b/CIUtils/find-elf.sh deleted file mode 100644 index 3486615..0000000 --- a/CIUtils/find-elf.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Check if a directory is provided as an argument -if [ -z "$1" ]; then - echo "Usage: $0 " - exit 1 -fi - -# Directory to search -directory=$1 - -# Find ELF files in the specified directory -files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -qE "ELF" && echo "$1"' _ {} \;) - -# Initialize an empty string for the output -output="" - -# Loop through each file and format it -for file in $files; do - if [ -z "$output" ]; then - output="\"$file\"" - else - output="$output,\"$file\"" - fi -done - -# Print the formatted output -echo $output diff --git a/CIUtils/find-executable.sh b/CIUtils/find-executable.sh index ff62f04..daf3355 100644 --- a/CIUtils/find-executable.sh +++ b/CIUtils/find-executable.sh @@ -1,21 +1,28 @@ #!/bin/bash -# Get the directory of the current script -script_dir=$(dirname "$0") +# Check if a directory is provided as an argument +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi -# Detect the operating system -os_type=$(uname) +# Directory to search +directory=$1 -# Execute the corresponding script based on the operating system -case "$os_type" in - Linux) - echo $("$script_dir/find-elf.sh" "$1") - ;; - Darwin) - echo $("$script_dir/find-macho.sh" "$1") - ;; - *) - echo "Unsupported OS: $os_type" - exit 1 - ;; -esac +# Find ELF, Mach-O and Universal Binary files in the specified directory +files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -qE "ELF|Mach-O|universal binary" && echo "$1"' _ {} \;) + +# Initialize an empty string for the output +output="" + +# Loop through each file and format it +for file in $files; do + if [ -z "$output" ]; then + output="\"$file\"" + else + output="$output,\"$file\"" + fi +done + +# Print the formatted output +echo $output diff --git a/CIUtils/find-macho.sh b/CIUtils/find-macho.sh deleted file mode 100644 index 700c56c..0000000 --- a/CIUtils/find-macho.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -# Check if a directory is provided as an argument -if [ -z "$1" ]; then - echo "Usage: $0 " - exit 1 -fi - -# Directory to search -directory=$1 - -# Find Mach-O and Universal Binary files in the specified directory -files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -qE "Mach-O|universal binary" && echo "$1"' _ {} \;) - -# Initialize an empty string for the output -output="" - -# Loop through each file and format it -for file in $files; do - if [ -z "$output" ]; then - output="\"$file\"" - else - output="$output,\"$file\"" - fi -done - -# Print the formatted output -echo $output From 6e959fbe631d0a327b003d09c5ceba223f1311e5 Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 14:15:40 +0800 Subject: [PATCH 11/12] Add CI shell specification --- .github/workflows/build-artifacts.yml | 1 + .github/workflows/upload-release.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/build-artifacts.yml b/.github/workflows/build-artifacts.yml index 0a0502a..3bfcd4a 100644 --- a/.github/workflows/build-artifacts.yml +++ b/.github/workflows/build-artifacts.yml @@ -57,6 +57,7 @@ jobs: - name: Find executable and dynamic library files - MacOS and Linux if: runner.os != 'Windows' && github.event_name != 'pull_request' id: find-executable-files + shell: bash working-directory: ${{github.workspace}} run: | find ./CIUtils/ -name "*.sh" -exec chmod +x {} \; diff --git a/.github/workflows/upload-release.yml b/.github/workflows/upload-release.yml index de06f9e..66fce7e 100644 --- a/.github/workflows/upload-release.yml +++ b/.github/workflows/upload-release.yml @@ -85,6 +85,7 @@ jobs: - name: Package - MacOS and Linux if: runner.os != 'Windows' + shell: bash working-directory: ${{github.workspace}} run: tar -zcvf package.tar.gz ./* From 0aec06973f43a3c1571b911cdcf7e5d770cdbd4d Mon Sep 17 00:00:00 2001 From: WuChang <3142324836@qq.com> Date: Wed, 31 Jul 2024 14:23:31 +0800 Subject: [PATCH 12/12] Fixed CI execuble find script result multi slash --- CIUtils/find-executable.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CIUtils/find-executable.sh b/CIUtils/find-executable.sh index daf3355..9871c95 100644 --- a/CIUtils/find-executable.sh +++ b/CIUtils/find-executable.sh @@ -10,7 +10,7 @@ fi directory=$1 # Find ELF, Mach-O and Universal Binary files in the specified directory -files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -qE "ELF|Mach-O|universal binary" && echo "$1"' _ {} \;) +files=$(find "$directory" -type f -exec sh -c 'file -b "$1" | grep -qE "ELF|Mach-O|universal binary" && echo "$1" | sed "s:/\{1,\}:/:g"' _ {} \;) # Initialize an empty string for the output output=""