From a2bacb292e4f19b1783f48f361c92c725e340d6a Mon Sep 17 00:00:00 2001 From: SpaiR Date: Thu, 15 Dec 2022 12:36:35 +0200 Subject: [PATCH] [Build] Update artifacts only when needed (#150) --- .github/workflows/ci.yml | 29 +++++++++++++++++++++-------- buildSrc/scripts/equal_file_size.py | 8 ++++++++ 2 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 buildSrc/scripts/equal_file_size.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a571776..016a282d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -69,16 +69,16 @@ jobs: - name: Ant Version run: ant -version - - if: matrix.os == 'ubuntu-latest' - name: Install MinGW-w64/GCC/G++ (Linux & Windows) + - name: Install MinGW-w64/GCC/G++ (Linux & Windows) + if: matrix.os == 'ubuntu-latest' run: sudo apt install mingw-w64 - - if: matrix.os == 'ubuntu-latest' && matrix.type == 'linux' && matrix.freetype == true - name: FreeType - Install (Linux) + - name: FreeType - Install (Linux) + if: matrix.os == 'ubuntu-latest' && matrix.type == 'linux' && matrix.freetype == true run: sudo apt install libfreetype6-dev - - if: matrix.os == 'ubuntu-latest' && matrix.type == 'windows' && matrix.freetype == true - name: FreeType - Install (Windows) + - name: FreeType - Install (Windows) + if: matrix.os == 'ubuntu-latest' && matrix.type == 'windows' && matrix.freetype == true run: | sudo mkdir /freetype sudo tar -xzf ./vendor/freetype-2.12.1.tar.gz -C /freetype --strip-components=1 @@ -98,8 +98,8 @@ jobs: path: ${{ matrix.expected }} update-bin: - if: github.ref == 'refs/heads/main' # runs only on the main branch name: Update Binaries + if: github.ref == 'refs/heads/main' # runs only on the main branch runs-on: ubuntu-latest needs: build-natives steps: @@ -111,20 +111,33 @@ jobs: with: path: /tmp/artifacts + - name: Equal Artifacts + id: equal-artifacts + continue-on-error: true + run: | + python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries/imgui-java64.dll bin/imgui-java64.dll + python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries/libimgui-java64.dylib bin/libimgui-java64.dylib + python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries/libimgui-java64.so bin/libimgui-java64.so + python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries-with-freetype/imgui-java64.dll bin/freetype/imgui-java64.dll + python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries-with-freetype/libimgui-java64.dylib bin/freetype/libimgui-java64.dylib + python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries-with-freetype/libimgui-java64.so bin/freetype/libimgui-java64.so + - name: Update + if: steps.equal-artifacts.outcome != 'success' run: | mv /tmp/artifacts/native-libraries/* bin/ mv /tmp/artifacts/native-libraries-with-freetype/* bin/freetype/ - name: Commit + if: steps.equal-artifacts.outcome != 'success' uses: EndBug/add-and-commit@v9 with: default_author: github_actions message: '[ci skip] update native binaries' release: - if: startsWith(github.ref, 'refs/tags/v') # if tag starts with "v" name: Release + if: startsWith(github.ref, 'refs/tags/v') # if tag starts with "v" runs-on: ubuntu-latest needs: [ build-java, build-natives ] steps: diff --git a/buildSrc/scripts/equal_file_size.py b/buildSrc/scripts/equal_file_size.py new file mode 100644 index 00000000..4a4323e5 --- /dev/null +++ b/buildSrc/scripts/equal_file_size.py @@ -0,0 +1,8 @@ +import sys +import os + +# A python script to compare file size of two files. +# Used to compare sizes of binaries to see, if there is a difference between them. +# Shell scripts are not used, since Python is a more portable solution. + +os.path.getsize(sys.argv[1]) == os.path.getsize(sys.argv[2]) if sys.exit(0) else sys.exit(1)