Skip to content

Commit

Permalink
[Build] Update artifacts only when needed (#150)
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaiR authored Dec 15, 2022
1 parent 8356d76 commit a2bacb2
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
29 changes: 21 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand Down
8 changes: 8 additions & 0 deletions buildSrc/scripts/equal_file_size.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a2bacb2

Please sign in to comment.