Skip to content

Commit a2bacb2

Browse files
authored
[Build] Update artifacts only when needed (#150)
1 parent 8356d76 commit a2bacb2

File tree

2 files changed

+29
-8
lines changed

2 files changed

+29
-8
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ jobs:
6969
- name: Ant Version
7070
run: ant -version
7171

72-
- if: matrix.os == 'ubuntu-latest'
73-
name: Install MinGW-w64/GCC/G++ (Linux & Windows)
72+
- name: Install MinGW-w64/GCC/G++ (Linux & Windows)
73+
if: matrix.os == 'ubuntu-latest'
7474
run: sudo apt install mingw-w64
7575

76-
- if: matrix.os == 'ubuntu-latest' && matrix.type == 'linux' && matrix.freetype == true
77-
name: FreeType - Install (Linux)
76+
- name: FreeType - Install (Linux)
77+
if: matrix.os == 'ubuntu-latest' && matrix.type == 'linux' && matrix.freetype == true
7878
run: sudo apt install libfreetype6-dev
7979

80-
- if: matrix.os == 'ubuntu-latest' && matrix.type == 'windows' && matrix.freetype == true
81-
name: FreeType - Install (Windows)
80+
- name: FreeType - Install (Windows)
81+
if: matrix.os == 'ubuntu-latest' && matrix.type == 'windows' && matrix.freetype == true
8282
run: |
8383
sudo mkdir /freetype
8484
sudo tar -xzf ./vendor/freetype-2.12.1.tar.gz -C /freetype --strip-components=1
@@ -98,8 +98,8 @@ jobs:
9898
path: ${{ matrix.expected }}
9999

100100
update-bin:
101-
if: github.ref == 'refs/heads/main' # runs only on the main branch
102101
name: Update Binaries
102+
if: github.ref == 'refs/heads/main' # runs only on the main branch
103103
runs-on: ubuntu-latest
104104
needs: build-natives
105105
steps:
@@ -111,20 +111,33 @@ jobs:
111111
with:
112112
path: /tmp/artifacts
113113

114+
- name: Equal Artifacts
115+
id: equal-artifacts
116+
continue-on-error: true
117+
run: |
118+
python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries/imgui-java64.dll bin/imgui-java64.dll
119+
python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries/libimgui-java64.dylib bin/libimgui-java64.dylib
120+
python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries/libimgui-java64.so bin/libimgui-java64.so
121+
python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries-with-freetype/imgui-java64.dll bin/freetype/imgui-java64.dll
122+
python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries-with-freetype/libimgui-java64.dylib bin/freetype/libimgui-java64.dylib
123+
python3 buildSrc/scripts/equal_file_size.py /tmp/artifacts/native-libraries-with-freetype/libimgui-java64.so bin/freetype/libimgui-java64.so
124+
114125
- name: Update
126+
if: steps.equal-artifacts.outcome != 'success'
115127
run: |
116128
mv /tmp/artifacts/native-libraries/* bin/
117129
mv /tmp/artifacts/native-libraries-with-freetype/* bin/freetype/
118130
119131
- name: Commit
132+
if: steps.equal-artifacts.outcome != 'success'
120133
uses: EndBug/add-and-commit@v9
121134
with:
122135
default_author: github_actions
123136
message: '[ci skip] update native binaries'
124137

125138
release:
126-
if: startsWith(github.ref, 'refs/tags/v') # if tag starts with "v"
127139
name: Release
140+
if: startsWith(github.ref, 'refs/tags/v') # if tag starts with "v"
128141
runs-on: ubuntu-latest
129142
needs: [ build-java, build-natives ]
130143
steps:
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import sys
2+
import os
3+
4+
# A python script to compare file size of two files.
5+
# Used to compare sizes of binaries to see, if there is a difference between them.
6+
# Shell scripts are not used, since Python is a more portable solution.
7+
8+
os.path.getsize(sys.argv[1]) == os.path.getsize(sys.argv[2]) if sys.exit(0) else sys.exit(1)

0 commit comments

Comments
 (0)