1+ name : Unified Build
2+
3+ on :
4+ push :
5+ tags :
6+ - " v*"
7+ branches :
8+ - master
9+ pull_request :
10+ branches :
11+ - master
12+ release :
13+ types :
14+ - created
15+ workflow_dispatch :
16+
17+ jobs :
18+ setup-matrix :
19+ runs-on : ubuntu-latest
20+ outputs :
21+ matrix : ${{ steps.set-matrix.outputs.matrix }}
22+ steps :
23+ - id : set-matrix
24+ run : |
25+ echo "matrix={\
26+ \"include\":[\
27+ {\"os\":\"ubuntu-latest\",\"package_name\":\"linux-x64\"},\
28+ {\"os\":\"ubuntu-24.04-arm\",\"target\":\"aarch64-unknown-linux-gnu\",\"package_name\":\"linux-arm64\"},\
29+ {\"os\":\"windows-latest\",\"package_name\":\"windows-x64\"},\
30+ {\"os\":\"macos-latest\",\"package_name\":\"macos-aarch64\"},\
31+ {\"os\":\"macos-13\",\"package_name\":\"macos-x64\"}\
32+ ]}" >> "$GITHUB_OUTPUT"
33+
34+ build :
35+ needs : setup-matrix
36+ name : Build
37+ runs-on : ${{ matrix.os }}
38+ strategy :
39+ matrix : ${{fromJson(needs.setup-matrix.outputs.matrix)}}
40+ fail-fast : false
41+
42+ steps :
43+ - name : Checkout repository
44+ uses : actions/checkout@v4
45+
46+ - name : Setup Rust
47+ uses : actions-rs/toolchain@v1
48+ with :
49+ toolchain : stable
50+ override : true
51+ target : ${{ matrix.target }}
52+
53+ # Common setup steps for all platforms
54+ - name : Install OpenSSL (Windows)
55+ if : runner.os == 'Windows'
56+ shell : powershell
57+ run : |
58+ echo "VCPKG_ROOT=$env:VCPKG_INSTALLATION_ROOT" | Out-File -FilePath $env:GITHUB_ENV -Append
59+ vcpkg install openssl:x64-windows-static-md
60+
61+ - name : Cache cargo registry
62+ uses : actions/cache@v4
63+ with :
64+ path : ~/.cargo/registry
65+ key : ${{ runner.os }}-cargo-registry
66+ restore-keys : |
67+ ${{ runner.os }}-cargo-registry
68+
69+ - name : Cache cargo index
70+ uses : actions/cache@v4
71+ with :
72+ path : ~/.cargo/git
73+ key : ${{ runner.os }}-cargo-index
74+ restore-keys : |
75+ ${{ runner.os }}-cargo-index
76+
77+ # Build & testLibrary
78+ - name : Build and Test Library
79+ if : runner.os != 'Windows' # issue with the openssl-sys on windows -> and it gets tested later with the binary package
80+ run : |
81+ cd src-tauri
82+ if [ "${{ matrix.target }}" != "" ]; then
83+ cargo test --no-fail-fast --no-default-features --lib --target ${{ matrix.target }} 2>&1 | tee result_lib.txt
84+ else
85+ cargo test --no-fail-fast --no-default-features --lib 2>&1 | tee result_lib.txt
86+ fi
87+ shell : bash
88+ continue-on-error : true
89+
90+ - name : Format test results
91+ if : runner.os != 'Windows'
92+ uses : hahihula/rust-test-results-formatter@v1
93+ with :
94+ results-file : " ./src-tauri/result_lib.txt"
95+
96+ # Build CLI
97+ - name : Build CLI
98+ if : runner.os != 'Windows'
99+ run : |
100+ cd src-tauri
101+ if [ "${{ matrix.target }}" != "" ]; then
102+ cargo build --release --no-default-features --features cli --target ${{ matrix.target }}
103+ else
104+ cargo build --release --no-default-features --features cli
105+ fi
106+ shell : bash
107+
108+ # Build CLI Windows
109+ - name : Build CLI Windows
110+ if : runner.os == 'Windows'
111+ run : |
112+ cd src-tauri
113+ cargo build --release --no-default-features --features cli
114+ continue-on-error : true # just to test the test pipeline
115+
116+ # Build GUI (Tauri)
117+ - name : Setup Node
118+ uses : actions/setup-node@v4
119+ with :
120+ node-version : lts/*
121+
122+ - name : Install frontend dependencies
123+ run : yarn install
124+
125+ # Platform specific GUI dependencies
126+ - name : Install GUI dependencies (Ubuntu)
127+ if : runner.os == 'Linux'
128+ run : |
129+ sudo apt-get update
130+ sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev libssl-dev patchelf
131+
132+ # Signing and notarization steps
133+ - uses : apple-actions/import-codesign-certs@v3
134+ if : startsWith(matrix.os, 'macos')
135+ with :
136+ p12-file-base64 : ${{ secrets.MACOS_CERTIFICATE }}
137+ p12-password : ${{ secrets.MACOS_CERTIFICATE_PWD }}
138+ keychain : build
139+
140+ - name : build with signing and notarization (macos only)
141+ if : startsWith(matrix.os, 'macos')
142+ env :
143+ MACOS_CERTIFICATE : ${{ secrets.MACOS_CERTIFICATE }}
144+ APPLE_ID : ${{ secrets.NOTARIZATION_USERNAME }}
145+ APPLE_PASSWORD : ${{ secrets.NOTARIZATION_PASSWORD }}
146+ APPLE_TEAM_ID : ${{ secrets.NOTARIZATION_TEAM_ID }}
147+ MACOS_CERTIFICATE_PWD : ${{ secrets.MACOS_CERTIFICATE_PWD }}
148+ run : |
149+ /usr/bin/security create-keychain -p espressif notary.keychain
150+ /usr/bin/security default-keychain -s notary.keychain
151+ /usr/bin/security unlock-keychain -p espressif notary.keychain
152+ yarn tauri build
153+
154+
155+ - name : build app
156+ if : ${{ ! startsWith(matrix.os, 'macos') }}
157+ run : |
158+ yarn tauri build
159+
160+ # Install zip on Windows
161+ - name : Install zip (Windows)
162+ if : runner.os == 'Windows'
163+ shell : powershell
164+ run : |
165+ choco install zip -y
166+
167+ - name : Sign Windows binaries
168+ if : runner.os == 'Windows'
169+ env :
170+ WINDOWS_PFX_FILE : ${{ secrets.WIN_CERTIFICATE }}
171+ WINDOWS_PFX_PASSWORD : ${{ secrets.WIN_CERTIFICATE_PWD }}
172+ WINDOWS_SIGN_TOOL_PATH : ' C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86\signtool.exe'
173+ run : |
174+ echo $env:WINDOWS_PFX_FILE | Out-File -FilePath cert.b64 -Encoding ASCII
175+ certutil -decode cert.b64 cert.pfx
176+ Remove-Item cert.b64
177+ & "$env:WINDOWS_SIGN_TOOL_PATH" sign /f cert.pfx /p $env:WINDOWS_PFX_PASSWORD /tr http://timestamp.digicert.com /td sha256 /fd sha256 src-tauri/target/release/eim.exe
178+
179+ # Package and upload artifacts
180+ - name : Package artifacts
181+ shell : bash
182+ run : |
183+ mkdir -p release/{cli,lib,gui}
184+ # Handle CLI artifacts
185+ if [ -f "src-tauri/target/release/eim" ]; then
186+ cp src-tauri/target/release/eim release/cli/
187+ chmod +x release/cli/eim
188+ cd release/cli
189+ zip eim-cli.zip eim
190+ cd ../..
191+ elif [ -f "src-tauri/target/release/eim.exe" ]; then
192+ cp src-tauri/target/release/eim.exe release/cli/
193+ cd release/cli
194+ zip eim-cli.zip eim.exe
195+ cd ../..
196+ fi
197+ # Handle GUI artifacts
198+ if [ -d "src-tauri/target/release/bundle" ]; then
199+ for file in src-tauri/target/release/bundle/*; do
200+ if [ -f "$file" ]; then
201+ filename=$(basename "$file")
202+ # Make executable if not on Windows
203+ if [[ "$RUNNER_OS" != "Windows" ]]; then
204+ chmod +x "$file"
205+ fi
206+ cp "$file" release/gui/
207+ cd release/gui
208+ zip "${filename}.zip" "$filename"
209+ cd ../..
210+ elif [ -d "$file" ]; then
211+ dirname=$(basename "$file")
212+ cp -r "$file" release/gui/
213+ # Make executables executable if not on Windows
214+ if [[ "$RUNNER_OS" != "Windows" ]]; then
215+ if [[ "$RUNNER_OS" == "Darwin" ]]; then
216+ # macOS: find app bundles and make them executable
217+ find "release/gui/$dirname" -type f -perm +0111 -exec chmod +x {} \;
218+ else
219+ # Linux: make all files with execute permission stay executable
220+ find "release/gui/$dirname" -type f -perm /111 -exec chmod +x {} \;
221+ fi
222+ fi
223+ cd release/gui
224+ zip -r "${dirname}.zip" "$dirname"
225+ cd ../..
226+ fi
227+ done
228+ fi
229+
230+ - name : Upload artifacts CLI
231+ uses : actions/upload-artifact@v4
232+ with :
233+ name : eim-cli-${{ matrix.package_name }}-${{ github.run_number }}
234+ path : release/cli/*.zip
235+
236+ - name : Upload artifacts GUI
237+ uses : actions/upload-artifact@v4
238+ with :
239+ name : eim-${{ matrix.package_name }}-${{ github.run_number }}
240+ path : release/gui/*.zip
241+
242+ - name : Upload Release Assets
243+ if : github.event_name == 'release' && github.event.action == 'created'
244+ uses : actions/upload-release-asset@v1
245+ env :
246+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
247+ with :
248+ upload_url : ${{ github.event.release.upload_url }}
249+ asset_path : release/cli/eim-cli.zip
250+ asset_name : eim-cli-${{ matrix.package_name }}-${{ github.ref_name }}.zip
251+ asset_content_type : application/zip
252+
253+ # Tests can run in parallel after build
254+ test :
255+ needs : build
256+ uses : ./.github/workflows/test.yml
257+ with :
258+ run_id : ${{ github.run_number }}
259+ ref : ${{ github.event.pull_request.head.ref }}
260+
261+ test-cli :
262+ needs : build
263+ uses : ./.github/workflows/test_cli.yml
264+ with :
265+ run_id : ${{ github.run_number }}
266+ ref : ${{ github.event.pull_request.head.ref }}
267+
268+ update-release-info :
269+ needs : [build, test, test-cli]
270+ if : github.event_name == 'release' || github.event_name == 'workflow_dispatch'
271+ runs-on : ubuntu-latest
272+ steps :
273+ - name : Update release information
274+ env :
275+ AWS_ACCESS_KEY_ID : ${{ secrets.AWS_ACCESS_KEY_ID }}
276+ AWS_SECRET_ACCESS_KEY : ${{ secrets.AWS_SECRET_ACCESS_KEY }}
277+ AWS_DEFAULT_REGION : ap-east-1
278+ run : |
279+ # Update CLI release info
280+ curl -s https://api.github.com/repos/espressif/idf-im-cli/releases/latest > eim_cli_release.json
281+ aws s3 cp --acl=public-read "eim_cli_release.json" s3://espdldata/dl/eim/eim_cli_release.json
282+
283+ # Update GUI release info
284+ curl -s https://api.github.com/repos/espressif/idf-im-ui/releases/latest > eim_gui_release.json
285+ aws s3 cp --acl=public-read "eim_gui_release.json" s3://espdldata/dl/eim/eim_gui_release.json
0 commit comments